@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Outfit:wght@400;600;700;800;900&display=swap');

:root {
    /* Premium Brown Layers Palette */
    --primary: #2d241e;      /* Deep Coffee Brown */
    --accent: #8b5e34;       /* Rich Leather/Walnut */
    --accent-glow: #a67c52;  /* Golden Oak */
    --accent-soft: #fdf8f4;  /* Warm Parchment */
    
    --success: #606c38;      /* Sage Green (Complements Brown) */
    --danger: #bc4749;       /* Muted Madder Red */
    --warning: #dda15e;      /* Ochre/Sand */
    
    --bg-body: #f8f9fa;      /* Clean Default Light/White */
    --bg-card: #ffffff;
    
    --text-main: #2d241e;    /* Deep Espresso */
    --text-muted: #6b5b4b;   /* Muted Earth */
    --text-light: #a69076;   /* Soft Tan */
    
    --border: #e8dfd5;       /* Warm Clay Border */
    --border-rich: #d6bda5;
    
    --shadow-soft: 0 1px 3px 0 rgba(45, 36, 30, 0.1), 0 1px 2px 0 rgba(45, 36, 30, 0.06);
    --shadow-card: 0 10px 15px -3px rgba(45, 36, 30, 0.1), 0 4px 6px -2px rgba(45, 36, 30, 0.05);
    --shadow-bold: 0 25px 50px -12px rgba(45, 36, 30, 0.15);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    text-decoration: none;

}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 2rem;
}

/* Unified Typography - IBM Plex Sans Arabic for all primary text */
h1, h2, h3, h4, .btn-primary, .back-btn, .card-btn, button, .header-title h1 {
    font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

/* Outfit remains for purely numerical/financial values */


.container {
    max-width: 1240px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Expansion to 90% for Desktop View */
@media (min-width: 1200px) {
    .container {
        max-width: 90%;
    }
}


/* Minimalist Header */
.header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-logo {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: #fdfdfd;
}

.header-title h1 {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.header-title p {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: 'IBM Plex Sans Arabic', sans-serif;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Distinct Back Button */
.back-btn {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: var(--shadow-soft);
}

.back-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateX(-3px);
    box-shadow: var(--shadow-card);
}

.logout-btn {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fee2e2;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Page Meta Bar */
.summary-bar {
    margin: 2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.welcome-msg h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary);
}

.welcome-msg h2 span { color: var(--accent); }
.welcome-msg p { color: var(--text-muted); font-size: 0.9rem; }

.date-badge {
    background: white;
    padding: 0.5rem 0.875rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-soft);
}

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn-primary:hover { background: #000; transform: translateY(-1px); }
.btn-primary.accent { background: var(--accent); }
.btn-primary.accent:hover { background: var(--accent-glow); }

/* Chalet Grid & More Visible Cards */
.chalet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.chalet-card {
    background: #ffffff;
    border-radius: 14px;
    padding: 1.5rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: 0 4px 15px rgba(45, 36, 30, 0.05);
    border: none;
    position: relative;
    overflow: hidden;
}

.chalet-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(45, 36, 30, 0.1);
}

.chalet-id {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 4px 10px;
    border-radius: 6px;
    width: fit-content;
    letter-spacing: 0.5px;
}

.chalet-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chalet-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
    line-height: 1.3;
}

.chalet-stats {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 1.15rem;
    background: #fbfbfc;
    border-radius: 10px;
}

.mini-stat {
    flex: 1;
}

.stat-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
    margin: 0 1.25rem;
}

.mini-stat label { 
    display: flex; 
    align-items: center;
    gap: 6px;
    font-size: 0.7rem; 
    color: var(--text-light); 
    font-weight: 700; 
    margin-bottom: 6px;
}

.mini-stat label i {
    color: var(--accent);
    font-size: 0.75rem;
}

.mini-stat span { 
    font-weight: 800; 
    font-size: 1.15rem; 
    color: var(--primary); 
    display: flex;
    align-items: baseline;
    gap: 4px;

}

.mini-stat small {
    font-size: 0.75rem;
    color: var(--text-light);
}

.chalet-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.card-btn {
    flex: 1;
    background: #f8f9fa;
    color: var(--primary);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

.card-btn:hover { 
    background: var(--accent); 
    color: #ffffff; 
}

.trigger-edit {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #f1f3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border: none;
    color: var(--text-light);
}

.trigger-edit:hover {
    background: var(--accent);
    color: #ffffff;
}

/* Responsive Data Table (Detail Top) */
.data-summary-table {
    width: 100%;
    margin: 0 auto 3rem;
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}


.data-summary-table table {
    width: 100%;
    border-collapse: collapse;
}

.data-summary-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 800;
    padding: 0.75rem 1.25rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.data-summary-table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
}

.data-summary-table tr:last-child td { border: none; }

.val-bold { font-weight: 800; font-size: 1.15rem; color: var(--primary); }
.val-unit { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; margin-right: 4px; font-family: 'IBM Plex Sans Arabic', sans-serif; }

/* Responsive calendar */
.cal-container {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 2.5rem;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow-card);
}


.cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #f8fafc;
}

.cal-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f8fafc;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
}

.cal-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    align-items: center;
}

.cal-day-label {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.cal-cell {
    aspect-ratio: 4; 
    border-radius: 8px;
    background: #fdfdfd;
    border: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    transition: var(--transition);
}

@media (max-width: 1200px) {
    .cal-cell {
        aspect-ratio: 1;
    }
}


.cal-cell.today { background: var(--accent); color: white; border-color: var(--accent); }
.cal-cell.booked { background: #fee2e2; color: var(--danger); border-color: #fecaca; }

/* Responsive adjustments */
@media (max-width: 768px) {
    .summary-bar { flex-direction: column; align-items: stretch; gap: 1rem; }
    
    /* Responsive Table Stacking */
    .data-summary-table table, 
    .data-summary-table thead, 
    .data-summary-table tbody, 
    .data-summary-table th, 
    .data-summary-table td, 
    .data-summary-table tr { 
        display: block; 
    }
    
    .data-summary-table thead tr { 
        position: absolute; 
        top: -9999px; 
        left: -9999px; 
    }
    
    .data-summary-table td {
        border: none;
        border-bottom: 1px solid #f1f5f9; 
        position: relative;
        padding-right: 50% !important; 
        text-align: left;
    }
    
    .data-summary-table td:before { 
        position: absolute;
        right: 1.25rem;
        width: 45%; 
        padding-left: 10px; 
        white-space: nowrap;
        font-weight: 800;
        font-size: 0.75rem;
        color: var(--text-muted);
        content: attr(data-label);
        text-align: right;
    }

    .data-summary-table td .val-bold { text-align: left; font-size: 1rem; }
}

@media (max-width: 480px) {
    .chalet-grid { grid-template-columns: 1fr; }
    .chalet-stats { grid-template-columns: 1fr; }
    .header-logo { width: 36px; height: 36px; }
    .header-title h1 { font-size: 1rem; }
}

/* Premium Modals & Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(8px);
    display: none; /* Controlled by JS */
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1.5rem;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

.modal {
    background: white;
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-bold);
    text-align: center;
    position: relative;
    border: 1px solid var(--border);
    animation: slideUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideDown { from { transform: translateY(0); opacity: 1; } to { transform: translateY(20px); opacity: 0; } }

/* Closing State */
.overlay.closing { animation: fadeOut 0.2s ease-out forwards; }
.overlay.closing .modal { animation: slideDown 0.2s ease-in forwards; }

.modal-icon {
    width: 64px;
    height: 64px;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin: 0 auto 1.5rem;
}

.modal-icon.warning { background: #fff1f2; color: var(--danger); }

/* Danger Theme Modal Variant */
.modal.modal-danger .modal-icon { background: #fee2e2; color: var(--danger); box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1); }
.modal.modal-danger h4 { color: var(--danger); }
.modal.modal-danger .btn-confirm { background: var(--danger); }
.modal.modal-danger .btn-confirm:hover { background: #dc2626; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }

.modal h4 {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.modal p {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

.modal-btn {
    flex: 1;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-weight: 800;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
    background: white;
    color: var(--text-muted);
    font-family: inherit;
}

.modal-btn.btn-confirm {
    background: var(--primary);
    color: white;
    border: none;
}

.modal-btn.btn-confirm:hover { background: #000; }
.modal-btn.btn-cancel:hover { background: #f9fafb; border-color: var(--border-rich); }

/* Edit Input Special */
#edit-cat-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    text-align: right;
    background: #fbfbfc;
    transition: var(--transition);
}

#edit-cat-input:focus {
    outline: none;
    border-color: var(--accent);
    background: white;
    box-shadow: 0 0 0 4px var(--accent-soft);
}

/* Premium Page Loader */
.premium-loader-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background-color: var(--bg-body); display: flex; justify-content: center; align-items: center; z-index: 99999; transition: opacity 0.6s cubic-bezier(0.165, 0.84, 0.44, 1), visibility 0.6s; backdrop-filter: blur(5px); }
.premium-loader-spinner { width: 50px; height: 50px; border: 3px solid rgba(37, 99, 235, 0.1); border-radius: 50%; border-top-color: var(--accent); animation: premiumSpin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite; }
@keyframes premiumSpin { 
    0% { transform: rotate(0deg); } 
    100% { transform: rotate(360deg); } 
}
.premium-loader-container { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; }
.premium-loader-logo { width: 60px; height: 60px; border-radius: var(--radius-md); background: #fff; padding: 10px; box-shadow: var(--shadow-bold); animation: loaderPulse 2s infinite; }
@keyframes loaderPulse { 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); } 70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); } 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); } }

input, textarea, select, button { font-family: 'IBM Plex Sans Arabic', sans-serif; }
::placeholder { font-family: 'IBM Plex Sans Arabic', sans-serif; }
