/* =================================
   Modern UI Components
   ================================= */

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

/* Modern Card */
.modern-card {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    overflow: hidden;
    border: none;
}

.modern-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.modern-card .card-img-top {
    height: 280px;
    object-fit: cover;
    transition: var(--transition);
}

.modern-card:hover .card-img-top {
    transform: scale(1.05);
}

.modern-card .card-body {
    padding: 1.5rem;
}

.modern-card .card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.modern-card .card-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Gradient Button */
.btn-gradient {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    color: white;
    font-weight: 600;
    padding: 0.75rem 2rem;
    border-radius: 50px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(13, 115, 119, 0.3);
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 115, 119, 0.4);
    color: white;
}

.btn-gradient-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #c44e3a 100%);
    box-shadow: 0 4px 15px rgba(231, 111, 81, 0.3);
}

.btn-gradient-success {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--secondary-color) 100%);
    box-shadow: 0 4px 15px rgba(13, 115, 119, 0.3);
}

/* Modern Badge */
.modern-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
    margin: 0.2rem;
}

/* Sidebar Modern */
.modern-sidebar {
    background: white;
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.modern-sidebar h4 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.modern-sidebar .list-group-item {
    border: none;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    padding: 0.9rem 1.2rem;
    transition: var(--transition);
    background: var(--light-bg);
    font-weight: 500;
}

.modern-sidebar .list-group-item:hover {
    background: var(--accent-color);
    color: white;
    transform: translateX(-5px);
}

.modern-sidebar .list-group-item.active {
    background: linear-gradient(135deg, var(--accent-color) 0%, #2980B9 100%);
    color: white;
    font-weight: 600;
}

/* Search Bar Modern */
.modern-search {
    background: white;
    border-radius: 50px;
    padding: 0.5rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

.modern-search .form-control {
    border: none;
    border-radius: 50px;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
}

.modern-search .form-control:focus {
    box-shadow: none;
}

.modern-search .btn {
    border-radius: 50px;
    padding: 0.8rem 2rem;
}

/* Loading Spinner */
.modern-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(52, 152, 219, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Alert Modern */
.modern-alert {
    border-radius: 16px;
    border: none;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.modern-alert i {
    font-size: 1.5rem;
    margin-left: 0.5rem;
}

/* Navbar Modern */
.modern-navbar {
    background: white;
    box-shadow: var(--shadow-md);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-radius: 0 0 24px 24px;
}

.modern-navbar .navbar-brand {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color) 0%, #2980B9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Book Detail Page */
.book-detail-cover {
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    background: white;
    padding: 1rem;
}

.book-detail-cover img {
    border-radius: 16px;
    width: 100%;
}

.book-info-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: var(--light-bg);
    border-radius: 12px;
}

.book-info-item i {
    font-size: 1.5rem;
    margin-left: 1rem;
    color: var(--accent-color);
}

.book-content-wrapper {
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: var(--shadow-md);
    line-height: 2.2;
    font-size: 1.1rem;
}

/* Admin Dashboard */
.admin-stat-card {
    border-radius: 20px;
    padding: 2rem;
    color: white;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    overflow: hidden;
    position: relative;
}

.admin-stat-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(45deg);
    transition: var(--transition);
}

.admin-stat-card:hover {
    transform: translateY(-10px);
}

.admin-stat-card:hover::before {
    right: -40%;
}

.admin-stat-card h2 {
    font-size: 3rem;
    font-weight: 800;
    margin: 0;
    color: white;
}

.admin-stat-card h6 {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    opacity: 0.9;
    color: white;
}

/* Table Modern */
.modern-table {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.modern-table table {
    margin: 0;
}

.modern-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a2533 100%);
    color: white;
}

.modern-table thead th {
    padding: 1.2rem 1rem;
    font-weight: 600;
    border: none;
}

.modern-table tbody tr {
    transition: var(--transition);
}

.modern-table tbody tr:hover {
    background: var(--light-bg);
}

.modern-table tbody td {
    padding: 1rem;
    vertical-align: middle;
}

/* Form Modern */
.modern-form .form-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.modern-form .form-control,
.modern-form .form-select {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    transition: var(--transition);
}

.modern-form .form-control:focus,
.modern-form .form-select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.15);
}

.modern-form .input-group-text {
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 12px 0 0 12px;
    padding: 0.8rem 1.2rem;
}

/* Accordion Modern */
.modern-accordion .accordion-item {
    border: none;
    border-radius: 16px !important;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.modern-accordion .accordion-button {
    background: white;
    color: var(--primary-color);
    font-weight: 600;
    padding: 1.2rem 1.5rem;
    border-radius: 16px;
}

.modern-accordion .accordion-button:not(.collapsed) {
    background: linear-gradient(135deg, var(--accent-color) 0%, #2980B9 100%);
    color: white;
}

.modern-accordion .accordion-body {
    padding: 1.5rem;
    line-height: 2;
    font-size: 1.05rem;
}

/* Pagination Modern */
.modern-pagination .page-link {
    border: none;
    border-radius: 12px;
    margin: 0 0.2rem;
    padding: 0.6rem 1rem;
    font-weight: 600;
    transition: var(--transition);
}

.modern-pagination .page-link:hover {
    background: var(--accent-color);
    color: white;
}

.modern-pagination .page-item.active .page-link {
    background: linear-gradient(135deg, var(--accent-color) 0%, #2980B9 100%);
    border: none;
}

/* Responsive */
/* Mobile First - Extra Small devices (phones, less than 576px) */
@media (max-width: 575.98px) {
    h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
    h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
    h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
    h4 { font-size: 1rem; margin-bottom: 0.4rem; }
    h5 { font-size: 0.95rem; }
    h6 { font-size: 0.9rem; }

    body {
        font-size: 13px;
        line-height: 1.5;
    }

    /* Sidebar optimization */
    .modern-sidebar {
        position: static;
        margin-bottom: 1rem;
        padding: 0.75rem;
        max-height: none;
        border-radius: 12px;
    }

    .modern-sidebar h4 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.4rem;
    }

    .modern-sidebar .list-group-item {
        padding: 0.6rem 0.8rem;
        margin-bottom: 0.3rem;
        font-size: 0.85rem;
        border-radius: 8px;
    }

    .modern-sidebar .badge {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }

    /* Card optimization */
    .modern-card {
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .modern-card .card-img-top {
        height: 160px;
        border-radius: 12px 12px 0 0;
    }

    .modern-card .card-body {
        padding: 0.75rem;
    }

    .modern-card .card-title {
        font-size: 0.95rem;
        margin-bottom: 0.4rem;
        font-weight: 600;
    }

    .modern-card .card-text {
        font-size: 0.8rem;
        line-height: 1.4;
        margin-bottom: 0.5rem;
    }

    .modern-card .text-muted {
        font-size: 0.75rem;
    }

    .modern-card .card-footer {
        padding: 0.5rem 0.75rem;
    }

    /* Navbar optimization */
    .modern-navbar {
        padding: 0.6rem 0;
        border-radius: 0 0 16px 16px;
        margin-bottom: 1rem;
    }

    .modern-navbar .navbar-brand {
        font-size: 1.2rem;
        margin-bottom: 0.2rem;
    }

    .modern-navbar .text-muted {
        font-size: 0.75rem;
    }

    /* Search bar optimization */
    .modern-search {
        padding: 0.3rem;
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .modern-search .form-control {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .modern-search .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
    }

    .modern-search-group {
        flex-wrap: wrap;
    }

    .modern-search-group .input-group-text {
        padding: 0.5rem 0.75rem;
    }

    .modern-search-group .form-control {
        font-size: 0.85rem;
        padding: 0.5rem 0.75rem;
    }

    .modern-search-group .btn {
        padding: 0.5rem 0.85rem;
        font-size: 0.85rem;
        flex: 1 1 auto;
        margin-top: 0.3rem;
    }

    /* Button optimization */
    .btn-gradient {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        border-radius: 25px;
    }

    .btn {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    /* Badge optimization */
    .modern-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        margin: 0.15rem;
    }

    /* Content optimization */
    .book-content-wrapper {
        padding: 0.75rem;
        font-size: 0.9rem;
        line-height: 1.6;
        border-radius: 12px;
    }

    /* Container optimization */
    .container-fluid {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    .px-4 {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    .p-3 {
        padding: 0.5rem !important;
    }

    /* Alert optimization */
    .modern-alert {
        padding: 0.75rem;
        font-size: 0.85rem;
        border-radius: 12px;
        margin-bottom: 1rem;
    }

    .modern-alert i {
        font-size: 1.1rem;
    }

    /* Icon size */
    .bi {
        font-size: 0.9rem;
    }

    /* Info box in sidebar */
    .modern-sidebar .bg-light {
        padding: 0.6rem !important;
        margin-top: 0.75rem !important;
        border-radius: 8px;
    }

    .modern-sidebar .bg-light h6 {
        font-size: 0.85rem;
        margin-bottom: 0.3rem;
    }

    .modern-sidebar .bg-light p {
        font-size: 0.75rem;
        line-height: 1.4;
    }

    /* Page header optimization */
    .d-flex.justify-content-between {
        flex-direction: column;
        gap: 0.5rem;
    }

    .d-flex.justify-content-between > div {
        width: 100%;
    }
}

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) and (max-width: 767.98px) {
    h1 { font-size: 1.9rem; }
    h2 { font-size: 1.65rem; }

    .modern-sidebar {
        position: static;
        margin-bottom: 2rem;
    }

    .modern-card .card-img-top {
        height: 220px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) and (max-width: 991.98px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }

    .modern-sidebar {
        position: static;
        margin-bottom: 2rem;
    }

    .modern-card .card-img-top {
        height: 240px;
    }
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slideInRight 0.5s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--accent-color) 100%);
}

/* Modern Search Group Styles */
.modern-search-group {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.modern-search-group:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 6px 20px rgba(13, 115, 119, 0.15);
}

.modern-search-group .input-group-text {
    border: none;
    padding-right: 1rem;
}

.modern-search-group .form-control {
    border: none;
    font-size: 1.05rem;
    padding: 0.75rem 1rem;
}

.modern-search-group .form-control:focus {
    box-shadow: none;
}

.modern-search-group .btn {
    border: none;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: all 0.3s ease;
}

.modern-search-group .btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.modern-search-group .btn-primary {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
}

.modern-search-group .btn-success {
    background: linear-gradient(135deg, #198754 0%, #146c43 100%);
}

/* Search Highlight Styles */
.search-highlight {
    background: linear-gradient(120deg, #ffd700 0%, #ffed4e 100%);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(255, 215, 0, 0.3);
    border: 1px solid rgba(255, 215, 0, 0.5);
}

.matched-paragraphs .alert {
    transition: all 0.3s ease;
}

.matched-paragraphs .alert:hover {
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Search result paragraph clickable styling */
.search-result-paragraph {
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-result-paragraph:hover {
    background-color: #f0f8ff !important;
    border-color: #198754 !important;
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(25, 135, 84, 0.2);
}
