
/* ═══════════════════════════════════════════════════════
   RESPONSIVIDADE MOBILE — THE3 Finance
   Adicionar no final do style.css
   ═══════════════════════════════════════════════════════ */

/* ── Meta viewport já deve estar no index.html:
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
── */

/* ══════════════════════════════════════════════════════
   TABLET (até 1024px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 1024px) {

  /* KPI grid 2 colunas */
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }

  /* Charts empilhados */
  .charts-row { grid-template-columns: 1fr; }

  /* Filtros wrap */
  .filter-row { flex-wrap: wrap; }
  .filter-row input, .filter-row select { min-width: 140px; flex: 1; }

  /* Relatórios */
  .rp-filters-row { grid-template-columns: 1fr 1fr 1fr; }

  /* Orçamentos stats */
  .bud-stats { grid-template-columns: repeat(3, 1fr); }

  /* Inventário stats */
  .inv-stats-row { grid-template-columns: 1fr 1fr; }
  .inv-stat-card.wide { grid-column: span 2; }

  /* Auditoria stats */
  .log-stats-row { grid-template-columns: repeat(3, 1fr); }
}

/* ══════════════════════════════════════════════════════
   MOBILE (até 768px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── SIDEBAR ── */
  :root { --sb-w: 280px; }

  .sidebar {
    transform: translateX(-100%);
    z-index: 300;
    box-shadow: none;
    transition: transform 0.3s cubic-bezier(.4,0,.2,1), box-shadow 0.3s;
    /* FIX: sidebar mobile ocupa tela cheia em altura com scroll */
    height: 100vh;
    display: flex;
    flex-direction: column;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.2);
  }

  /* FIX: nav com scroll no mobile */
  .sidebar .sb-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  /* FIX: usuário sempre visível no rodapé da sidebar */
  .sidebar .sb-user {
    flex-shrink: 0;
    border-top: 1px solid var(--border-light, #f0f2f5);
    padding: .85rem 1rem;
  }

  /* Overlay quando sidebar está aberta */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 299;
    backdrop-filter: blur(2px);
  }
  .sidebar-overlay.active { display: block; }

  /* ── MAIN AREA — FIX: 100vw quando sidebar está escondida ── */
  .main-area {
    margin-left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
  }

  /* ── TOPBAR ── */
  .topbar { padding: 0 1rem; gap: .75rem; }
  .tb-menu { display: flex !important; }
  .tb-title { font-size: .9rem; }
  .tb-period select { font-size: .75rem; padding: .3rem .5rem; }

  /* ── SECTIONS ── */
  .section { padding: 1rem; }

  /* ── SEC HEAD ── */
  .sec-head {
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
  }
  .sec-head h2 { font-size: 1.25rem; }
  .sec-head .btn-primary,
  .sec-head .btn-outline { width: 100%; justify-content: center; }
  .sec-head div[style*="display:flex"] { width: 100%; flex-direction: column; gap: .5rem; }

  /* ── KPI GRID ── */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .kpi { padding: 1rem; }
  .kpi-val { font-size: 1.25rem; }
  .kpi-icon-wrap { width: 36px; height: 36px; margin-bottom: .65rem; }

  /* ── CHARTS ── */
  .charts-row { grid-template-columns: 1fr; gap: .75rem; }
  .chart-card { padding: 1rem; }

  /* ── FILTER ROW ── */
  .filter-row {
    flex-direction: column;
    gap: .5rem;
    padding: .85rem;
  }
  .filter-row > * { width: 100% !important; min-width: unset !important; }
  .fr-search { width: 100%; }
  .fr-search input { width: 100%; }
  .filter-row .btn-primary { width: 100%; justify-content: center; }

  /* ── TABELAS ── */
  .tbl-card { border-radius: var(--r-sm); }
  .data-table { font-size: .78rem; }
  .data-table th { padding: .6rem .65rem; font-size: .65rem; }
  .data-table td { padding: .7rem .65rem; }

  /* Ocultar colunas menos importantes em mobile */
  .tbl-col-hide-mobile { display: none !important; }

  /* ── MODAL ── */
  .modal-bg { padding: .5rem; align-items: flex-end; }
  .modal-box {
    max-height: 92vh;
    border-radius: var(--r) var(--r) 0 0;
    max-width: 100%;
    width: 100%;
  }
  .modal-hd { padding: 1rem 1.25rem; }
  .modal-bd { padding: 1rem 1.25rem; }
  .fg { grid-template-columns: 1fr !important; }
  .fg .full { grid-column: 1 !important; }
  .form-foot {
    flex-direction: column-reverse;
    gap: .5rem;
  }
  .form-foot .btn-primary,
  .form-foot .btn-outline { width: 100%; justify-content: center; }

  /* ── ENTITY GRID ── */
  .entity-grid { grid-template-columns: 1fr; }

  /* ── CATEGORIES ── */
  .cat-cols { grid-template-columns: 1fr; gap: 1rem; }

  /* ── RELATÓRIOS ── */
  .rp-filters-row { grid-template-columns: 1fr; }
  .rpt-kpis { grid-template-columns: repeat(2, 1fr); }
  .rp-filters-actions { flex-direction: column; }
  .rp-filters-actions .btn-primary,
  .rp-filters-actions .btn-outline { width: 100%; justify-content: center; }
  .rp-date-range { flex-direction: column; }
  .rp-date-range input { width: 100%; }
  .rp-date-sep { display: none; }

  /* ── SETTINGS ── */
  .settings-tabs { width: 100%; justify-content: center; }
  .stab { flex: 1; text-align: center; }
  .user-row { flex-wrap: wrap; gap: .65rem; }
  .user-row-acts { width: 100%; justify-content: flex-end; }

  /* ── AUDITORIA ── */
  .audit-filter-bar { flex-direction: column; }
  .audit-filter-bar > * { width: 100% !important; min-width: unset !important; }
  .audit-filter-dates { flex-direction: column; }
  .audit-filter-dates input { width: 100%; }
  .log-stats-row { grid-template-columns: 1fr 1fr; }
  .log-stat-card.wide { grid-column: span 2; }

  /* ── ORÇAMENTOS ── */
  .bud-stats { grid-template-columns: 1fr 1fr; }
  .bud-items-header { display: none; }
  .bud-item-row { flex-wrap: wrap; gap: .4rem; }
  .bud-item-desc  { width: 100%; min-width: unset; }
  .bud-item-qty   { width: calc(33% - .3rem); }
  .bud-item-unit  { width: calc(33% - .3rem); }
  .bud-item-price { width: calc(33% - .3rem); text-align: left; }
  .bud-item-total { width: 100%; text-align: right; border-top: 1px solid #f1f5f9; padding-top: .3rem; }
  .bud-section-title { font-size: .82rem; }

  /* Recorrência */
  .recur-types { grid-template-columns: 1fr; gap: .4rem; }
  .recur-type-card { flex-direction: row; padding: .65rem .85rem; justify-content: flex-start; }

  /* ── INVENTÁRIO ── */
  .inv-stats-row { grid-template-columns: 1fr; }
  .inv-stat-card.wide { grid-column: span 1; }
  .inv-items-grid { grid-template-columns: 1fr; }
  .inv-client-header { flex-wrap: wrap; gap: .65rem; }
  .inv-client-header .btn-outline { width: 100%; }
  .inv-print-list { max-height: 200px; }

  /* ── SIDEBAR CASH WIDGET ── */
  .sb-cash-widget { margin: .75rem; }
  .sbcw-value { font-size: 1.1rem; }

  /* ── LOGIN MOBILE ── */
  .login-layout {
    flex-direction: column;
    min-height: 100vh;
    position: relative;
  }

  /* Fundo animado cobre tela toda */
  .login-left {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
  }

  /* Conteúdo do lado esquerdo: logo + headline no topo */
  .ll-content {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    padding: 2.5rem 1.75rem 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    gap: .85rem !important;
    z-index: 1 !important;
    pointer-events: none !important;
  }

  /* Oculta features e body no mobile (economiza espaço) */
  .ll-features { display: none !important; }
  .ll-body     { display: none !important; }
  .ll-bottom   { display: none !important; }

  /* Headline menor */
  .ll-headline {
    font-size: 1.75rem !important;
    margin-bottom: 0 !important;
  }

  /* Painel direito: sem fundo, ocupa tela inteira, alinha card ao centro-baixo */
  .login-right {
    position: relative;
    z-index: 2;
    width: 100% !important;
    min-width: unset !important;
    min-height: 100vh;
    margin-left: 0 !important;
    background: transparent !important;
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 1rem 2rem !important;
  }

  /* Card de login: largura total, borda arredondada */
  .login-card {
    width: 100% !important;
    max-width: 420px !important;
    border-radius: 20px !important;
    padding: 1.75rem 1.5rem !important;
    background: rgba(255,255,255,0.97) !important;
    box-shadow: 0 -4px 40px rgba(0,0,0,0.25), 0 8px 32px rgba(0,0,0,0.2) !important;
  }
}

/* ══════════════════════════════════════════════════════
   MOBILE PEQUENO (até 480px)
   ══════════════════════════════════════════════════════ */
@media (max-width: 480px) {

  .kpi-grid { grid-template-columns: 1fr; }
  .kpi { padding: .85rem; }

  .rpt-kpis { grid-template-columns: 1fr 1fr; }

  .bud-stats { grid-template-columns: 1fr; }

  .log-stats-row { grid-template-columns: 1fr; }
  .log-stat-card.wide { grid-column: span 1; }

  .tb-period select { font-size: .7rem; padding: .25rem .4rem; }
  .tbl-acts { flex-wrap: wrap; gap: .25rem; }

  .section { padding: .75rem; }
  .topbar  { padding: 0 .75rem; }

  .data-table th,
  .data-table td { padding: .5rem .5rem; }

  /* Esconde colunas secundárias */
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) { display: none; }
}

/* ══════════════════════════════════════════════════════
   TOUCH & HOVER IMPROVEMENTS
   ══════════════════════════════════════════════════════ */
@media (hover: none) {
  /* Botões maiores para toque */
  .btn-primary, .btn-outline { min-height: 44px; }
  .btn-sm { min-height: 36px; padding: .4rem .85rem !important; }
  .sb-item { min-height: 44px; }

  /* Remove hover states que não fazem sentido em touch */
  .kpi:hover,
  .ent-card:hover,
  .inv-item-card:hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
}

/* ══════════════════════════════════════════════════════
   PRINT (impressão)
   ══════════════════════════════════════════════════════ */
@media print {
  .sidebar, .topbar, .filter-row, .tbl-acts,
  .btn-primary, .btn-outline, .btn-danger, .btn-edit { display: none !important; }
  .main-area { margin-left: 0 !important; }
  .section { padding: 0; }
  .tbl-card { box-shadow: none; border: 1px solid #e2e8f0; }
}
