/* assets/css/style.css */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #059669;
    --warning-color: #d97706;
    --danger-color: #dc2626;
    --info-color: #0891b2;
    --bg-color: #f1f5f9;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 60px;
    --header-height: 60px;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* 1. LAYOUT & SIDEBAR */
.wrapper {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

#sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: all 0.3s;
    height: 100vh;
    position: fixed;
    z-index: 1040;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

#sidebar .sidebar-header {
    padding: 20px;
    background: rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar .sidebar-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    white-space: nowrap;
}

#sidebar ul.components {
    padding: 20px 0;
    flex: 1;
}

#sidebar ul li {
    padding: 5px 15px;
}

#sidebar ul li a {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    color: var(--sidebar-text);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
    gap: 12px;
}

#sidebar ul li a:hover,
#sidebar ul li.active > a {
    background: var(--primary-color);
    color: #fff;
}

#sidebar ul li a i {
    width: 20px;
    text-align: center;
}

.submenu-icon {
    margin-left: auto;
    transition: transform 0.3s;
}

#sidebar ul li a[aria-expanded="true"] .submenu-icon {
    transform: rotate(90deg);
}

#sidebar ul ul a {
    padding-left: 45px;
    font-size: 0.9em;
}

#sidebar .user-info {
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Collapsed Sidebar */
#sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

#sidebar.collapsed .sidebar-header h3,
#sidebar.collapsed ul li a span,
#sidebar.collapsed .submenu-icon,
#sidebar.collapsed .user-info-text {
    display: none;
}

#sidebar.collapsed ul li a {
    justify-content: center;
    padding: 10px;
}

#sidebar.collapsed ul li a i {
    margin: 0;
}

#sidebar.collapsed ul ul {
    display: none !important;
}

/* Main Content */
#content {
    width: calc(100% - var(--sidebar-width));
    margin-left: var(--sidebar-width);
    transition: all 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#content.expanded {
    width: calc(100% - var(--sidebar-collapsed-width));
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Navbar */
.top-navbar {
    height: var(--header-height);
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 5px;
}

.content-padding {
    padding: 20px;
    flex: 1;
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

/* 3. DASHBOARD */
.stat-card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.stat-card.success { border-left-color: var(--success-color); }
.stat-card.warning { border-left-color: var(--warning-color); }
.stat-card.danger { border-left-color: var(--danger-color); }
.stat-card.info { border-left-color: var(--info-color); }

.stat-icon {
    font-size: 2.5rem;
    color: rgba(0,0,0,0.1);
}

/* 4. DATA TABLES */
.table-responsive {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 15px;
}

.table th {
    background-color: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
}

.table tbody tr:hover {
    background-color: #f1f5f9;
}

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

/* 5. FORMS */
.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.25rem rgba(37, 99, 235, 0.25);
}

.required::after {
    content: " *";
    color: var(--danger-color);
}

.is-invalid {
    border-color: var(--danger-color);
}
.is-valid {
    border-color: var(--success-color);
}

.form-section-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

/* 6. CARDS */
.card {
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border-radius: 8px;
    margin-bottom: 20px;
}
.card-header {
    background-color: #fff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    border-top-left-radius: 8px !important;
    border-top-right-radius: 8px !important;
}

/* 7. MODALS */
.modal-backdrop {
    backdrop-filter: blur(3px);
}
.modal-content {
    border: none;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* 9. STATUS BADGES */
.badge {
    padding: 0.4em 0.8em;
    border-radius: 4px;
    font-weight: 500;
}
.badge-booked, .badge-info { background-color: var(--info-color); color: #fff; }
.badge-confirmed, .badge-success { background-color: var(--success-color); color: #fff; }
.badge-waiting, .badge-warning { background-color: var(--warning-color); color: #fff; }
.badge-in-consultation { background-color: var(--primary-color); color: #fff; }
.badge-completed { background-color: var(--secondary-color); color: #fff; }
.badge-cancelled, .badge-danger, .badge-no-show { background-color: var(--danger-color); color: #fff; }
.badge-paid { background-color: var(--success-color); color: #fff; }
.badge-partial { background-color: var(--warning-color); color: #fff; }
.badge-unpaid { background-color: var(--danger-color); color: #fff; }
.badge-in-stock { background-color: var(--success-color); color: #fff; }
.badge-low-stock { background-color: var(--warning-color); color: #fff; }
.badge-out-of-stock { background-color: var(--danger-color); color: #fff; }
.badge-near-expiry { background-color: var(--warning-color); color: #fff; }
.badge-expired { background-color: var(--danger-color); color: #fff; }

/* 10. TOAST NOTIFICATIONS */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1060;
}

/* 11. SEARCH */
.search-wrapper {
    position: relative;
}
.search-wrapper i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}
.search-wrapper input {
    padding-left: 35px;
}
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    display: none;
}
.autocomplete-item {
    padding: 10px;
    cursor: pointer;
}
.autocomplete-item:hover, .autocomplete-item.active {
    background-color: var(--bg-color);
}

/* 12. PRINT */
@media print {
    body { background: #fff; }
    #sidebar, .top-navbar, .btn, .sidebar-overlay, .toast-container, .no-print { display: none !important; }
    #content { margin: 0 !important; width: 100% !important; padding: 0 !important; }
    .card { box-shadow: none; border: none; }
    .table-responsive { box-shadow: none; padding: 0; }
    .print-only { display: block !important; }
    @page { size: A4; margin: 20mm; }
}
.print-only { display: none; }

/* 13. LOADING */
.page-loader {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 100% { transform: rotate(360deg); } }

/* 14. EMPTY STATES */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #cbd5e1;
}

/* 16. RESPONSIVE */
@media (max-width: 768px) {
    #sidebar {
        transform: translateX(-100%);
    }
    #sidebar.show {
        transform: translateX(0);
    }
    #content, #content.expanded {
        width: 100%;
        margin-left: 0;
    }
    .sidebar-overlay.show {
        display: block;
    }
    .top-navbar {
        padding: 0 10px;
    }
    .stat-card {
        margin-bottom: 15px;
    }
}

/* Login Page specific */
.login-page {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--info-color) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
    padding: 30px;
}
.login-logo {
    text-align: center;
    margin-bottom: 30px;
}
.login-logo i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}
.login-logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}
