/* ════════════════════════════════════════════════════════════════
   Ceramispot — Mobile-First Responsive Layer
   Completes the existing responsive patterns in each dashboard CSS.
   ════════════════════════════════════════════════════════════════ */

/* ── GLOBAL BASE ── */
html, body { overflow-x: hidden; -webkit-text-size-adjust: 100%; }
*, *::before, *::after { box-sizing: border-box; }
img, video, iframe { max-width: 100%; height: auto; }

/* ── TOUCH TARGETS ── */
button, .btn, a, .sb-item, .tab-nav-item, .anav-item, .nav-item,
.msg-row, .notif, .res-card, .brow, .fcard, .pay-row {
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(201,106,58,.08);
}

/* ── TAB-NAV SCROLL ── */
@media (max-width: 768px) {
  .tab-nav, .tbar, .sub-tabs, .view-tabs {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-snap-type: x mandatory;
    flex-wrap: nowrap !important;
  }
  .tab-nav::-webkit-scrollbar,
  .tbar::-webkit-scrollbar,
  .sub-tabs::-webkit-scrollbar,
  .view-tabs::-webkit-scrollbar { display: none; }
  .tab-nav > *, .tbar > *, .sub-tabs > *, .view-tabs > * {
    scroll-snap-align: start;
    flex-shrink: 0;
  }
}

/* ── iOS INPUT ZOOM PREVENTION ── */
@media (max-width: 768px) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

/* ── MIN TOUCH TARGETS (44px Apple HIG) ── */
@media (max-width: 768px) {
  button, .btn, .abtn, .sb-item, .anav-item, .nav-item,
  input[type="checkbox"], input[type="radio"] {
    min-height: 44px;
  }
  .abtn { padding: 8px 12px; font-size: 12px; }
}

/* ═══════════════════════════════════════════════════════════════
   ADMIN DASHBOARD — ENHANCED MOBILE (extends dashboard-admin.css)
   ═══════════════════════════════════════════════════════════════ */

/* Admin sidebar drawer (currently just display:none at 1000px) */
@media (max-width: 1000px) {
  .admin-sb {
    display: flex !important;
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    z-index: 4000;
    transition: left .3s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(45,26,8,.18);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .admin-sb.open { left: 0; }

  /* Hamburger button */
  .admin-mob-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1.5px solid #e8ddd2;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    font-size: 18px;
  }

  /* Overlay */
  .admin-mob-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45,26,8,.5);
    z-index: 3999;
    backdrop-filter: blur(1px);
  }
  .admin-mob-overlay.open { display: block; }

  /* Main full width */
  .admin-main {
    width: 100%;
    min-width: 0;
    padding: 12px;
  }

  /* Topnav compact */
  .topnav { padding: 0 10px; gap: 6px; }
  .topnav-user span { display: none; }
}

/* Admin tables — horizontal scroll on mobile */
@media (max-width: 768px) {
  .atable-wrap, .table-wrap, .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -12px;
    padding: 0 12px;
  }
  .atable { min-width: 600px; }
  .atable th, .atable td { padding: 8px 6px; font-size: 12px; }
  .abtns { gap: 2px; }
  .abtn { padding: 6px 8px; font-size: 10px; }
}

/* Admin stats grid */
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr !important; }
  .stat-card, .kpi-card, .card { margin-bottom: 8px; }
}

/* Admin filter bar */
@media (max-width: 768px) {
  .afbar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .asearch { width: 100%; min-width: 0; }
  .asel { width: 100%; }
}

/* ═══════════════════════════════════════════════════════════════
   CRM — ENHANCED MOBILE (extends ceramispot-crm.css)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  /* CRM sidebar drawer */
  .ceramispot-crm-app .sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    width: 240px;
    height: 100vh;
    z-index: 5000;
    transition: left .3s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(45,26,8,.18);
  }
  .ceramispot-crm-app .sidebar.open { left: 0; }

  /* CRM overlay */
  .ceramispot-crm-app .crm-mob-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45,26,8,.5);
    z-index: 4999;
  }
  .ceramispot-crm-app .crm-mob-overlay.open { display: block; }

  /* CRM main full-width */
  .ceramispot-crm-app .main { width: 100%; }
  .ceramispot-crm-app .content { padding: 12px; }
  .ceramispot-crm-app .topbar { padding: 0 12px; }

  /* CRM stats — 2 cols then 1 col */
  .ceramispot-crm-app .stats-row { grid-template-columns: repeat(2, 1fr); }

  /* CRM focus wrap — stack */
  .ceramispot-crm-app .focus-wrap { grid-template-columns: 1fr; }

  /* CRM pipeline — horizontal scroll */
  .ceramispot-crm-app .pipeline-board {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 16px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .ceramispot-crm-app .pipeline-col {
    min-width: 280px;
    scroll-snap-align: start;
    flex-shrink: 0;
  }

  /* Sendtime grid */
  .ceramispot-crm-app .sendtime-grid { grid-template-columns: repeat(2, 1fr); }

  /* CRM toggle button */
  .crm-mob-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1.5px solid var(--cream-dark, #f5e6d4);
    border-radius: 8px;
    background: var(--white, #fff);
    cursor: pointer;
    font-size: 16px;
  }
}

@media (max-width: 600px) {
  .ceramispot-crm-app .stats-row { grid-template-columns: 1fr; }

  /* Lead page — single column */
  .ceramispot-crm-app .lp-columns,
  .ceramispot-crm-app .lead-page-body {
    grid-template-columns: 1fr !important;
    height: auto;
    overflow: visible;
  }
  .ceramispot-crm-app .lp-col,
  .ceramispot-crm-app .lead-info-col,
  .ceramispot-crm-app .lead-history-col {
    height: auto;
    overflow: visible;
  }

  /* Lead page footer */
  .ceramispot-crm-app .lead-page-footer,
  .ceramispot-crm-app .lp-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }
  .ceramispot-crm-app .lead-page-footer button,
  .ceramispot-crm-app .lp-footer button {
    flex: 1;
    min-width: 140px;
    justify-content: center;
  }
}

/* Hide CRM/admin toggle buttons on desktop */
@media (min-width: 901px) {
  .crm-mob-toggle { display: none !important; }
}
@media (min-width: 1001px) {
  .admin-mob-toggle { display: none !important; }
  .admin-mob-overlay { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   MODALS — BOTTOM SHEET ON MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .modal-box, .block-modal, .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 40vh;
    max-height: 90vh;
    border-radius: 20px 20px 0 0 !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    margin: 0 !important;
    transform: none !important;
  }
  .modal-overlay, .modal-bg, .modal-backdrop {
    align-items: flex-end !important;
  }
  .modal-body, .modal-box-body {
    overflow-y: auto;
    max-height: calc(90vh - 120px);
    -webkit-overflow-scrolling: touch;
  }
}

/* ═══════════════════════════════════════════════════════════════
   MESSAGING — ONE COLUMN ON MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .msg-layout, .msg-wrap {
    display: block;
  }
  .msg-list-col, .msg-list-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e8ddd2;
  }
  .msg-thread-col, .msg-conv-col {
    display: none;
    width: 100%;
  }
  .msg-thread-col.active, .msg-conv-col.active {
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0;
    z-index: 500;
    background: #faf7f4;
    padding-top: 56px;
  }
  .msg-back-btn { display: flex !important; }
}
@media (min-width: 769px) {
  .msg-back-btn { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════
   KPI / STATS GRIDS
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .kpi-grid, .quick-stats, .qs-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
  }
  .kpi-card, .qs-card { padding: 14px; }
  .kpi-value, .qs-value { font-size: 22px; }
}
@media (max-width: 400px) {
  .kpi-grid, .quick-stats, .qs-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   HEADER COMPACT ON MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .dashboard-header, .dash-header, .pro-header {
    padding: 0 12px;
    gap: 8px;
    height: 56px;
  }
  .h-add-btn span, .header-btn-text { display: none; }
  .h-add-btn {
    padding: 8px 12px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .page-title, .dash-title { font-size: 16px; }

  /* Notification dropdown — full width */
  .notif-dropdown, .cn-panel {
    position: fixed !important;
    top: 56px !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    border-radius: 0 !important;
    max-height: calc(100vh - 56px) !important;
    overflow-y: auto !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   FORM CREATION (ANNONCE) MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .listing-steps-nav, .step-bar, .steps-nav {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .listing-steps-nav::-webkit-scrollbar,
  .step-bar::-webkit-scrollbar,
  .steps-nav::-webkit-scrollbar { display: none; }
  .step-item, .step-dot {
    display: inline-flex;
    min-width: 80px;
    flex-shrink: 0;
  }
  .listing-form-grid, .form-grid, .form-row {
    grid-template-columns: 1fr !important;
  }
  .step-nav-btns, .form-nav {
    flex-direction: column;
    gap: 8px;
  }
  .step-nav-btns button, .form-nav button {
    width: 100%;
    min-height: 48px;
  }
  .photos-grid, .upload-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLING INERTIA
   ═══════════════════════════════════════════════════════════════ */

.dashboard-main, .admin-main, .content,
.msg-list-col, .msg-conv-col, .msg-thread-col,
.lead-tab-body, .sidebar, .admin-sb {
  -webkit-overflow-scrolling: touch;
}

/* ═══════════════════════════════════════════════════════════════
   SINGLE-LISTING MOBILE ENHANCEMENTS
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  /* Gallery — full-bleed */
  .gallery-grid, .listing-gallery {
    grid-template-columns: 1fr !important;
    gap: 4px;
    margin: 0 -12px;
  }
  .gallery-grid img, .listing-gallery img {
    border-radius: 0;
  }

  /* Info grid — stack */
  .listing-info-grid, .detail-grid {
    grid-template-columns: 1fr !important;
  }

  /* Reviews — compact */
  .review-card { padding: 14px; }
  .review-stars { font-size: 14px; }
}

/* ═══════════════════════════════════════════════════════════════
   HOMEPAGE MOBILE
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .hero-section, .cs-hero {
    padding: 40px 16px 30px;
  }
  .hero-title, .cs-hero h1 {
    font-size: clamp(24px, 6vw, 36px);
  }
  .search-bar-wrap, .cs-search-bar {
    flex-direction: column;
    gap: 8px;
  }
  .search-bar-wrap input,
  .search-bar-wrap select,
  .cs-search-bar input,
  .cs-search-bar select {
    width: 100%;
    min-height: 48px;
  }
  .search-bar-wrap button,
  .cs-search-bar button {
    width: 100%;
    min-height: 48px;
  }

  /* Category cards — 1 col */
  .category-grid, .cs-categories {
    grid-template-columns: 1fr !important;
  }

  /* Testimonials — horizontal scroll */
  .testimonials-grid, .cs-temoignages {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding-bottom: 12px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
  }
  .testimonial-card, .cs-temoignage {
    min-width: 280px;
    flex-shrink: 0;
    scroll-snap-align: start;
  }
}

/* ═══════════════════════════════════════════════════════════════
   PRINT — HIDE NON-ESSENTIAL
   ═══════════════════════════════════════════════════════════════ */

@media print {
  .sidebar, .admin-sb, .topnav, .dashboard-header,
  .fab-add, .fab-book, .mob-menu-btn, .admin-mob-toggle,
  .crm-mob-toggle, .mobile-cta-bar { display: none !important; }
  .dashboard-main, .admin-main, .content { width: 100% !important; }
}
