:root { 
    --primary: #2c3e50; 
    --primary-dark: #1a252f; 
    --accent: #e74c3c; 
    --background: #f4f7f6; 
    --text: #333; 
    --text-light: #7f8c8d; 
    --shadow: 0 4px 6px rgba(0,0,0,0.1); 
    --radius: 8px; 
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: 'Roboto', sans-serif; 
    background-color: var(--background); 
    color: var(--text); 
    line-height: 1.6; 
    padding-bottom: 30px; 
    position: relative; 
    min-height: 100vh;
}

.hidden { display: none !important; }

/* --- HEADER & SIDEBAR --- */
header { 
    background-color: var(--primary); 
    color: white; 
    padding: 15px; 
    display: flex; 
    align-items: center; 
    position: sticky; 
    top: 0; 
    z-index: 100; 
    box-shadow: var(--shadow); 
}
.menu-btn { background: transparent; border: none; cursor: pointer; margin-right: 15px; padding: 5px; display: flex; align-items: center; justify-content: center; }
.menu-btn svg { width: 32px; height: 32px; fill: white; }
.back-btn { color: white; text-decoration: none; font-size: 1.5rem; margin-right: 15px; font-weight: bold; }
.header-logo { height: 40px; margin-right: 10px; }
.header-title { font-size: 1.2rem; font-weight: 500; white-space: nowrap; }

.sidebar { 
    position: fixed; 
    top: 0; 
    left: -280px; 
    width: 280px; 
    height: 100%; 
    background-color: white; 
    box-shadow: 2px 0 15px rgba(0,0,0,0.3); 
    transition: left 0.3s ease; 
    z-index: 1002; 
    display: flex; 
    flex-direction: column; 
    overflow-y: auto; 
    padding-bottom: 20px; 
}

.sidebar.open { left: 0; }
.sidebar-header { background-color: var(--primary); color: white; padding: 25px 20px; font-size: 1.3rem; font-weight: bold; display: flex; align-items: center; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.sidebar-link { padding: 18px 20px; text-decoration: none; color: var(--text); font-size: 1.1rem; border-bottom: 1px solid #eee; display: flex; align-items: center; gap: 15px; transition: all 0.2s ease; }
.sidebar-link:hover, .sidebar-link.active { background-color: rgba(244, 247, 246, 0.8); color: var(--primary); font-weight: 600; border-left: 5px solid var(--primary); padding-left: 15px; }
.sidebar-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1001; display: none; backdrop-filter: blur(2px); }
.sidebar-overlay.open { display: block; }

/* --- CONTAINERS & FORMS --- */
.container { max-width: 600px; margin: 20px auto; padding: 0 15px; }

.form-section { 
    background: white; 
    padding: 20px; 
    border-radius: var(--radius); 
    border: 1px solid rgba(44, 62, 80, 0.15);
    box-shadow: var(--shadow); 
    margin-bottom: 20px; 
}
.form-section h2 { font-size: 1.2rem; color: var(--primary); margin-bottom: 15px; border-bottom: 2px solid rgba(0,0,0,0.05); padding-bottom: 5px; }

.form-group { margin-bottom: 15px; }
label { display: block; font-weight: 500; margin-bottom: 5px; color: var(--primary); font-size: 0.95rem; }
input[type="text"], input[type="date"], input[type="datetime-local"], input[type="number"], input[type="password"], select, textarea { 
    width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 1rem; font-family: inherit; box-sizing: border-box;
}
textarea { resize: vertical; height: 100px; }

.checkbox-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.checkbox-grid.two-col { grid-template-columns: repeat(2, 1fr); }
.check-item { display: flex; align-items: flex-start; background: #f9f9f9; padding: 10px; border-radius: 4px; border: 1px solid #eee; flex-wrap: wrap; }
.check-item input { margin-right: 10px; margin-top: 4px; width: 18px; height: 18px; flex-shrink: 0; }
.check-item label { margin-bottom: 0; font-weight: normal; font-size: 0.90rem; color: var(--text); }

/* --- BUTTONS --- */
.btn { display: block; width: 100%; padding: 15px; border: none; border-radius: var(--radius); font-size: 1.1rem; font-weight: 700; text-align: center; cursor: pointer; text-transform: uppercase; text-decoration: none; box-sizing: border-box;}
.btn-submit { background-color: #2ecc71; color: white; box-shadow: 0 4px 6px rgba(46, 204, 113, 0.3);}
.btn-secondary { background-color: #3498db; color: white; padding: 10px; font-size: 1rem; box-shadow: 0 4px 6px rgba(52, 152, 219, 0.3);}
.btn-outline { background-color: transparent; border: 2px dashed #3498db; color: #3498db; font-size: 0.9rem; padding: 10px; margin-top: 5px; text-transform: none;}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Subtle Action Buttons for Admin Table */
.action-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-subtle { background: transparent; border: 1px solid #ddd; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 0.85rem; font-weight: 500; transition: all 0.2s; white-space: nowrap;}
.btn-subtle.view { color: #3498db; border-color: #3498db; }
.btn-subtle.view:hover { background: #3498db; color: white; }
.btn-subtle.approve { color: #2ecc71; border-color: #2ecc71; }
.btn-subtle.approve:hover { background: #2ecc71; color: white; }
.btn-subtle.delete { color: #e74c3c; border-color: #e74c3c; }
.btn-subtle.delete:hover { background: #e74c3c; color: white; }
.btn-subtle.edit { color: #f39c12; border-color: #f39c12; }
.btn-subtle.edit:hover { background: #f39c12; color: white; }

/* --- MODALS --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; display: flex; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box;}
.modal-content { background: white; width: 100%; max-width: 500px; max-height: 90vh; border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.modal-header { padding: 15px 20px; background: var(--primary); color: white; font-weight: bold; font-size: 1.2rem; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;}
.close-btn { background: transparent; border: none; color: white; font-size: 1.5rem; cursor: pointer; margin-top: -5px; }
.modal-body { padding: 20px; font-size: 1.05rem; color: #333; overflow-y: auto; flex-grow: 1;}

/* --- AUTOCOMPLETE --- */
.autocomplete-wrapper { position: relative; width: 100%; }
.autocomplete-items { position: absolute; border: 1px solid #ddd; border-bottom: none; border-top: none; z-index: 99; top: 100%; left: 0; right: 0; background-color: #fff; border-radius: 0 0 4px 4px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); max-height: 250px; overflow-y: auto;}
.autocomplete-items div { padding: 12px; cursor: pointer; border-bottom: 1px solid #ddd; font-size: 0.9rem; }
.autocomplete-items div:hover { background-color: #f4f7f6; color: var(--primary); font-weight: 500;}

/* --- UTILITIES & ENHANCEMENTS --- */
.loading-text { text-align: center; color: var(--text-light); margin-top: 20px; }

.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* --- TOAST NOTIFICATIONS --- */
.toast {
    visibility: hidden;
    min-width: 280px;
    margin-left: -140px;
    background-color: #333;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 16px;
    position: fixed;
    z-index: 3000;
    left: 50%;
    bottom: 30px;
    font-size: 1rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    opacity: 0;
    transition: opacity 0.3s, bottom 0.3s, visibility 0.3s;
}

.toast.show {
    visibility: visible;
    opacity: 1;
    bottom: 50px;
}

.toast-success { background-color: #2ecc71; }
.toast-error { background-color: #e74c3c; }
.toast-info { background-color: #3498db; }

/* Mobile Sidebar & Global Fixes */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        position: fixed;
        z-index: 1000;
        width: 250px;
        top: 0;
        left: 0;
        height: 100%; 
        height: 100dvh; /* Dynamic viewport height to prevent browser bar overlap */
        overflow-y: auto;
        background: white;
        padding-bottom: 50px; /* Forces spacing so the bottom links can't get trapped below the fold */
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    }
    body.dark-mode .sidebar {
        background: #1e1e1e;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-overlay.open {
        display: block;
    }
    .hidden {
        display: none !important;
    }
}