/**
 * DELUX / Wepesi hotel — responsive layout for phone, tablet, and desktop.
 */

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Remove mistaken 220px body gutters on standalone pages (no sidebars) */
body:not(.accounting-layout-body) {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

body.hotel-page {
    padding: clamp(0.5rem, 2vw, 1.25rem);
    min-height: 100vh;
}

/* Nested pages that also squeezed content */
body:not(.accounting-layout-body) .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100%;
}

img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
}

/* Fluid containers */
.container-fluid {
    padding-left: clamp(0.5rem, 2vw, 1rem);
    padding-right: clamp(0.5rem, 2vw, 1rem);
}

/* Tables: horizontal scroll on small screens */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
}

.table-responsive > .table {
    min-width: 640px;
}

.table-responsive.table-responsive-cards {
    min-width: 0;
}

/* Modals: use full width on phones */
@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-dialog.modal-lg,
    .modal-dialog.modal-xl {
        max-width: calc(100% - 1rem);
    }

    .modal-fullscreen-sm-down {
        width: 100vw;
        max-width: none;
        margin: 0;
    }
}

/* Scrollable tab bars */
.nav-tabs,
.card-header-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    border-bottom-width: 1px;
}

.nav-tabs .nav-link,
.card-header-tabs .nav-link {
    white-space: nowrap;
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
    padding: 0.5rem 0.75rem;
}

/* Page headers stack on narrow screens */
.page-header-stack,
.fd-page-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: 0.75rem;
}

.page-header-stack .btn-group-mobile,
.fd-page-header .header-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.page-header-stack .btn,
.fd-page-header .btn,
.page-header-stack a.btn,
.fd-page-header a.btn {
    width: 100%;
    justify-content: center;
}

/* Touch-friendly controls */
@media (max-width: 767.98px) {
    .btn {
        min-height: 44px;
    }

    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    .stats-number {
        font-size: clamp(1.5rem, 6vw, 2.5rem) !important;
    }

    .kpi-value {
        font-size: clamp(1.35rem, 5vw, 2rem) !important;
    }

    .card-header {
        padding: 12px 14px;
    }

    .search-filter-container {
        padding: 12px;
    }

    .room-image-wrapper,
    .image-fallback-container {
        height: 160px !important;
    }

    .dashboard-card:hover {
        transform: none;
    }
}

/* KPI progress bar (reports) — keep above decorative ::after */
.kpi-card .kpi-body,
.kpi-card .mt-3 {
    position: relative;
    z-index: 2;
}

.kpi-card .progress {
    position: relative;
    z-index: 2;
    height: 8px;
}

/* Room card action footer */
.room-card .card-footer .d-grid,
.room-card .card-footer .d-flex {
    flex-wrap: wrap;
}

@media (max-width: 575.98px) {
    .room-card .card-footer .btn {
        flex: 1 1 100%;
    }
}

/* App layout sidebar (layouts/app.blade.php) */
@media (max-width: 767.98px) {
    #app .sidebar {
        margin-bottom: 1rem;
        border-radius: 12px;
        min-height: auto !important;
    }

    #app main.col-md-9 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* ——— Accounting layout: off-canvas sidebar ——— */
.accounting-layout-body .sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1100;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary-green, #1a936f), var(--secondary-green, #88d498));
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    font-size: 1.25rem;
}

.accounting-layout-body .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
}

@media (max-width: 991.98px) {
    .accounting-layout-body .sidebar {
        transform: translateX(-100%);
        transition: transform 0.28s ease;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .accounting-layout-body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .accounting-layout-body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    .accounting-layout-body .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .accounting-layout-body .main-content {
        margin-left: 0 !important;
        padding: 12px !important;
    }

    .accounting-layout-body .top-bar {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
        padding: 12px 14px;
    }

    .accounting-layout-body .page-title {
        font-size: 1.15rem;
    }
}

/* Dashboard module strip */
@media (max-width: 576px) {
    .modules-scroll,
    .module-grid {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    body.hotel-page,
    .accounting-layout-body .main-content {
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
    }

    .accounting-layout-body .sidebar-toggle {
        bottom: max(1rem, env(safe-area-inset-bottom));
        right: max(1rem, env(safe-area-inset-right));
    }
}

/* Dark mode (Settings → Appearance, or dashboard toggle) */
body.theme-dark {
    background-color: #121826 !important;
    color: #e8edf5 !important;
}

body.theme-dark .navbar,
body.theme-dark .top-bar,
body.theme-dark .card,
body.theme-dark .stats-card,
body.theme-dark .report-container,
body.theme-dark .accounting-card,
body.theme-dark .guide-card,
body.theme-dark .dropdown-menu,
body.theme-dark .modal-content,
body.theme-dark .table-container,
body.theme-dark .welcome-section,
body.theme-dark .quick-actions,
body.theme-dark .sync-section {
    background-color: #1b2433 !important;
    color: #e8edf5 !important;
    border-color: #2f3b52 !important;
}

body.theme-dark .nav-link,
body.theme-dark .text-muted,
body.theme-dark .form-text,
body.theme-dark .page-subtitle,
body.theme-dark small {
    color: #b8c4d9 !important;
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea {
    background-color: #111827 !important;
    color: #f3f4f6 !important;
    border-color: #374151 !important;
}

body.theme-dark .table,
body.theme-dark table {
    color: #e8edf5;
}

body.theme-dark .table thead th,
body.theme-dark table thead th {
    background-color: #243044 !important;
    color: #f3f4f6 !important;
    border-color: #374151 !important;
}

body.theme-dark .table td,
body.theme-dark .table th,
body.theme-dark table td,
body.theme-dark table th {
    border-color: #2f3b52 !important;
}

body.theme-dark .btn-outline-secondary,
body.theme-dark .btn-outline-primary,
body.theme-dark .btn-light {
    color: #e8edf5 !important;
    border-color: #4b5563 !important;
}

body.theme-dark .summary-card,
body.theme-dark .stat-card {
    box-shadow: none !important;
}
