/* ──────────────────────────────────────────────────────────────────────────────
   Concrefer Frotas – styles.css  (Base + Variables + Layout + Dark mode)
   ────────────────────────────────────────────────────────────────────────────── */

/* ─── Reset & Box ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* ─── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  /* Cores principais */
  --c-primary:        #1e3a5f;
  --c-primary-light:  #2d5a8c;
  --c-primary-dark:   #0f1f33;
  --c-secondary:      #374151;
  --c-white:          #ffffff;
  --c-bg:             #f0f4f8;
  --c-surface:        #ffffff;
  --c-border:         #e2e8f0;

  /* Texto */
  --c-text:           #1a202c;
  --c-text-muted:     #718096;
  --c-text-light:     #a0aec0;

  /* Semânticas */
  --c-success:        #16a34a;
  --c-success-bg:     #dcfce7;
  --c-warning:        #d97706;
  --c-warning-bg:     #fef3c7;
  --c-danger:         #dc2626;
  --c-danger-bg:      #fee2e2;
  --c-orange:         #ea580c;
  --c-orange-bg:      #ffedd5;
  --c-info:           #0284c7;
  --c-info-bg:        #e0f2fe;

  /* Status */
  --c-aberto:           #3b82f6;
  --c-aberto-bg:        #dbeafe;
  --c-triagem:          #7c3aed;
  --c-triagem-bg:       #ede9fe;
  --c-atribuido:        #1d4ed8;
  --c-atribuido-bg:     #dbeafe;
  --c-execucao:         #059669;
  --c-execucao-bg:      #d1fae5;
  --c-pausado:          #d97706;
  --c-pausado-bg:       #fef3c7;
  --c-ag-peca:          #ea580c;
  --c-ag-peca-bg:       #ffedd5;
  --c-ag-aprovacao:     #7c3aed;
  --c-ag-aprovacao-bg:  #ede9fe;
  --c-concluido:        #15803d;
  --c-concluido-bg:     #dcfce7;
  --c-cancelado:        #6b7280;
  --c-cancelado-bg:     #f3f4f6;

  /* Prioridade */
  --c-urgente:   #dc2626;
  --c-alta:      #ea580c;
  --c-media:     #d97706;
  --c-baixa:     #16a34a;

  /* Espaçamento */
  --sp-xs:  4px;
  --sp-sm:  8px;
  --sp-md:  16px;
  --sp-lg:  24px;
  --sp-xl:  32px;
  --sp-2xl: 48px;

  /* Raios */
  --r-sm:   6px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   20px;
  --r-full: 9999px;

  /* Sombras */
  --shadow-xs:  0 1px 2px rgba(0,0,0,.06);
  --shadow-sm:  0 1px 4px rgba(0,0,0,.10);
  --shadow-md:  0 4px 12px rgba(0,0,0,.12);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.16);

  /* Tipografia */
  --fs-xs:   11px;
  --fs-sm:   13px;
  --fs-base: 15px;
  --fs-md:   16px;
  --fs-lg:   18px;
  --fs-xl:   20px;
  --fs-2xl:  24px;
  --fs-3xl:  28px;

  /* Layout */
  --header-h:    60px;
  --bottom-nav-h: 64px;
  --filter-bar-h: 56px;
}

/* ─── Dark mode ──────────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --c-bg:      #0f172a;
  --c-surface: #1e293b;
  --c-border:  #334155;
  --c-text:    #f1f5f9;
  --c-text-muted: #94a3b8;
  --c-text-light: #64748b;
  --c-secondary: #94a3b8;
}

/* ─── Base ───────────────────────────────────────────────────────────────────── */
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-size: var(--fs-base);
  line-height: 1.5;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ─── App Header ─────────────────────────────────────────────────────────────── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--c-primary);
  color: #fff;
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 0 var(--sp-md);
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.app-header__brand { display: flex; align-items: center; gap: var(--sp-sm); flex: 1; min-width: 0; }
.app-header__logo { font-size: 22px; flex-shrink: 0; }
.app-header__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.app-header__actions { display: flex; align-items: center; gap: var(--sp-sm); }

/* ─── Bottom Nav ─────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--sp-xs) var(--sp-sm);
  color: var(--c-text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  transition: color .2s;
  min-width: 44px;
}
.bottom-nav__item--active { color: var(--c-primary); }
.bottom-nav__icon { font-size: 22px; line-height: 1; }
.bottom-nav__item--fab {
  position: relative;
  top: -16px;
}
.bottom-nav__icon--fab {
  width: 52px; height: 52px;
  background: var(--c-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  font-size: 26px;
}

/* ─── App Content ────────────────────────────────────────────────────────────── */
.app-content {
  margin-top: var(--header-h);
  padding-bottom: calc(var(--bottom-nav-h) + var(--sp-lg));
  min-height: calc(100vh - var(--header-h));
}
.app-content--home { padding: var(--sp-md); }
.app-content--form { padding: var(--sp-md) var(--sp-md) calc(var(--bottom-nav-h) + 80px); }
.app-content--list {
  padding: var(--sp-sm) var(--sp-md);
  margin-top: calc(var(--header-h) + var(--filter-bar-h));
}
.app-content--list.has-chips {
  margin-top: calc(var(--header-h) + var(--filter-bar-h) + 44px);
}
.app-content--detail { padding: var(--sp-md) var(--sp-md) calc(var(--bottom-nav-h) + 80px); }
.app-content--dashboard { padding: var(--sp-md); }

/* ─── Filter Bar ─────────────────────────────────────────────────────────────── */
.filter-bar {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  height: var(--filter-bar-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 0 var(--sp-md);
  z-index: 90;
  box-shadow: var(--shadow-xs);
}
.search-box { flex: 1; display: flex; }
.search-box__input {
  flex: 1;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-full);
  padding: var(--sp-sm) var(--sp-md);
  font-size: var(--fs-sm);
  background: var(--c-bg);
  color: var(--c-text);
  outline: none;
  height: 38px;
}
.search-box__input:focus { border-color: var(--c-primary-light); }

/* ─── Status Chips ───────────────────────────────────────────────────────────── */
.status-chips {
  position: fixed;
  top: calc(var(--header-h) + var(--filter-bar-h));
  left: 0; right: 0;
  height: 44px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  gap: var(--sp-sm);
  padding: var(--sp-xs) var(--sp-md);
  overflow-x: auto;
  z-index: 89;
  scrollbar-width: none;
}
.status-chips::-webkit-scrollbar { display: none; }
.status-chip {
  white-space: nowrap;
  border: 1.5px solid var(--c-border);
  border-radius: var(--r-full);
  padding: 4px 12px;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--c-surface);
  color: var(--c-text-muted);
  flex-shrink: 0;
}
.status-chip--active { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

/* ─── Filters panel ──────────────────────────────────────────────────────────── */
.filters-panel {
  position: fixed;
  top: calc(var(--header-h) + var(--filter-bar-h));
  left: 0; right: 0;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: var(--sp-md);
  z-index: 88;
  box-shadow: var(--shadow-sm);
}
.filters-panel__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-sm);
}

/* ─── List Header ────────────────────────────────────────────────────────────── */
.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-sm) 0;
}
.list-count { font-size: var(--fs-sm); color: var(--c-text-muted); font-weight: 600; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-xs);
  padding: 10px var(--sp-md);
  border-radius: var(--r-md);
  font-size: var(--fs-base);
  font-weight: 600;
  border: 2px solid transparent;
  transition: opacity .15s, transform .1s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn--primary  { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn--success  { background: var(--c-success); color: #fff; border-color: var(--c-success); }
.btn--warning  { background: var(--c-warning); color: #fff; border-color: var(--c-warning); }
.btn--danger   { background: var(--c-danger);  color: #fff; border-color: var(--c-danger); }
.btn--orange   { background: var(--c-orange);  color: #fff; border-color: var(--c-orange); }
.btn--outline  { background: transparent; color: var(--c-primary); border-color: var(--c-primary); }
.btn--sm       { padding: 6px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--lg       { padding: 14px var(--sp-lg); font-size: var(--fs-lg); border-radius: var(--r-lg); }
.btn--block    { width: 100%; }
.btn-icon {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  padding: var(--sp-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-sm);
  min-width: 36px;
  -webkit-tap-highlight-color: transparent;
}
.btn-icon:active { opacity: .7; }

/* ─── User badge ────────────────────────────────────────────────────────────── */
.user-badge {
  background: rgba(255,255,255,.2);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-h) + var(--sp-md));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--c-secondary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  font-weight: 600;
  max-width: calc(100vw - 32px);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}
.toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast--success { background: var(--c-success); }
.toast--error   { background: var(--c-danger); }
.toast--warning { background: var(--c-warning); }

/* ─── Loading Overlay ────────────────────────────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
}
.loading-spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Skeleton ───────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--c-border) 25%, #e8ecf0 50%, var(--c-border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--r-sm);
}
.skeleton--text { height: 14px; margin-bottom: 10px; border-radius: var(--r-full); }
.skeleton--card { height: 110px; margin-bottom: var(--sp-sm); border-radius: var(--r-lg); }
.skeleton--hero { height: 100px; border-radius: var(--r-lg); }
.skeleton--kpi  { height: 32px; width: 60px; }
.skeleton-list { display: flex; flex-direction: column; gap: var(--sp-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  z-index: 9000;
  padding: 0;
}
.modal-overlay--dark { background: rgba(0,0,0,.92); align-items: center; justify-content: center; }
.modal {
  background: var(--c-surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .25s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md);
  border-bottom: 1px solid var(--c-border);
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 1;
}
.modal__title { font-size: var(--fs-lg); font-weight: 700; }
.modal__close { color: var(--c-text-muted); font-size: 18px; }
.modal__body { padding: var(--sp-md); }
.modal__footer {
  padding: var(--sp-md);
  border-top: 1px solid var(--c-border);
  display: flex;
  gap: var(--sp-sm);
  justify-content: flex-end;
}
.modal-foto__close { position: fixed; top: var(--sp-md); right: var(--sp-md); z-index: 2; background: rgba(0,0,0,.5); color: #fff; border-radius: 50%; width: 40px; height: 40px; font-size: 20px; border: none; }
.modal-foto__img { max-width: 100%; max-height: 90vh; border-radius: var(--r-md); object-fit: contain; }

/* ─── Empty State ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--sp-2xl) var(--sp-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-sm);
}
.empty-state__icon { font-size: 56px; }
.empty-state__title { font-size: var(--fs-lg); font-weight: 700; }
.empty-state__desc  { font-size: var(--fs-sm); color: var(--c-text-muted); }

/* ─── Action bar (detail page) ───────────────────────────────────────────────── */
.action-bar {
  position: fixed;
  bottom: var(--bottom-nav-h);
  left: 0; right: 0;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: var(--sp-sm) var(--sp-md);
  display: flex;
  gap: var(--sp-sm);
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 80;
  box-shadow: 0 -2px 8px rgba(0,0,0,.08);
}
.action-bar::-webkit-scrollbar { display: none; }
.action-bar .btn { flex-shrink: 0; }

/* ─── Home ───────────────────────────────────────────────────────────────────── */
.home-hero { margin-bottom: var(--sp-md); padding: var(--sp-sm) 0; }
.home-hero__subtitle { font-size: var(--fs-sm); color: var(--c-text-muted); }
.sync-status { display: flex; align-items: center; gap: var(--sp-sm); margin-top: var(--sp-sm); }
.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-md);
}
.home-card {
  background: var(--c-surface);
  border-radius: var(--r-lg);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-xs);
  box-shadow: var(--shadow-sm);
  border: 1.5px solid var(--c-border);
  transition: transform .15s, box-shadow .15s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  min-height: 110px;
}
.home-card:active { transform: scale(.97); box-shadow: var(--shadow-xs); }
.home-card--primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); grid-column: span 2; }
.home-card--sync { background: var(--c-surface); border: 2px dashed var(--c-border); color: var(--c-text-muted); }
.home-card__icon { font-size: 32px; }
.home-card__label { font-size: var(--fs-md); font-weight: 700; }
.home-card__desc { font-size: var(--fs-xs); opacity: .75; }
.home-card__badge {
  position: absolute;
  top: var(--sp-sm); right: var(--sp-sm);
  background: var(--c-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px; height: 22px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
