/* ============================================================
   UFUQ Quran LMS - Core Theme
   Islamic green & gold design system
   Bootstrap 5.3 RTL compatible
   ============================================================ */

/* ----- CSS Custom Properties ----- */
:root {
    --primary: #1B6B4A;
    --primary-light: #2E8B65;
    --primary-dark: #0D4A32;
    --secondary: #C8A961;
    --secondary-light: #D4BC7E;
    --secondary-dark: #A88B3D;
    --bg-quran: #FBF5E8;
    --bg-body: #f5f7f6;
    --bg-sidebar: linear-gradient(180deg, #0D4A32 0%, #1B6B4A 100%);
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --text-inverse: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #f0f0f0;
    --font-ui: 'Noto Kufi Arabic', 'Inter', sans-serif;
    --font-quran: 'Amiri', 'KFGQPC Hafs Smart', serif;
    --shadow-sm: 0 2px 10px rgba(27, 107, 74, 0.08);
    --shadow-md: 0 10px 40px rgba(27, 107, 74, 0.12);
    --shadow-lg: 0 20px 60px rgba(27, 107, 74, 0.16);
    --shadow-gold: 0 4px 20px rgba(200, 169, 97, 0.25);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 20px;
    --radius-xl: 28px;
}

/* ----- Base & Body ----- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 0.95rem;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

::selection {
    background-color: rgba(27, 107, 74, 0.15);
    color: var(--primary-dark);
}

/* ----- Typography ----- */
h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-ui);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 0.5em;
}

h1, .h1 { font-size: 2rem; }
h2, .h2 { font-size: 1.65rem; }
h3, .h3 { font-size: 1.35rem; }
h4, .h4 { font-size: 1.15rem; }
h5, .h5 { font-size: 1rem; }
h6, .h6 { font-size: 0.875rem; }

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

small, .text-small {
    font-size: 0.82rem;
}

.text-gold {
    color: var(--secondary) !important;
}

.text-green {
    color: var(--primary) !important;
}

/* ----- Buttons ----- */
.btn {
    font-family: var(--font-ui);
    font-weight: 600;
    border-radius: var(--radius-sm);
    padding: 0.55rem 1.5rem;
    font-size: 0.9rem;
    transition: var(--transition);
    border: none;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(27, 107, 74, 0.3);
}

.btn-primary:hover,
.btn-primary:focus {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: var(--text-inverse);
    box-shadow: 0 6px 25px rgba(27, 107, 74, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(27, 107, 74, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
    color: #3d2e00;
    box-shadow: var(--shadow-gold);
}

.btn-secondary:hover,
.btn-secondary:focus {
    background: linear-gradient(135deg, var(--secondary-dark) 0%, var(--secondary) 100%);
    color: #3d2e00;
    box-shadow: 0 6px 25px rgba(200, 169, 97, 0.35);
    transform: translateY(-1px);
}

.btn-outline-primary {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--primary);
    color: var(--text-inverse);
    box-shadow: 0 4px 15px rgba(27, 107, 74, 0.3);
}

.btn-outline-secondary {
    background: transparent;
    color: var(--secondary-dark);
    border: 2px solid var(--secondary);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    background: var(--secondary);
    color: #3d2e00;
}

.btn-sm {
    padding: 0.35rem 1rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1rem;
    border-radius: var(--radius);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ----- Cards ----- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 1.25rem 1.5rem;
    font-weight: 700;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background: transparent;
    border-top: 1px solid var(--border-light);
    padding: 1rem 1.5rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* ----- Forms ----- */
.form-control,
.form-select {
    font-family: var(--font-ui);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    color: var(--text-primary);
    background-color: var(--bg-card);
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(27, 107, 74, 0.12);
    outline: none;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.form-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus {
    box-shadow: 0 0 0 3px rgba(27, 107, 74, 0.15);
    border-color: var(--primary);
}

.form-switch .form-check-input:checked {
    background-color: var(--primary);
}

.input-group-text {
    background-color: #f9fafb;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ----- Badges ----- */
.badge {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.75em;
    border-radius: 6px;
}

.badge-primary,
.badge.bg-primary {
    background-color: rgba(27, 107, 74, 0.12) !important;
    color: var(--primary) !important;
}

.badge-secondary,
.badge.bg-secondary {
    background-color: rgba(200, 169, 97, 0.15) !important;
    color: var(--secondary-dark) !important;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.12) !important;
    color: #047857 !important;
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.12) !important;
    color: #b45309 !important;
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.12) !important;
    color: #dc2626 !important;
}

.badge-info {
    background-color: rgba(59, 130, 246, 0.12) !important;
    color: #2563eb !important;
}

/* ----- Tables ----- */
.table {
    font-size: 0.9rem;
    color: var(--text-primary);
    border-color: var(--border-light);
}

.table thead th {
    background-color: #f8faf9;
    border-bottom: 2px solid var(--primary);
    font-weight: 700;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--primary-dark);
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.table tbody tr:hover {
    background-color: rgba(27, 107, 74, 0.03);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(27, 107, 74, 0.02);
}

/* ----- Page Header ----- */
.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.page-header h1,
.page-header .page-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.page-header .page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.page-header .breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
    font-size: 0.82rem;
}

.page-header .breadcrumb-item a {
    color: var(--primary);
}

.page-header .breadcrumb-item.active {
    color: var(--text-muted);
}

/* ----- Stat Cards ----- */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    background: rgba(27, 107, 74, 0.1);
    color: var(--primary);
}

.stat-card .stat-change {
    font-size: 0.78rem;
    font-weight: 600;
}

.stat-card .stat-change.positive {
    color: #10b981;
}

.stat-card .stat-change.negative {
    color: #ef4444;
}

/* ----- Avatar ----- */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: var(--text-inverse);
    flex-shrink: 0;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
}

.avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 1.6rem;
}

.avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ----- Progress Bars ----- */
.progress {
    height: 8px;
    border-radius: 20px;
    background-color: rgba(27, 107, 74, 0.08);
    overflow: hidden;
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 20px;
    transition: width 0.6s ease;
}

.progress-bar.bg-gold {
    background: linear-gradient(90deg, var(--secondary) 0%, var(--secondary-light) 100%);
}

.progress-sm {
    height: 5px;
}

.progress-lg {
    height: 12px;
}

/* ----- Alerts ----- */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    padding: 1rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-success {
    background-color: rgba(27, 107, 74, 0.08);
    color: var(--primary-dark);
    border-right: 4px solid var(--primary);
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.08);
    color: #92400e;
    border-right: 4px solid #f59e0b;
}

.alert-danger {
    background-color: rgba(239, 68, 68, 0.08);
    color: #991b1b;
    border-right: 4px solid #ef4444;
}

.alert-info {
    background-color: rgba(59, 130, 246, 0.08);
    color: #1e40af;
    border-right: 4px solid #3b82f6;
}

/* ----- Miscellaneous Utilities ----- */
.divider {
    height: 1px;
    background: var(--border-light);
    margin: 1.5rem 0;
}

.divider-gold {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--secondary), transparent);
    margin: 1.5rem 0;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-green {
    box-shadow: var(--shadow-md) !important;
}

.border-green {
    border-color: var(--primary) !important;
}

.border-gold {
    border-color: var(--secondary) !important;
}

.rounded-theme {
    border-radius: var(--radius) !important;
}

.rounded-theme-lg {
    border-radius: var(--radius-lg) !important;
}

/* ----- Top Nav & Layout ----- */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-box {
    position: relative;
    max-width: 360px;
}

.search-box .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    z-index: 2;
}

.search-box .search-input {
    padding-right: 36px;
    border-radius: var(--radius-sm);
    background: rgba(27, 107, 74, 0.04);
    border-color: transparent;
}

.search-box .search-input:focus {
    background: var(--bg-card);
    border-color: var(--primary);
}

.badge-notification {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
}

.nav-icon-btn {
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.nav-icon-btn:hover {
    color: var(--primary);
}

.app-footer {
    border-top: 1px solid var(--border-light);
    margin-top: auto;
}

/* ----- Loading Overlay ----- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(27, 107, 74, 0.25);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(27, 107, 74, 0.4);
}

/* ===== Global Search Results Dropdown ===== */
.search-results-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    z-index: 1050;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
}

[data-bs-theme="dark"] .search-results-dropdown {
    background: rgba(30, 30, 30, 0.97);
    border-color: rgba(255, 255, 255, 0.1);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
    background: rgba(27, 107, 74, 0.08);
    color: inherit;
}

.search-result-icon {
    font-size: 1.25rem;
    color: var(--bs-green, #1a6b3c);
    min-width: 1.5rem;
    text-align: center;
}

.search-result-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.search-result-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-meta {
    font-size: 0.78rem;
    color: var(--bs-secondary-color, #6c757d);
}

.search-no-results {
    padding: 1.5rem;
    text-align: center;
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.9rem;
}
