:root {
    --primary: #6366F1;
    --primary-dark: #4F46E5;
    --primary-light: rgba(99, 102, 241, 0.1);
    --secondary: #10B981;
    --secondary-dark: #059669;
    --danger: #F43F5E;
    --warning: #F59E0B;
    --info: #3B82F6;
    --bg-app: #F8FAFC;
    --bg-white: #FFFFFF;
    --text-main: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --radius: 16px;
    --radius-sm: 8px;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
}

/* Custom Themes */
body.dark-mode {
    --bg-app: #0F172A;
    --bg-white: #1E293B;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --border: #334155;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    --glass: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
}

body.theme-green {
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: rgba(16, 185, 129, 0.15);
}

body.theme-purple {
    --primary: #8B5CF6;
    --primary-dark: #7C3AED;
    --primary-light: rgba(139, 92, 246, 0.15);
}

body.theme-rose {
    --primary: #F43F5E;
    --primary-dark: #E11D48;
    --primary-light: rgba(244, 63, 94, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 2rem 1rem;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3rem;
    padding: 0 1rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
    font-weight: 500;
}

.nav-links li:hover {
    background: var(--primary-light);
    color: var(--primary);
    padding-left: 1.5rem;
}

.nav-links li.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.4);
}

.nav-links li i {
    width: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.nav-links li:hover i {
    transform: scale(1.2);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-bar {
    height: 70px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    flex-shrink: 0;
}

.hamburger {
    display: none; /* Hidden on desktop */
}

.search-container {
    position: relative;
    width: 400px;
}

.search-container i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-container input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: 50px;
    background: var(--bg-app);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
}

.search-container input:focus {
    border-color: var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-info {
    text-align: right;
    display: flex;
    flex-direction: column;
}

.admin-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.admin-status {
    font-size: 0.75rem;
    color: var(--secondary);
}

.avatar {
    font-size: 2.5rem;
    color: var(--border);
}

/* View Container */
.view-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
}

.stat-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-light);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-info .stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-info .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Button UI */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

/* Table Design */
.table-container {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--bg-app);
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover {
    background: var(--hover-bg);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-active {
    background: #DCFCE7;
    color: #166534;
}

.status-paid {
    background: #E0E7FF;
    color: #3730A3;
}

.status-overdue {
    background: #FEE2E2;
    color: #991B1B;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal {
    background: var(--bg-white);
    width: 95%;
    max-width: 850px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1.5rem;
    max-height: 80vh;
    overflow-y: auto;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
}

.hidden {
    display: none;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    font-family: inherit;
    background: var(--bg-white);
    color: var(--text-main);
    transition: all 0.2s;
}

.form-group select option {
    background: var(--bg-white);
    color: var(--text-main);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Responsive */
/* Additional Premium Touches */
.card {
    border: 1px solid var(--border);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.btn {
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.btn:active {
    transform: scale(0.95);
}

.glass-morphism {
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
}

.table-container {
    border: 1px solid var(--border);
}

/* Searchable Select Premium Component */
.search-select-container {
    position: relative;
    width: 100%;
}

.search-select-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-select-input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.search-select-input {
    padding-left: 2.5rem !important;
    cursor: text;
}

.search-select-results {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 4px;
    display: none;
}

.search-select-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.search-select-item:last-child {
    border-bottom: none;
}

.search-select-item:hover {
    background: var(--primary-light);
}

.search-select-item .item-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.search-select-item .item-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

#upcoming-collections > div {
    transition: transform 0.2s ease;
}

#upcoming-collections > div:hover {
    transform: scale(1.02);
}

.loan-card-item {
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.loan-card-item:hover {
    transform: translateY(-2px);
    border-color: var(--primary) !important;
    box-shadow: var(--shadow);
}

@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
        min-height: 100vh;
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* Hamburger button */
    .hamburger {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-main);
        cursor: pointer;
        margin-right: 0.5rem;
    }

    /* Hide original sidebar, make it off‑canvas */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        background: var(--bg-white);
        flex-direction: column;
        padding: 2rem 1rem;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: 2px 0 8px rgba(0,0,0,0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .logo {
        display: flex;
    }

    .admin-info {
        display: flex;
    }

    .nav-links {
        flex-direction: column;
        gap: 0.5rem;
    }

    .nav-links span {
        display: inline;
    }

    .nav-links li {
        flex-direction: row;
        justify-content: flex-start;
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
    }

    .nav-links li i {
        margin-right: 0.5rem;
    }

    .top-bar {
        height: 55px;
        padding: 0 0.75rem;
        display: flex;
        align-items: center;
    }

    .search-container {
        flex: 1;
        max-width: none;
    }

    .user-profile {
        gap: 0.5rem;
    }

    .main-content {
        padding-bottom: 0;
    }

    .view-container {
        padding: 1rem 0.75rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
        margin-bottom: 1rem;
    }

    .stat-card {
        padding: 0.85rem;
        gap: 0.6rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .stat-info .stat-value {
        font-size: 1.1rem;
    }

    .stat-info .stat-label {
        font-size: 0.7rem;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 600px;
    }

    th, td {
        padding: 0.6rem 0.75rem;
        font-size: 0.8rem;
    }

    .modal {
        width: 98%;
        max-width: none;
        max-height: 90vh;
        margin: 0.5rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: 75vh;
    }

    .modal-header {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .btn {
        padding: 0.5rem 0.9rem;
        font-size: 0.85rem;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.7rem;
    }

    .stat-info .stat-value {
        font-size: 1rem;
    }

    .view-container {
        padding: 0.5rem;
        padding-bottom: 80px;
    }

    .top-bar {
        height: 50px;
        padding: 0 0.5rem;
    }

    .search-container input {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem 0.6rem 2.2rem;
    }
}
