:root {
    --primary: #9B7B67;
    --primary-dark: #7A5F4E;
    --secondary: #D8C7AF;
    --background: #F4EFE6;
    --surface: #FFFFFF;
    --text-primary: #1E1B18;
    --text-secondary: #4B3A2F;
    --danger: #D9534F;
    --success: #5CB85C;
    --border: rgba(155, 123, 103, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    padding-bottom: 70px; /* Space for Bottom Nav */
    overflow-x: hidden; /* Prevent horizontal scroll */
}

/* Base Layout (Mobile First) */
.container {
    width: 100%;
    padding: 15px;
}

.grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Navbar (Top) */
.navbar {
    background: var(--surface);
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 100;
}
.navbar-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

/* Bottom Navigation (Mobile First) */
.sidebar-card {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--surface);
    box-shadow: 0 -4px 15px rgba(0,0,0,0.08);
    z-index: 999;
    padding: 8px 5px;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}
.sidebar-ul {
    list-style: none;
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
}
.sidebar-ul li {
    flex: 1;
    text-align: center;
}
.sidebar-ul li button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 700;
    gap: 4px;
    padding: 8px 0;
}
.sidebar-ul li button i {
    font-size: 1.4rem;
}
.sidebar-ul li button.active {
    color: var(--primary);
}

/* Cards */
.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    border: 1px solid var(--border);
    width: 100%;
}

/* Stats Cards */
.stat-card {
    background: var(--surface);
    padding: 20px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid var(--border);
    border-top: 5px solid var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.stat-card h3 {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 5px;
}
.stat-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Buttons */
.btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}
.btn-primary { background: var(--primary); color: white; box-shadow: 0 4px 10px rgba(155, 123, 103, 0.3); }
.btn-primary:active { transform: scale(0.98); }
.btn-secondary { background: var(--secondary); color: var(--text-secondary); }
.btn-outline { background: transparent; border: 1px solid var(--primary); color: var(--primary); padding: 8px 15px; font-size: 0.9rem;}

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 0.95rem;
}
input, select, textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #FAFAFA;
    color: var(--text-primary);
    font-size: 16px !important; /* Force prevent zoom */
    font-weight: 600;
    transition: border-color 0.3s;
    appearance: none; /* Clean select on mobile */
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--surface);
}

/* Card-style Lists (Mobile First Tables) */
.table-responsive {
    width: 100%;
}
.table-responsive table {
    width: 100%;
    border-collapse: collapse;
}
.table-responsive thead {
    display: none; /* Hide standard headers on mobile */
}
.table-responsive tr {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 15px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}
.table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
    font-size: 0.95rem;
}
.table-responsive td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 10px;
}
.table-responsive td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-secondary);
    margin-left: 15px;
}

/* Badges */
.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; }
.badge-confirmed { background: var(--success); color: white; }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex; justify-content: center; align-items: flex-end; /* Bottom sheet on mobile */
    z-index: 2000;
}
.modal-content {
    background: var(--surface);
    padding: 25px 20px;
    border-radius: 24px 24px 0 0;
    width: 100%; 
    max-height: 90vh; 
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.close-btn { background: var(--background); border: none; font-size: 1.2rem; cursor: pointer; color: var(--danger); width: 36px; height: 36px; border-radius: 50%; display: flex; justify-content: center; align-items: center; }

/* Calendar */
.calendar-wrapper { margin-top: 15px; }
.calendar-controls { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.calendar-header { text-align: center; font-weight: 700; padding: 10px 0; font-size: 0.85rem; color: var(--text-secondary); }
.calendar-day { 
    min-height: 80px; 
    border: 1px solid var(--border); 
    border-radius: 10px; 
    padding: 4px; 
    background: #FAFAFA; 
    display: flex; flex-direction: column; 
}
.calendar-day.empty { background: transparent; border: none; }
.calendar-day-number { font-weight: 700; margin-bottom: 5px; font-size: 0.9rem; }
.res-badge { 
    font-size: 0.7rem; 
    padding: 4px; 
    border-radius: 6px; 
    margin-bottom: 3px; 
    color: white; 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    font-weight: 600;
}
.res-mabeet { background-color: #5CB85C; }
.res-sabahi { background-color: #F0AD4E; }
.res-sahra { background-color: #5BC0DE; }

/* Helpers */
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.mb-2 { margin-bottom: 15px; }
.mt-2 { margin-top: 15px; }
.text-center { text-align: center; }

/* Action Buttons for tables */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

/* Login Page Styling */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: url('bg.jpg') center/cover no-repeat;
}
.login-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}
.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 2;
    position: relative;
}
.login-logo {
    max-width: 150px;
    height: auto;
    border-radius: 12px;
    margin-bottom: 25px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

/* =======================================
   Desktop Overrides (min-width: 768px)
   ======================================= */
@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }
    .container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 30px 20px;
    }
    .grid {
        display: grid;
    }
    .grid-2 { grid-template-columns: 1fr 1fr; gap: 20px; }
    .grid-3 { grid-template-columns: repeat(3, 1fr); gap: 20px; }
    .main-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 30px;
        align-items: start;
    }
    
    /* Restore Sidebar */
    .sidebar-card {
        position: sticky;
        top: 90px;
        border-radius: 20px;
        padding: 20px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.03);
        border: 1px solid var(--border);
    }
    .sidebar-ul {
        flex-direction: column;
        gap: 15px;
    }
    .sidebar-ul li button {
        flex-direction: row;
        justify-content: flex-start;
        padding: 12px 20px;
        font-size: 1.05rem;
        border-radius: 12px;
        background: var(--background);
    }
    .sidebar-ul li button.active {
        background: var(--primary);
        color: white;
    }
    
    /* Modals Center on Desktop */
    .modal-overlay {
        align-items: center;
    }
    .modal-content {
        border-radius: 24px;
        max-width: 650px;
        animation: scaleIn 0.3s ease-out;
    }
    @keyframes scaleIn {
        from { transform: scale(0.9); opacity: 0; }
        to { transform: scale(1); opacity: 1; }
    }
    
    /* Restore Standard Tables */
    .table-responsive tr {
        display: table-row;
        background: transparent;
        border: none;
        box-shadow: none;
    }
    .table-responsive thead {
        display: table-header-group;
    }
    .table-responsive td, .table-responsive th {
        display: table-cell;
        padding: 15px;
        border-bottom: 1px solid var(--border);
        text-align: right;
    }
    .table-responsive td::before {
        display: none;
    }
}
