/* ==========================================
   Design System & Variables
   ========================================== */
   :root {
    /* Main HSL Colors */
    --primary-h: 216;
    --primary-s: 90%;
    --primary-l: 55%;
    
    --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
    --primary-hover: hsl(var(--primary-h), var(--primary-s), 45%);
    --primary-light: hsl(var(--primary-h), var(--primary-s), 95%);
    
    --success: hsl(152, 70%, 45%);
    --warning: hsl(35, 90%, 55%);
    --danger: hsl(0, 75%, 55%);

    /* Light Theme */
    --bg-main: #f8faff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-sidebar: #ffffff;
    --text-main: #1a1f2c;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-sidebar: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --glass-border: rgba(255, 255, 255, 0.05);
    --primary-light: rgba(59, 130, 246, 0.15);
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* ==========================================
   Reset & Base Styles
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

ul {
    list-style: none;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    transition: all 0.2s ease;
}

/* ==========================================
   Layout
   ========================================== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-sidebar-btn {
    display: none;
    font-size: 1.2rem;
    color: var(--text-muted);
}

.nav-links {
    padding: 20px 15px;
    flex: 1;
}

.nav-links li {
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.nav-links li:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-links li.active {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    background-color: rgba(var(--bg-main), 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

#pageTitle {
    font-size: 1.25rem;
    font-weight: 600;
}

.menu-toggle {
    display: none;
    font-size: 1.25rem;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.theme-toggle {
    font-size: 1.1rem;
    color: var(--text-muted);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
}

.theme-toggle:hover {
    color: var(--primary);
    transform: translateY(-2px);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), hsl(250, 80%, 60%));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.username {
    font-weight: 500;
    font-size: 0.9rem;
}

.content-body {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    scroll-behavior: smooth;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out forwards;
}

.view-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.animate-fade { animation: fadeIn 0.4s ease-out forwards; }
.animate-slide { animation: slideInRight 0.4s ease-out forwards; }

/* ==========================================
   Dashboard Components
   ========================================== */
.dashboard-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow-glass);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.summary-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.15);
}

[data-theme="dark"] .summary-card:hover {
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.card-icon.blue { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.card-icon.green { background-color: rgba(16, 185, 129, 0.1); color: #10b981; }
.card-icon.orange { background-color: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.card-icon.red { background-color: rgba(239, 68, 68, 0.1); color: #ef4444; }

.card-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 4px;
}

.card-info p.value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Dashboard Panels Layout */
.dashboard-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .dashboard-panels {
        grid-template-columns: 1fr;
    }
}

/* ==========================================
   Panels
   ========================================== */
.panel {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
    overflow: hidden;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-body {
    padding: 24px;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.alert-item {
    padding: 16px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    font-weight: 500;
}

.alert-item.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border-left: 4px solid #f59e0b;
}

.alert-item.danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
    border-left: 4px solid #ef4444;
}

[data-theme="dark"] .alert-item.warning { color: #fcd34d; }
[data-theme="dark"] .alert-item.danger { color: #fca5a5; }

.alert-item.empty {
    background-color: var(--primary-light);
    color: var(--text-muted);
    justify-content: center;
    border: 1px dashed var(--border);
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.activity-icon.create { background-color: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.activity-icon.update { background-color: rgba(16, 185, 129, 0.1); color: #10b981; }
.activity-icon.delete { background-color: rgba(239, 68, 68, 0.1); color: #ef4444; }

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.activity-text strong {
    color: var(--primary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.activity-item.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
    justify-content: center;
}

/* ==========================================
   Tables & Forms
   ========================================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

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

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-box input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-group {
    display: flex;
    gap: 10px;
}

.filter-group select {
    padding: 10px 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-main);
    outline: none;
    cursor: pointer;
}

.filter-group select:focus {
    border-color: var(--primary);
}

.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.primary-btn {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.secondary-btn {
    background-color: var(--bg-sidebar);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.secondary-btn:hover {
    background-color: var(--border);
}

.table-container {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

.data-table th, .data-table td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background-color: rgba(var(--bg-main), 0.5);
}

.data-table tbody tr {
    transition: background-color 0.2s;
}

.data-table tbody tr:hover {
    background-color: var(--primary-light);
    transform: scale(1.002);
    box-shadow: var(--shadow-sm);
    z-index: 1;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-available { background-color: rgba(16, 185, 129, 0.15); color: #059669; }
.status-loaned { background-color: rgba(245, 158, 11, 0.15); color: #d97706; }
.status-calibration { background-color: rgba(239, 68, 68, 0.15); color: #b91c1c; }

[data-theme="dark"] .status-available { color: #34d399; }
[data-theme="dark"] .status-loaned { color: #fbbf24; }
[data-theme="dark"] .status-calibration { color: #f87171; }

.action-btn {
    color: var(--primary);
    font-size: 1.1rem;
    padding: 5px;
}

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

/* ==========================================
   Modals
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.modal {
    background: var(--bg-sidebar);
    width: 90%;
    max-width: 500px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.2rem;
}

.close-modal {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.close-modal:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-main);
    font-size: 0.9rem;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-main);
    color: var(--text-main);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
}

/* ==========================================
   Responsive Logic (Smartphone focus)
   ========================================== */
/* --- Confirm Modal Specific --- */
.confirm-modal .modal-body {
    text-align: center;
    padding: 30px 24px;
}

.confirm-modal #confirmMessage {
    font-size: 1.05rem;
    font-weight: 500;
    COLOR: var(--text-main);
}

.confirm-modal .form-actions {
    margin-top: 40px;
    justify-content: center;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: 5px 0 25px rgba(0,0,0,0.1);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .close-sidebar-btn {
        display: block;
    }

    .menu-toggle {
        display: block;
    }

    .header-title h1 {
        font-size: 1.1rem;
    }

    .username {
        display: none; /* Hide username on mobile to save space */
    }

    .content-body {
        padding: 15px;
    }

    .dashboard-summary {
        grid-template-columns: 1fr 1fr;
    }
    
    .search-box {
        width: 100%;
    }
    
    .toolbar button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .dashboard-summary {
        grid-template-columns: 1fr;
    }
}
