:root {
    --primary-color: #052d9bfe;
    --accent-color: #2564eba7;
    --bg-light: #f8fafc;
    --text-color: #334155;
    --white: #ffffff;
    --border-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
}

/* ==========================================
   SIDEBAR NAVIGATION
========================================== */
/* ==========================================
   SIDEBAR NAVIGATION (COMPACT DESIGN)
========================================== */
.sidebar {
    width: 250px;
    background-color: var(--primary-color);
    color: var(--white);
    padding: 6px 8px; /* Waxaa la dhimay padding-ka guud */
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    transition: width 0.3s ease;
}

.sidebar-header {
    margin-bottom: 4px; /* La dhimay */
    padding: 2px 4px; /* La dhimay */
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo-img {
    max-height: 50px; /* Logo-ga ayaa la yarayey in yar */
    max-width: 100%;
    object-fit: contain;
    margin-bottom: 2px;
}

.sidebar h2.logo-text {
    font-size: 0.9rem; /* Farta magaca waa la yarayey */
    color: #38bdf8;
    text-transform: uppercase;
    font-weight: 700;
}

.sidebar .logo-icon {
    display: none;
    font-size: 1.1rem;
    font-weight: bold;
    color: #38bdf8;
    text-align: center;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 1px; /* Fogaanta u dhaxaysa linkiyada oo aad loo yareeyey */
}

.nav-item {
    color: #f6f7f7;
    text-decoration: none;
    padding: 5px 8px; /* Padding aad u yar oo ka dhigaya compact */
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-size: 0.82rem; /* Far yar oo sahleysa in linkiyo badani isku mid wada qaadaan */
}

.nav-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.nav-item:hover, .nav-item.active {
    background-color: #54617b;
    color: var(--white);
}
/* ==========================================
   MAIN LAYOUT & HEADER
========================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100vh;
    overflow: hidden;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 15px 30px;
    border-bottom: 1px solid var(--border-color);
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.header-bar h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--primary-color);
}

.user-role {
    font-size: 0.75rem;
    color: #64748b;
}

.content-body {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
}

/* ==========================================
   CARDS UI
========================================== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.card {
    background: var(--white);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.card h3 {
    font-size: 0.9rem;
    color: #64748b;
    margin-bottom: 10px;
}

.card .number {
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--primary-color);
}

/* ==========================================
   TABLE & CONTAINER
========================================== */
.table-container {
    background: #ffffff;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.student-info {
    display: flex;
    flex-direction: column;
}

.student-name {
    font-weight: 600;
    color: #1e293b;
}

.student-id {
    color: #64748b;
    font-size: 0.78rem;
}

.amount-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.original-price {
    color: #475569;
}

.discount-badge {
    background-color: #fef3c7;
    color: #b45309;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-top: 2px;
    font-weight: 600;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 15px;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #334155;
}

th, td {
    padding: 14px 18px;
    text-align: left;
    font-size: 0.9rem;
    white-space: nowrap;
}

th {
    background-color: #f8fafc;
    color: #475569;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    border-bottom: 2px solid #e2e8f0;
}

th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }

td {
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.2s ease;
}

tr:hover td {
    background-color: #f8fafc;
}

/* ==========================================
   BUTTONS & BADGES
========================================== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 0.85rem;
}

.btn-primary { background: var(--accent-color); color: var(--white); }
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none !important;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    margin-right: 4px;
}

.btn-action.view {
    color: #2563eb !important;
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
}
.btn-action.view:hover { background-color: #dbeafe; }

.btn-action.edit {
    color: #059669 !important;
    background-color: #ecfdf5;
    border: 1px solid #a7f3d0;
}
.btn-action.edit:hover { background-color: #d1fae5; }

.badge-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: inline-block;
    text-align: center;
}

.badge-status.unpaid {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
    border: 1px solid #fecaca;
}

.badge-status.paid {
    background-color: #f0fdf4 !important;
    color: #16a34a !important;
    border: 1px solid #bbf7d0;
}

.badge-status.partially_paid,
.badge-status.partial {
    background-color: #fffbebfb !important;
    color: #d97706 !important;
    border: 1px solid #fde68a;
}

/* ==========================================
   ALERTS & LOADER
========================================== */
.alert-msg {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 1;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-msg.fade-out {
    opacity: 0;
    transform: translateY(-10px);
}

#global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(2px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#global-loader.hidden {
    opacity: 0;
    visibility: hidden;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid var(--border-color);
    border-top: 5px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================
   MODAL POPUP STYLING (CLEAN & UNIQUE)
========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease-in-out;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-card {
    background: #ffffff;
    width: 100%;
    max-width: 520px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transform: translateY(-20px);
    transition: transform 0.25s ease-in-out;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    padding: 18px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
    color: #0f172a;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #64748b;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #0f172a;
}

.modal-body {
    padding: 24px;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.detail-item label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.detail-item p {
    margin: 0;
    font-size: 0.95rem;
    color: #1e293b;
    font-weight: 500;
}

.detail-item.highlight p {
    color: #2563eb;
    font-size: 1.1rem;
    font-weight: 700;
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #0f172a;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.readonly-input {
    background-color: #f1f5f9;
    color: #64748b;
    cursor: not-allowed;
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.btn-modal {
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    border: none;
    transition: background 0.2s ease;
}

.btn-close-modal {
    background: #e2e8f0;
    color: #475569;
}

.btn-close-modal:hover {
    background: #cbd5e1;
}

.btn-save-modal {
    background: #2563eb;
    color: #ffffff;
}

.btn-save-modal:hover {
    background: #1d4ed8;
}

/* ==========================================
   RESPONSIVE MEDIA QUERIES
========================================== */
@media screen and (max-width: 992px) {
    .sidebar {
        width: 70px;
        padding: 20px 8px;
        align-items: center;
    }

    .sidebar h2.logo-text { display: none; }
    .sidebar .logo-icon { display: block; }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .nav-text { display: none; }
    .header-bar { padding: 12px 15x; }
    .header-bar h3 { font-size: 0.95rem; }
    .user-info { display: none; }
}

@media screen and (max-width: 600px) {
    .content-body { padding: 15px; }
    .details-grid { grid-template-columns: 1fr; }
}

/* Badhanka Daabacaadda */
.btn-print {
    background: #059669;
    color: #ffffff;
}
.btn-print:hover {
    background: #047857;
}

/* Header & Footer-ka Rasiidka marka caadi loo joogo waa qarsoon yihiin */
.receipt-header, .receipt-footer {
    display: none;
    text-align: center;
}

/* ==========================================
   PRINT STYLES (THERMAL PRINTER 80mm/58mm)
========================================== */
@media print {
    /* Qarso dhamaan element-yada bogga */
    body * {
        visibility: hidden;
    }

    /* Kaliya soo saar modalka shaqaynaya */
    #viewModal, #viewModal * {
        visibility: visible;
    }

    #viewModal {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        background: transparent !important;
        backdrop-filter: none !important;
    }

    .modal-card {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: 80mm !important; /* Cabirka Caadiga ah ee Thermal Printer-ka */
        margin: 0 auto;
        padding: 0;
    }

    /* Qari badhamada iyo header-ka modalka */
    .hide-on-print {
        display: none !important;
    }

    /* Muuji header-ka iyo footer-ka rasiidka */
    .receipt-header, .receipt-footer {
        display: block !important;
    }

    .receipt-header h2 {
        font-size: 1.1rem;
        margin-bottom: 2px;
    }

    .receipt-header p, .receipt-footer p {
        font-size: 0.75rem;
        margin: 0;
    }

    .details-grid {
        grid-template-columns: 1fr !important; /* Hal saf ka dhig rasiidka */
        gap: 6px !important;
    }

    .detail-item {
        display: flex;
        justify-content: space-between;
        border-bottom: 1px dashed #ccc;
        padding-bottom: 4px;
    }

    .detail-item label, .detail-item p {
        font-size: 0.8rem !important;
        margin: 0;
    }
}