/**
 * SYLWORK — mobile & tablet professional layer
 * Loaded after app.css. High-specificity so cards never collapse to inline text.
 */

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
img, video, svg, iframe {
  max-width: 100%;
  height: auto;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* Desktop: hide mobile chrome */
.mbar { display: none; }
.nav-toggle { display: none; }
.side-close { display: none; }

/* Large screens */
@media (min-width: 1400px) {
  .main { padding: 32px 40px 64px; }
  .main-top h1 { font-size: 1.75rem; }
  .stats-admin, .pane-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1800px) {
  body { font-size: 17px; }
  .main { padding: 36px 48px 72px; }
}

/* Tablet */
@media (max-width: 1100px) {
  .pane-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .admin-grid { grid-template-columns: 1fr; }
  .pv-layout, .jd-layout { grid-template-columns: 1fr !important; }
  .lp-features { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ============================================================
   PHONE + SMALL TABLET  (≤ 900px)
   ============================================================ */
@media (max-width: 900px) {
  html, body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .app-shell {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: none !important;
    min-height: 100dvh;
  }

  /* —— Sticky top bar —— */
  .mbar {
    display: flex !important;
    position: sticky;
    top: 0;
    z-index: 120;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    height: 56px;
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0px);
    min-height: calc(56px + env(safe-area-inset-top, 0px));
    background: #0b1220;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 24px rgba(2, 6, 23, 0.28);
  }
  .mbar-brand {
    flex: 1;
    text-align: center;
    text-decoration: none !important;
  }
  .mbar-brand .logo-text { font-size: 1.12rem; }
  .mbar-brand .logo-text .syl { color: #22c55e; }
  .mbar-brand .logo-text .work { color: #fff; }
  .mbar-btn {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    text-decoration: none !important;
    flex-shrink: 0;
    cursor: pointer;
  }
  .mbar-burger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 18px;
  }
  .mbar-burger i {
    display: block;
    height: 2px;
    width: 100%;
    background: #e2e8f0;
    border-radius: 2px;
  }

  /* Hide in-page Menu buttons — top bar owns navigation */
  .nav-toggle.btn,
  .dash-hero-actions .nav-toggle,
  .pe-hero-actions .nav-toggle,
  .jobs-hero-actions .nav-toggle,
  .pp-list-hero-actions .nav-toggle,
  .cv-hero-actions .nav-toggle,
  .ac-summary .nav-toggle,
  button.nav-toggle.btn {
    display: none !important;
  }
  .side-close {
    display: inline-flex !important;
  }

  /* —— Dark drawer —— */
  .sidebar,
  .admin-side,
  aside.sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw) !important;
    max-width: 300px;
    height: 100% !important;
    height: 100dvh !important;
    z-index: 200;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    box-shadow: none !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: linear-gradient(180deg, #0b1220 0%, #0f172a 45%, #111827 100%) !important;
    color: #e2e8f0 !important;
    padding-bottom: env(safe-area-inset-bottom, 12px);
  }
  body.nav-open .sidebar,
  body.nav-open .admin-side,
  body.nav-open aside.sidebar {
    transform: translateX(0);
    box-shadow: 16px 0 48px rgba(0, 0, 0, 0.45) !important;
  }
  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 150;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(3px);
    border: 0;
    padding: 0;
    cursor: pointer;
  }
  body.nav-open .nav-backdrop { display: block; }

  .main {
    padding: 16px 14px 56px !important;
    width: 100%;
    max-width: 100% !important;
    flex: 1;
  }

  /* —— Dashboard hero —— */
  .dash-hero,
  .pe-hero,
  .jobs-hero,
  .pp-page-head,
  .pp-list-hero,
  .pv-header-inner,
  .cv-hero,
  .jp-head,
  .ac-summary {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 16px 16px !important;
    gap: 12px !important;
  }
  .dash-hero h1,
  .pp-list-hero h1,
  .pe-hero h1,
  .jobs-hero h1,
  .cv-hero h1,
  .jp-head h1 {
    font-size: 1.35rem !important;
  }
  .dash-hero-actions,
  .pe-hero-actions,
  .jobs-hero-actions,
  .pp-list-hero-actions,
  .pv-actions,
  .jp-head-actions,
  .cv-hero-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .dash-hero-actions .btn,
  .pp-list-hero-actions .btn,
  .pe-hero-actions .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  .dash-hero-actions .btn:only-child,
  .pp-list-hero-actions .btn:only-child {
    grid-column: 1 / -1;
  }

  /* —— Stats / panes: NEVER collapse to inline text —— */
  .pane-grid,
  .stats,
  .stats-admin,
  .pp-list-stats {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 10px !important;
    margin-bottom: 18px !important;
  }
  a.pane,
  .pane {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 96px !important;
    padding: 14px 14px !important;
    color: #0f172a !important;
    text-decoration: none !important;
    background: #fff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 16px !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06) !important;
  }
  .pane .pane-label,
  .pane .pane-value,
  .pane .pane-hint {
    display: block !important;
    width: 100%;
  }
  .pane .pane-label {
    font-size: 0.68rem !important;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b !important;
    font-weight: 800 !important;
  }
  .pane .pane-value {
    font-size: 1.45rem !important;
    font-weight: 800 !important;
    color: #0f172a !important;
    line-height: 1.15;
  }
  .pane .pane-hint {
    font-size: 0.75rem !important;
    color: #64748b !important;
    line-height: 1.35;
  }

  /* —— Hub cards —— */
  .hub-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }
  .hub-card {
    min-height: 0 !important;
    padding: 18px 16px !important;
  }
  .hub-card .btn {
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }

  /* —— Profile / company list rows —— */
  .hub-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
    padding: 14px 14px !important;
  }
  .hub-item-body strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 6px;
  }
  .hub-item-body small,
  .hub-item small {
    display: flex !important;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: center;
    line-height: 1.4;
  }
  .hub-item .btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }
  .dash-section {
    margin: 22px 0 10px;
  }
  .dash-section h2 { font-size: 1.05rem !important; }
  .dash-section .btn { min-height: 40px; }

  /* Forms */
  .form-grid,
  .kv,
  .share-box,
  .pe-card .form-grid,
  .ac-layout {
    grid-template-columns: 1fr !important;
  }

  .auth-wrap { grid-template-columns: 1fr !important; }
  .auth-side { display: none !important; }
  .auth-card { margin: 0 auto; width: 100%; max-width: 420px; }

  /* Landing */
  .lp-nav nav a:not(.btn) { display: none; }
  .lp-hero { grid-template-columns: 1fr !important; padding-top: 28px !important; }
  .lp-features { grid-template-columns: 1fr !important; }

  /* Pro profile cards */
  .pro-card {
    grid-template-columns: 72px 1fr !important;
    padding: 14px !important;
  }
  .pro-card-photo {
    width: 72px !important;
    height: 72px !important;
  }
  .pro-card-actions {
    grid-column: 1 / -1;
    flex-direction: row !important;
  }
  .pro-card-actions .btn { flex: 1; min-height: 44px; }

  .pp-card-top { flex-direction: column; }
  .pp-card-actions {
    flex-direction: row !important;
    width: 100%;
  }
  .pp-card-actions .btn { flex: 1; min-height: 44px; }
  .pp-card-grid { grid-template-columns: 1fr 1fr !important; }

  /* Jobs */
  .job-card,
  .job-card-portal {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .job-card-side {
    width: 100%;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: center;
  }
  .jp-filter-row { grid-template-columns: 1fr !important; }
  .jp-field.jp-actions { grid-column: 1 / -1; }
  .jp-btn-row .btn { min-height: 44px; flex: 1; }

  /* View profile */
  .pv-facts { grid-template-columns: 1fr 1fr !important; }
  .pv-dl, .pv-edu-grid, .doc-grid { grid-template-columns: 1fr !important; }
  .pv-identity { flex-direction: column; align-items: flex-start !important; }

  /* Edit steps */
  .pe-steps {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }
  .pe-actions {
    flex-direction: column;
    align-items: stretch !important;
  }
  .pe-actions .spacer { display: none; }
  .pe-actions .btn { width: 100%; justify-content: center; min-height: 44px; }

  table.data { font-size: 0.85rem; }
  table.data th, table.data td { padding: 8px 10px; }

  .btn { min-height: 44px; }
  .btn.small { min-height: 40px; }

  .cv-workspace { grid-template-columns: 1fr !important; }
  .cv-styles { position: static !important; max-height: none !important; }
  .cv-style-grid { grid-template-columns: 1fr 1fr; }
  .cv-toolbar { flex-direction: column; align-items: stretch !important; }
  .cv-toolbar-actions { width: 100%; }
  .cv-toolbar-actions .btn { flex: 1; min-height: 44px; }

  .jd-layout { grid-template-columns: 1fr !important; }
  .jd-hero { flex-direction: column; }
  .share-row { flex-direction: column; }
  .share-row .btn { width: 100%; min-height: 44px; }
}

/* Narrow phones */
@media (max-width: 560px) {
  .pv-facts {
    grid-template-columns: 1fr !important;
  }
  .main-top h1,
  .dash-hero h1,
  .pe-hero h1,
  .jobs-hero h1,
  .pp-page-head h1,
  .pp-list-hero h1 {
    font-size: 1.28rem !important;
  }
  .pv-avatar {
    width: 72px !important;
    height: 72px !important;
  }
  .doc-modal-box {
    max-height: 95vh;
    border-radius: 14px;
  }
  .doc-modal-body iframe {
    height: 55vh;
  }
  .pp-card-grid { grid-template-columns: 1fr 1fr !important; }
  .pane .pane-hint {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

/* Safe areas */
@supports (padding: max(0px)) {
  @media (max-width: 900px) {
    .sidebar, .admin-side {
      padding-left: max(0px, env(safe-area-inset-left));
      padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
    .main {
      padding-bottom: max(56px, env(safe-area-inset-bottom)) !important;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .admin-side, .mbar {
    transition: none !important;
  }
}
