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

:root {
    /* Rasn Platform Theme Colors */
    --primary: #3A6B35;
    /* Rasn Green */
    --accent: #E3B448;
    /* Rasn Gold */
    --accent-glow: #f1c40f;
    /* Brighter Gold */
    --accent-soft: #fcf8e3;
    /* Soft Gold Background */

    --success: #3A6B35;
    --danger: #bc4749;
    --warning: #dda15e;

    --bg-body: #f8f9fa;
    --bg-card: #ffffff;

    --text-main: #1a2a1a;
    /* Deep Green-Black */
    --text-muted: #4a5a4a;
    --text-light: #7a8a7a;

    --border: #e2e8e2;
    --border-rich: #ccd6cc;

    --shadow-soft: 0 1px 3px 0 rgba(58, 107, 53, 0.05), 0 1px 2px 0 rgba(58, 107, 53, 0.03);
    --shadow-card: 0 10px 15px -3px rgba(58, 107, 53, 0.1), 0 4px 6px -2px rgba(58, 107, 53, 0.05);
    --shadow-bold: 0 25px 50px -12px rgba(58, 107, 53, 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);

    /* Responsive Font Sizes */
    --fs-h1: clamp(1.5rem, 5vw, 2.25rem);
    --fs-h2: clamp(1.25rem, 4vw, 1.75rem);
    --fs-h3: clamp(1.1rem, 3vw, 1.35rem);
    --fs-body: clamp(0.9rem, 2vw, 1rem);
}

.currency-icon {
    height: 14px;
    width: auto;
    vertical-align: middle;
    display: inline-block;
    margin-right: 4px;
}

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

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

h1,
h2,
h3,
h4,
.btn-primary,
.back-btn,
.card-btn,
button,
.header-title h1 {
    font-family: 'IBM Plex Sans Arabic', 'Tajawal', sans-serif !important;
}

h1 {
    font-size: var(--fs-h1);
}

h2 {
    font-size: var(--fs-h2);
}

h3 {
    font-size: var(--fs-h3);
}

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

@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: 50px;
    height: 50px;
    border-radius: var(--radius-md);
    background: #fff;
    padding: 2px;
    border: 1px solid var(--border);
}

.header-title h1 {
    font-size: var(--fs-h3);
    font-weight: 800;
    color: #000;
    line-height: 1.2;
}

.header-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.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.75rem;
    font-weight: 800;
    color: #000;
}

.welcome-msg h2 span {
    color: #000;
}

.welcome-msg p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

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

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

.btn-primary:hover {
    background: #2d5529;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(58, 107, 53, 0.2);
}

.btn-primary.accent {
    background: var(--accent);
    color: #1a2a1a;
}

.btn-primary.accent:hover {
    background: #d4a337;
    box-shadow: 0 4px 12px rgba(227, 180, 72, 0.2);
}

/* Professional Summary Stats Grid */
.summary-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: white;
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 1px solid var(--border);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-card);
    border-color: var(--primary);
}

.stat-icon-box {
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
}

.stat-card.sales .stat-icon-box {
    background: #ecfdf5;
    color: #059669;
}

.stat-card.occupancy .stat-icon-box {
    background: #fff7ed;
    color: #c2410c;
}

.stat-card.categories .stat-icon-box {
    background: #eff6ff;
    color: #2563eb;
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stat-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #000;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stat-value span,
.stat-value small {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

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

.chalet-card {
    background: #ffffff;
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 1.25rem;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.chalet-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 25px -5px rgba(58, 107, 53, 0.08);
    transform: translateY(-4px);
}

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

.chalet-identity {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.unit-tag {
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unit-name {
    font-size: 1.2rem;
    font-weight: 800;
    color: #000;
    margin: 0;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-indicator.available {
    background: #ecfdf5;
    color: #059669;
}

.status-indicator.occupied {
    background: #fff7ed;
    color: #c2410c;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    position: relative;
}

.available .pulse-dot {
    background: #10b981;
}

.occupied .pulse-dot {
    background: #f97316;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.5);
        opacity: 0;
    }
}

.chalet-data-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
}

.summary-item {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.summary-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-light);
    font-weight: 600;
}

.summary-label i {
    color: var(--accent);
}

.summary-val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 4px;
}

.summary-val span,
.summary-val small {
    font-size: 0.75rem;
    color: var(--text-light);
}

.chalet-management-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.25rem;
}

.main-actions {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.mgmt-btn {
    width: 50%;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    border: 1px solid #e2e8f0;
    background: white;
    color: var(--text-main);
}

.mgmt-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--primary);
}

.mgmt-btn.analysis:hover {
    color: #2563eb;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.mgmt-btn.bookings:hover {
    color: #059669;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.mgmt-edit-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mgmt-edit-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
}

/* Responsive Data Table */
.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: #f8faf8;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    font-weight: 800;
    padding: 1rem 1.5rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

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

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

.val-bold {
    font-weight: 800;
    font-size: 1.35rem;
    color: var(--primary);
}

.val-unit {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    margin-right: 6px;
}

/* Overlays & Modals */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 17, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    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;
    }
}

.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 h4 {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

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

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

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

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

.modal-btn.btn-confirm:hover {
    background: #2d5529;
}

#edit-cat-input {
    width: 100%;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 1.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 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;
    backdrop-filter: blur(5px);
}

.premium-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.premium-loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(58, 107, 53, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: premiumSpin 1s linear infinite;
}

@keyframes premiumSpin {
    100% {
        transform: rotate(360deg);
    }
}

.premium-loader-overlay.loaded {
    opacity: 0;
    visibility: hidden;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .summary-bar {
        margin-bottom: 2rem;
        flex-direction: column;
        align-items: stretch;
    }

    .date-badge {
        width: 60%;
        justify-content: center;
    }

    .summary-stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 2.5rem;
    }

    .stat-card {
        padding: 1.25rem;
        border: 1.5px solid transparent;
    }

    .stat-icon-box {
        width: 52px;
        height: 52px;
        font-size: 1.4rem;
        border-radius: 12px;
        /* Keep icon box white for contrast on colored backgrounds */
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.03);
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .header-actions a span {
        display: none;
    }
    .header-actions a {
        padding: 0.5rem 0.6rem;
    }
    .header-title h1 {
        font-size: 1.1rem;
    }
    .header-logo {
        width: 40px;
        height: 40px;
    }
}

/* Global Responsive Table Style */
@media (max-width: 768px) {

    .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 tr {
        border-bottom: 1px solid var(--border);
        padding: 1rem 0;
    }

    .data-summary-table td {
        border: none;
        padding: 0.75rem 1rem;
        position: relative;
        padding-right: 50% !important;
        text-align: left !important;
    }

    .data-summary-table td::before {
        content: attr(data-label);
        position: absolute;
        right: 10px;
        width: 45%;
        white-space: nowrap;
        font-weight: 800;
        color: var(--text-muted);
        text-align: right;
        font-size: 0.85rem;
    }
}