/* ═══════════════════════════════════════════
   Mobile-first responsive — کل سایت
   ═══════════════════════════════════════════ */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

/* Safe areas (notch / home indicator) */
@supports (padding: env(safe-area-inset-bottom)) {
    .mobile-bottom-nav {
        padding-bottom: calc(0.35rem + env(safe-area-inset-bottom));
    }
    .live-chat-fab {
        bottom: calc(24px + env(safe-area-inset-bottom));
    }
    body.has-bottom-nav .live-chat-fab {
        bottom: calc(78px + env(safe-area-inset-bottom));
    }
    .pwa-install-banner {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    body.has-bottom-nav .pwa-install-banner {
        bottom: calc(62px + env(safe-area-inset-bottom));
    }
}

/* Prevent iOS zoom on focus */
@media (max-width: 991.98px) {
    input.form-control,
    select.form-select,
    textarea.form-control,
    .form-control,
    .form-select {
        font-size: 16px !important;
    }
}

/* Touch-friendly controls */
@media (max-width: 991.98px) {
    .btn {
        min-height: 44px;
        padding-top: 0.55rem;
        padding-bottom: 0.55rem;
    }
    .btn-sm {
        min-height: 36px;
        padding-top: 0.35rem;
        padding-bottom: 0.35rem;
    }
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    .navbar .nav-link {
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }
}

/* ── Tables: always scrollable on small screens ── */
@media (max-width: 991.98px) {
    .table-responsive,
    .card > .table,
    .card .table:not(.table-responsive .table) {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .building-content .table,
    .panel-content .table {
        min-width: 520px;
    }
    .table td,
    .table th {
        white-space: nowrap;
    }
    .table td.text-wrap,
    .table th.text-wrap {
        white-space: normal;
    }
}

/* ── Layout & spacing ── */
@media (max-width: 991.98px) {
    .building-layout {
        display: block;
        min-height: auto;
    }
    .building-sidebar {
        display: none !important;
    }
    .building-content {
        padding: 0.85rem 0.85rem 1.25rem;
        width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-bottom: 1rem;
    }
    .page-header h4 {
        font-size: 1.15rem;
        line-height: 1.4;
    }
    .page-header .btn {
        width: 100%;
    }

    .stat-card {
        padding: 0.9rem;
        gap: 0.7rem;
    }
    .stat-card .stat-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
        border-radius: 10px;
    }
    .stat-card .stat-value {
        font-size: 1.15rem;
    }
    .stat-card .stat-label {
        font-size: 0.72rem;
    }

    main.mt-3 {
        margin-top: 0.5rem !important;
    }

    .container-fluid.px-3 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .card-body {
        padding: 0.9rem;
    }

    .empty-state {
        padding: 2rem 0.75rem;
    }
    .empty-state i {
        font-size: 2.25rem;
    }
}

@media (max-width: 575.98px) {
    .building-content {
        padding: 0.7rem 0.65rem 1rem;
    }
    .row.g-3,
    .row.g-4 {
        --bs-gutter-x: 0.65rem;
        --bs-gutter-y: 0.65rem;
    }
}

/* ── Navbar mobile ── */
@media (max-width: 991.98px) {
    .navbar {
        padding-top: 0.4rem;
        padding-bottom: 0.4rem;
    }
    .navbar-brand--logo .site-logo--nav {
        height: 32px;
    }
    .navbar-brand-text {
        font-size: 0.85rem;
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .navbar-collapse {
        background: rgba(0, 0, 0, 0.12);
        margin: 0.5rem -0.75rem -0.4rem;
        padding: 0.5rem 0.85rem 0.75rem;
        border-radius: 0 0 12px 12px;
        max-height: min(70vh, 480px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    .navbar-nav .dropdown-menu {
        border: none;
        background: rgba(255, 255, 255, 0.08);
        padding: 0.25rem 0;
    }
    .navbar-nav .dropdown-item {
        color: rgba(255, 255, 255, 0.9);
        padding: 0.65rem 1rem;
    }
    .navbar-nav .dropdown-item:hover,
    .navbar-nav .dropdown-item:focus {
        background: rgba(255, 255, 255, 0.12);
        color: #fff;
    }
    .navbar-nav .dropdown-divider {
        border-color: rgba(255, 255, 255, 0.15);
    }
}

/* When bottom nav exists, simplify top nav on phone */
@media (max-width: 991.98px) {
    body:has(.mobile-bottom-nav) .navbar .navbar-nav.me-auto {
        /* keep but tighter */
    }
}

/* ── Bottom navigation ── */
.mobile-bottom-nav {
    height: auto;
    min-height: 58px;
}
.mobile-bottom-nav .bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    max-width: 88px;
    padding: 0.35rem 0.15rem;
    gap: 2px;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.15;
    -webkit-user-select: none;
    user-select: none;
}
.mobile-bottom-nav .bottom-nav-item span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-bottom-nav .bottom-nav-item i {
    font-size: 1.28rem;
    margin-bottom: 0;
    line-height: 1;
}

.has-bottom-nav {
    padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}
.has-bottom-nav + footer {
    margin-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
}

@media (max-width: 380px) {
    .mobile-bottom-nav .bottom-nav-item {
        font-size: 0.55rem;
        padding-left: 0.05rem;
        padding-right: 0.05rem;
    }
    .mobile-bottom-nav .bottom-nav-item i {
        font-size: 1.15rem;
    }
}

/* ── Auth pages ── */
@media (max-width: 575.98px) {
    .auth-wrapper {
        align-items: flex-start;
        padding: 1rem 0.75rem 2rem;
        min-height: 100dvh;
    }
    .auth-card {
        padding: 1.5rem 1.15rem;
        border-radius: 14px;
        max-width: 100%;
        box-shadow: 0 6px 24px rgba(37, 99, 235, 0.1);
    }
    .auth-card .site-logo--auth {
        height: 72px;
    }
}

/* ── Panel (superadmin / support) ── */
.panel-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .panel-sidebar {
        width: min(280px, 86vw);
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
    }
    .panel-sidebar.open + .panel-sidebar-backdrop,
    body.panel-sidebar-open .panel-sidebar-backdrop {
        display: block;
    }
    .panel-topbar {
        padding: 0.65rem 0.85rem;
        gap: 0.5rem;
    }
    .panel-topbar h6 {
        font-size: 0.9rem;
        line-height: 1.3;
        max-width: 50vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .panel-content {
        padding: 1rem 0.85rem 1.5rem !important;
    }
    .panel-main > .px-4 {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }
    .panel-stat {
        padding: 1rem !important;
    }
    .panel-stat .ps-val {
        font-size: 1.3rem !important;
    }
    .panel-stat .ps-icon {
        width: 42px !important;
        height: 42px !important;
        font-size: 1.15rem !important;
    }
}

/* ── Live chat widget mobile (fullscreen — see live-chat-widget.css) ── */
@media (max-width: 575.98px) {
    .live-chat-fab {
        width: 52px;
        height: 52px;
        left: 14px;
        font-size: 1.35rem;
    }
    body.has-bottom-nav .live-chat-fab {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        left: 12px;
    }
}

/* ── Home marketing mobile ── */
@media (max-width: 767.98px) {
    .home-topbar-inner {
        min-height: 56px;
    }
    .home-topbar-brand .site-logo--nav {
        height: 34px;
    }
    .home-hero {
        min-height: calc(100dvh - 56px);
        padding: 2rem 0 3.5rem;
    }
    .home-hero .site-logo--hero {
        height: clamp(132px, 42vw, 190px);
        border-radius: 18px;
    }
    .home-hero-title {
        max-width: none;
        font-size: clamp(1.45rem, 6.5vw, 1.9rem);
    }
    .home-hero-lead {
        font-size: 0.95rem;
        padding: 0 0.25rem;
        margin-bottom: 1.5rem;
    }
    .home-hero-actions {
        flex-direction: column;
        align-items: stretch;
        padding: 0 0.5rem;
    }
    .home-hero-actions .home-btn {
        width: 100%;
    }
    .home-section {
        padding: 3rem 0;
    }
    .home-section-head {
        margin-bottom: 2rem;
        padding: 0 0.25rem;
    }
    .home-panel-showcase {
        margin-bottom: 2.75rem;
    }
    .home-mock {
        transform: none !important;
        border-radius: 12px;
    }
    .home-mock:hover {
        transform: none !important;
    }
    .home-mock-body {
        grid-template-columns: 88px 1fr;
        min-height: 240px;
    }
    .home-mock-body-mobile {
        grid-template-columns: 1fr;
        max-width: 100%;
    }
    .hm-stats {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .home-install-cta {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .home-install-cta .home-btn {
        width: 100%;
    }
    .home-final {
        padding: 3rem 0;
    }
    .home-final-logo {
        height: 72px;
    }
}

@media (max-width: 400px) {
    .home-platform-row {
        grid-template-columns: 1fr 1fr;
    }
    .home-mock-side {
        font-size: 0.65rem;
        padding: 0.55rem 0.3rem;
    }
    .hm-brand {
        font-size: 0.68rem;
        padding: 0.15rem 0.35rem 0.5rem;
    }
}

/* ── PWA banner ── */
@media (max-width: 575.98px) {
    .pwa-install-banner-text span {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .pwa-install-banner-icon {
        width: 40px;
        height: 40px;
    }
}

/* ── Amenity / calendar ── */
@media (max-width: 575.98px) {
    .jcal-day {
        min-height: 40px;
        font-size: 0.78rem;
    }
}

/* ── Utility helpers ── */
@media (max-width: 575.98px) {
    .btn-group {
        flex-wrap: wrap;
        width: 100%;
    }
    .btn-group > .btn {
        flex: 1 1 auto;
    }
    .d-flex.gap-2.flex-wrap > .btn {
        flex: 1 1 auto;
    }
    .modal-dialog {
        margin: 0.5rem;
    }
    .modal-content {
        border-radius: 12px;
    }
    footer.border-top {
        font-size: 0.75rem;
        padding: 1rem 0.75rem !important;
    }
}

@media (max-width: 575.98px) {
    .card-header.d-flex {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }
    .card-header .ms-auto {
        margin-right: 0 !important;
        margin-left: 0 !important;
        width: 100%;
        text-align: right !important;
    }
    .alert.d-flex {
        flex-direction: column;
        align-items: flex-start !important;
    }
    .container.py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1.25rem !important;
    }
    .card-body.p-4 {
        padding: 1.1rem !important;
    }
}

.mobile-bottom-nav .bottom-nav-item.active {
    color: var(--primary);
}
.mobile-bottom-nav .bottom-nav-item.active i {
    transform: translateY(-1px);
}

/* Reduce hover lift on touch devices */
@media (hover: none) {
    .card:hover {
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 8px rgba(0, 0, 0, 0.04);
    }
    .home-btn:hover {
        transform: none;
    }
}

