:root {
    --primary-color: #1a6b4f;
    --primary-hover: #14523d;
    --primary-light: #e8f5f0;
    --sidebar-width: 260px;
    --sidebar-bg: #ffffff;
    --sidebar-text: #1e293b;
    --sidebar-text-muted: #64748b;
    --sidebar-border: #e2e8f0;
    --topbar-bg: #ffffff;
    --topbar-border: #e2e8f0;
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --table-hover: #f1f5f9;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --superadmin-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --superadmin-primary: #667eea;
    --superadmin-secondary: #764ba2;
    min-height: 100vh;
}

[data-bs-theme="dark"] {
    --primary-color: #2e8b6e;
    --primary-hover: #3a9f7d;
    --primary-light: #1a3d2e;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --sidebar-text-muted: #94a3b8;
    --sidebar-border: #334155;
    --topbar-bg: #1e293b;
    --topbar-border: #334155;
    --body-bg: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --table-hover: #263449;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    
    /* Bootstrap Native Overrides */
    --bs-body-bg: #0f172a;
    --bs-body-color: #f1f5f9;
    --bs-tertiary-bg: #1e293b;
    --bs-border-color: #334155;
    --bs-border-color-translucent: rgba(255,255,255,0.1);
}

/* Override Bootstrap Utility Classes that break Dark Mode */
[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-black {
    color: var(--bs-body-color) !important;
}

[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .btn-light {
    background-color: var(--bs-tertiary-bg) !important;
    color: var(--bs-body-color) !important;
    border-color: var(--bs-border-color) !important;
}

[data-bs-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

body {
    margin: 0;
    background-color: var(--body-bg);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    z-index: 100;
    border-right: 1px solid var(--sidebar-border);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--sidebar-text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}

.sidebar-brand i {
    color: var(--primary-color);
}

.sidebar-brand-text {
    color: var(--primary-color);
}

.sidebar-brand-subtitle {
    color: var(--sidebar-text-muted);
}

.sidebar-logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sidebar-text-muted);
    font-weight: 700;
    padding: 0.75rem 0.75rem 0.25rem;
    flex-shrink: 0;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.925rem;
    transition: all 0.2s ease;
    margin-bottom: 0.25rem;
    cursor: pointer;
}

.sidebar-link:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.sidebar-link.active {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(26, 107, 79, 0.3);
}

.sidebar-link span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 1.5rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--sidebar-border);
    background-color: var(--sidebar-bg);
    position: relative;
    z-index: 1;
}

.sidebar-footer .btn {
    pointer-events: auto;
    z-index: 2;
    position: relative;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--topbar-bg);
    height: 64px;
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    position: relative;
    z-index: 10;
}

.topbar .btn {
    pointer-events: auto;
    z-index: 15;
    position: relative;
}

.content-body {
    padding: 1.5rem;
    flex-grow: 1;
}

/* Modern Card */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
}

.bg-soft-primary { background-color: #eff6ff; color: #2563eb; }
.bg-soft-success { background-color: #ecfdf5; color: #059669; }
.bg-soft-danger { background-color: #fef2f2; color: #dc2626; }
.bg-soft-warning { background-color: #fffbeb; color: #d97706; }
.bg-soft-info { background-color: #f0fdfa; color: #0d9488; }
.bg-soft-purple { background-color: #faf5ff; color: #7c3aed; }

[data-bs-theme="dark"] .bg-soft-primary { background-color: rgba(37, 99, 235, 0.15) !important; color: #60a5fa !important; }
[data-bs-theme="dark"] .bg-soft-success { background-color: rgba(5, 150, 105, 0.15) !important; color: #34d399 !important; }
[data-bs-theme="dark"] .bg-soft-danger { background-color: rgba(220, 38, 38, 0.15) !important; color: #f87171 !important; }
[data-bs-theme="dark"] .bg-soft-warning { background-color: rgba(217, 119, 6, 0.15) !important; color: #fbbf24 !important; }
[data-bs-theme="dark"] .bg-soft-info { background-color: rgba(13, 148, 136, 0.15) !important; color: #2dd4bf !important; }
[data-bs-theme="dark"] .bg-soft-purple { background-color: rgba(124, 58, 237, 0.15) !important; color: #a78bfa !important; }

/* Tables */
.custom-table {
    background: var(--card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--card-border);
    overflow-x: auto;
    overflow-y: hidden;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
    -webkit-overflow-scrolling: touch;
}

.custom-table table {
    margin-bottom: 0;
}

.custom-table thead th {
    background-color: var(--primary-light);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.825rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border-color);
    padding: 0.9rem 1rem;
}

.custom-table tbody td {
    padding: 0.9rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.925rem;
    color: var(--text-primary);
}

.custom-table tbody tr:hover {
    background-color: var(--table-hover);
}

/* Badges */
.badge-soft-success { background: #dcfce7; color: #15803d; }
.badge-soft-danger { background: #fee2e2; color: #b91c1c; }
.badge-soft-warning { background: #fef3c7; color: #b45309; }
.badge-soft-info { background: #e0f2fe; color: #0369a1; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }

/* Thermal Receipt Printable Styles - 58mm */
.thermal-receipt-container {
    max-width: 600px;
    margin: 0 auto;
}

.thermal-receipt {
    width: 58mm;
    max-width: 100%;
    margin: 0 auto;
    background: #ffffff;
    padding: 8px 6px;
    font-family: 'Courier New', 'Courier', 'Consolas', 'Monaco', monospace;
    font-size: 11px;
    line-height: 1.3;
    color: #000000;
    border: 1px dashed #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Thermal printer specific fonts */
@font-face {
    font-family: 'Thermal';
    src: local('Courier New'), local('Courier'), local('Consolas');
    font-weight: normal;
    font-style: normal;
}

.thermal-receipt {
    font-family: 'Thermal', 'Courier New', 'Courier', 'Consolas', 'Monaco', monospace;
}

/* Qirqish chizig'i */
.receipt-cut-line {
    display: none;
    text-align: center;
    margin: 15px 0;
    color: #999;
}

.cut-line-dashed {
    border-top: 2px dashed #999;
    margin: 5px 0;
}

.cut-line-scissors {
    font-size: 20px;
    color: #666;
    background: #f8fafc;
    width: 40px;
    height: 40px;
    line-height: 40px;
    border-radius: 50%;
    margin: 5px auto;
    border: 2px solid #ddd;
}

/* Yangi chek dizayn elementlari */
.receipt-date {
    font-size: 9px;
    margin-top: 1px;
    color: #666;
}

.receipt-debt {
    color: #dc2626;
    font-weight: bold;
}

.receipt-qr {
    width: 40px;
    height: 40px;
    display: block;
    margin: 0 auto;
}

.receipt-qr-text {
    font-size: 8px;
    margin-top: 2px;
    color: #666;
}

.receipt-thanks {
    font-weight: bold;
    margin-bottom: 2px;
}

.receipt-contact {
    font-size: 9px;
    margin: 1px 0;
}

.receipt-system {
    font-size: 8px;
    margin-top: 3px;
    color: #555;
}

.receipt-header {
    text-align: center;
    padding-bottom: 4px;
    border-bottom: 1px dashed #000;
}

.receipt-title {
    font-size: 14px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 1px;
}

.receipt-subtitle {
    font-size: 10px;
    font-weight: bold;
}

.receipt-divider {
    border-top: 1px dashed #000;
    margin: 4px 0;
}

.receipt-divider-double {
    border-top: 2px solid #000;
    margin: 4px 0;
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 2px;
    font-size: 10px;
}

.receipt-amount-box {
    text-align: center;
    background: #f8fafc;
    border: 2px solid #000;
    padding: 6px 3px;
    margin: 6px 0;
    border-radius: 3px;
}

.receipt-amount-title {
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.receipt-amount-val {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.3px;
}

.receipt-stamp {
    display: inline-block;
    border: 2px solid #15803d;
    color: #15803d;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 1px;
    border-radius: 2px;
    margin-top: 3px;
    text-transform: uppercase;
}

.receipt-footer {
    text-align: center;
    font-size: 9px;
    margin-top: 6px;
    border-top: 1px dashed #000;
    padding-top: 4px;
}

.receipt-copy-badge {
    text-align: center;
    font-size: 9px;
    font-weight: bold;
    padding: 2px 0;
    background: #e2e8f0;
    margin-bottom: 4px;
    border-radius: 2px;
}

.receipt-qr-section {
    text-align: center;
    margin: 6px 0;
    padding: 4px;
    background: #f8fafc;
    border-radius: 3px;
}

/* Dual Receipt Layout for 2 copies */
.dual-receipt-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

@media print {
    @page {
        size: 58mm auto;
        margin: 0;
    }

    html,
    body {
        width: 58mm !important;
        min-width: 58mm !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
        color: #000 !important;
    }

    .no-print, .sidebar, .topbar, .btn, .modal-header, .modal-footer {
        display: none !important;
    }

    .main-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    .content-body {
        padding: 0 !important;
    }

    .thermal-receipt {
        border: none !important;
        box-shadow: none !important;
        width: 54mm !important;
        max-width: 54mm !important;
        margin: 0 auto !important;
        padding: 2mm !important;
        page-break-after: always;
    }

    .thermal-receipt-container {
        display: block !important;
    }

    .receipt-cut-line {
        display: block !important;
        page-break-after: always;
    }

    #second-copy {
        display: block !important;
        page-break-before: always;
    }
}

/* Superadmin Specific Styles */
.superadmin-header {
    background: var(--superadmin-gradient);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.superadmin-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.superadmin-header p {
    margin: 0.5rem 0 0 0;
    opacity: 0.9;
    font-size: 0.9rem;
}

.superadmin-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-weight: 600;
    font-size: 0.75rem;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.superadmin-card {
    border-left: 4px solid var(--superadmin-primary);
    transition: all 0.3s ease;
}

.superadmin-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
}

.superadmin-card .stat-icon {
    background: linear-gradient(135deg, var(--superadmin-primary) 0%, var(--superadmin-secondary) 100%);
    color: white;
}

.superadmin-btn {
    background: var(--superadmin-gradient);
    border: none;
    color: white;
    transition: all 0.3s ease;
}

.superadmin-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: white;
}

.superadmin-table thead {
    background: var(--superadmin-gradient);
    color: white;
}

.superadmin-table thead th {
    border: none;
    font-weight: 600;
    font-size: 0.875rem;
}

/* Info Bar */
.info-bar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.info-bar .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Button Groups Fix */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.btn-group .btn {
    flex-shrink: 0;
}

/* Remove Bootstrap Button Override - Bootstrap CSS should work properly */

/* Enhanced Cards */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    height: 100%;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.bg-soft-primary {
    background: rgba(26, 107, 79, 0.1);
    color: #1a6b4f;
}

.bg-soft-success {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.bg-soft-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.bg-soft-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.bg-soft-info {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
}

.bg-soft-purple {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
}

/* Remove conflicting Bootstrap overrides */
.card {
    border: 1px solid var(--card-border) !important;
    background-color: var(--card-bg) !important;
}

.table {
    --bs-table-color: var(--text-primary);
    --bs-table-bg: var(--card-bg);
    --bs-table-border-color: var(--border-color);
}

.btn {
    /* Let Bootstrap handle button styling */
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-wrapper {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        height: 100vh;
        width: 280px;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        pointer-events: none;
    }

    .sidebar-overlay.active {
        display: block;
        pointer-events: auto;
    }

    .topbar {
        padding: 0 0.75rem;
        gap: 0.5rem;
    }

    .topbar > div:first-child {
        min-width: 0;
    }

    .topbar h5 {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .topbar > div:last-child {
        flex-shrink: 0;
    }

    .topbar > div:last-child .btn-outline-danger {
        padding-left: 0.55rem;
        padding-right: 0.55rem;
        font-size: 0;
    }

    .topbar > div:last-child .btn-outline-danger i {
        font-size: 0.9rem;
        margin-right: 0 !important;
    }

    .content-body {
        padding: 1rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .custom-table {
        font-size: 0.85rem;
    }

    .custom-table thead th,
    .custom-table tbody td {
        padding: 0.5rem 0.75rem;
    }

    .btn {
        font-size: 0.875rem;
        padding: 0.375rem 0.75rem;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Adjust charts for mobile */
    canvas {
        max-height: 250px !important;
    }

    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: block !important;
        margin-right: 0.75rem;
    }

    .desktop-menu-toggle {
        display: none !important;
    }
}

@media (max-width: 576px) {
    .content-body {
        padding: 0.75rem;
    }

    .stat-card {
        padding: 0.875rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    h4, .h4 {
        font-size: 1.25rem;
    }

    h5, .h5 {
        font-size: 1.1rem;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .btn-group .btn {
        margin-bottom: 0.25rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .form-control,
    .form-select {
        font-size: 16px; /* Prevent iOS zoom */
    }
}

/* Desktop menu toggle hidden by default */
.mobile-menu-toggle {
    display: none;
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.mobile-menu-toggle:hover {
    background-color: var(--primary-color);
    color: #ffffff;
    border-color: var(--primary-color);
}

/* Touch-friendly targets */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .sidebar-link,
    a {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Ensure logout buttons are always clickable */
a[href="logout.php"],
.btn[href="logout.php"] {
    pointer-events: auto !important;
    z-index: 1000 !important;
    position: relative;
}

/* Unified Modals */
.modal-content {
    border-radius: 1rem;
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    overflow: hidden;
}

[data-bs-theme="dark"] .modal-content {
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
    background-color: rgba(0,0,0,0.015);
}

[data-bs-theme="dark"] .modal-footer {
    background-color: rgba(255,255,255,0.015);
}

.modal-body {
    padding: 1.5rem;
}

/* Animations */
.modal.fade .modal-dialog {
    transition: transform 0.2s ease-out;
    transform: scale(0.95);
}

.modal.show .modal-dialog {
    transform: scale(1);
}
