/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === THEME VARS === */
:root {
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --transition: 0.3s ease;
}

/* DARK (default) */
[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-card-hover: #222636;
  --bg-input: #1a1d27;
  --border: #2d3148;
  --text: #e4e6ed;
  --text-muted: #8b8fa3;
  --text-heading: #ffffff;
  --primary: #4f6ef7;
  --primary-dark: #3b5ae0;
  --primary-bg: rgba(79,110,247,0.1);
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --danger-bg: rgba(239,68,68,0.1);
  --navbar-bg: #0a0c14;
  --table-header: #141722;
  --table-hover: #1e2233;
}

/* LIGHT */
[data-theme="light"] {
  --bg: #f3f4f6;
  --bg-card: #ffffff;
  --bg-card-hover: #f9fafb;
  --bg-input: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-heading: #111827;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-bg: rgba(37,99,235,0.08);
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --danger-bg: rgba(220,38,38,0.08);
  --navbar-bg: #111827;
  --table-header: #f9fafb;
  --table-hover: #f3f4f6;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === NAVBAR === */
.navbar {
  background: var(--navbar-bg);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  height: 60px;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}
.nav-logo { height: 36px; }
.nav-brand a:hover { text-decoration: none; }
.nav-links { display: flex; gap: 1.2rem; flex: 1; }
.nav-links a { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; transition: color 0.2s; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 0.8rem; }
.nav-user span { color: var(--text-muted); font-size: 0.85rem; }
.nav-toggle { display: none; background: none; border: none; color: #fff; font-size: 1.5rem; cursor: pointer; }

.theme-toggle {
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* === CONTAINER === */
.container { max-width: 1300px; margin: 0 auto; padding: 2rem; flex: 1; width: 100%; }

/* === AUTH === */
.auth-container { display: flex; align-items: center; justify-content: center; min-height: 80vh; }
.auth-card {
  background: var(--bg-card); padding: 2.5rem; border-radius: var(--radius);
  box-shadow: var(--shadow-md); width: 100%; max-width: 420px; text-align: center;
  border: 1px solid var(--border);
}
.auth-card .auth-logo { height: 50px; margin-bottom: 1rem; }
.auth-card .subtitle { color: var(--text-muted); margin-bottom: 2rem; }
.auth-link { margin-top: 1.5rem; font-size: 0.9rem; color: var(--text-muted); }

/* === FORMS === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.82rem; margin-bottom: 0.3rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 0.6rem 0.8rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 0.95rem; background: var(--bg-input);
  color: var(--text); transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-card { background: var(--bg-card); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 700px; border: 1px solid var(--border); }
.form-card-wide { max-width: 900px; }
.form-section-title { font-size: 1rem; font-weight: 700; color: var(--primary); margin: 1.5rem 0 1rem; padding-bottom: 0.5rem; border-bottom: 2px solid var(--primary); }
.form-foto-preview { margin-bottom: 1rem; }
.form-foto-preview img { max-height: 200px; border-radius: var(--radius); }

/* === BUTTONS === */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1.1rem; border-radius: var(--radius); font-size: 0.88rem;
  font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-full { width: 100%; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.78rem; }
.btn-logout { color: var(--text-muted); border-color: rgba(255,255,255,0.15); }

/* === PAGE HEADER === */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; flex-wrap: wrap; gap: 0.5rem; }
.page-header h1 { font-size: 1.5rem; color: var(--text-heading); }

/* === STATS === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--bg-card); padding: 1.5rem; border-radius: var(--radius);
  box-shadow: var(--shadow); text-align: center; border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
}
.stat-card.stat-warning { border-left-color: var(--warning); }
.stat-card.stat-money { border-left-color: var(--success); }
.stat-card.stat-danger { border-left-color: var(--danger); }
.stat-number { font-size: 2rem; font-weight: 800; color: var(--text-heading); }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.25rem; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-link { text-decoration: none; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; }
.stat-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); text-decoration: none; }

/* === CARDS GRID === */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }
.vehicle-card {
  background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; border: 1px solid var(--border); transition: all 0.2s;
}
.vehicle-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); }
.vehicle-foto { height: 180px; overflow: hidden; background: var(--table-header); }
.vehicle-foto img { width: 100%; height: 100%; object-fit: cover; }
.vehicle-foto-empty { display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.85rem; font-weight: 600; }
.vehicle-body { padding: 1.2rem; }
.vehicle-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.8rem; }
.vehicle-header h3 { font-size: 1.05rem; color: var(--text-heading); }
.vehicle-info p { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.vehicle-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }

/* === BADGES & TAGS === */
.badge { background: var(--primary); color: #fff; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.78rem; font-weight: 700; letter-spacing: 1px; }
.badge-admin { background: var(--danger); font-size: 0.7rem; }
.badge-gestor { background: var(--primary); font-size: 0.65rem; padding: 0.15rem 0.4rem; border-radius: 4px; color: #fff; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-role-admin { background: rgba(239,68,68,0.15); color: #ef4444; }
.tag-role-gestor { background: rgba(79,110,247,0.15); color: #4f6ef7; }
.tag { display: inline-block; padding: 0.12rem 0.55rem; border-radius: 12px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.tag-ativo { background: rgba(34,197,94,0.15); color: #22c55e; }
.tag-inativo { background: rgba(107,114,128,0.15); color: #8b8fa3; }
.tag-tipo { background: var(--primary-bg); color: var(--primary); }
.tag-fornecedor { background: rgba(168,85,247,0.15); color: #a855f7; margin-left: 0.4rem; }

/* === FILTER TABS === */
.filter-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.filter-tab {
  padding: 0.45rem 1rem; border-radius: var(--radius); font-size: 0.85rem; font-weight: 600;
  border: 1px solid var(--border); color: var(--text-muted); text-decoration: none; transition: all 0.2s;
}
.filter-tab:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tag-veic-disponivel { background: rgba(34,197,94,0.15); color: #22c55e; }
.tag-veic-em_uso { background: rgba(79,110,247,0.15); color: #4f6ef7; }
.tag-veic-manutencao { background: rgba(245,158,11,0.15); color: #f59e0b; }
.tag-veic-inativo { background: rgba(107,114,128,0.15); color: #8b8fa3; }

/* Solicitacao */
.tag-sol-aberta { background: rgba(79,110,247,0.15); color: #4f6ef7; }
.tag-sol-em_andamento { background: rgba(245,158,11,0.15); color: #f59e0b; }
.tag-sol-concluida { background: rgba(34,197,94,0.15); color: #22c55e; }
.tag-sol-cancelada { background: rgba(107,114,128,0.15); color: #8b8fa3; }

/* Urgencia */
.tag-urg-normal { background: rgba(107,114,128,0.15); color: #8b8fa3; }
.tag-urg-alta { background: rgba(245,158,11,0.15); color: #f59e0b; }
.tag-urg-urgente { background: rgba(239,68,68,0.15); color: #ef4444; font-weight: 800; }

/* Sinistro */
.tag-sin-registrado { background: rgba(79,110,247,0.15); color: #4f6ef7; }
.tag-sin-em_analise { background: rgba(245,158,11,0.15); color: #f59e0b; }
.tag-sin-aprovado { background: rgba(34,197,94,0.15); color: #22c55e; }
.tag-sin-concluido { background: rgba(34,197,94,0.2); color: #16a34a; }
.tag-sin-negado { background: rgba(239,68,68,0.15); color: #ef4444; }

/* Classificacao */
.tag-preventiva { background: rgba(79,110,247,0.15); color: #4f6ef7; }
.tag-recorrente { background: rgba(245,158,11,0.15); color: #f59e0b; }
.tag-mau_uso { background: rgba(239,68,68,0.15); color: #ef4444; }
.tag-mau_executado { background: rgba(236,72,153,0.15); color: #ec4899; }
.tag-status-pendente { background: rgba(245,158,11,0.15); color: #f59e0b; }
.tag-status-concluido { background: rgba(34,197,94,0.15); color: #22c55e; }

/* === TABLE === */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
thead { background: var(--table-header); }
th { text-align: left; padding: 0.75rem 1rem; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; }
td { padding: 0.75rem 1rem; border-top: 1px solid var(--border); font-size: 0.88rem; }
tr:hover { background: var(--table-hover); }
.row-inativo { opacity: 0.5; }
.actions-cell { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.inline-form { display: inline-flex; align-items: center; gap: 0.3rem; }

/* === ALERTS === */
.alert { padding: 0.9rem 1.2rem; border-radius: var(--radius); margin-bottom: 1.5rem; font-size: 0.88rem; border: 1px solid; }
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.alert-warning { background: rgba(245,158,11,0.1); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.alert-warning a { color: var(--warning); font-weight: 600; }
.alert-info { background: var(--primary-bg); color: var(--primary); border-color: rgba(79,110,247,0.3); }

/* === QUICK ACTIONS === */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
.action-card {
  display: flex; align-items: center; gap: 1rem; padding: 1.2rem 1.5rem;
  background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  transition: all 0.2s; text-decoration: none; color: var(--text);
}
.action-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-2px); }
.action-card-danger { border-left-color: var(--danger); }
.action-icon { font-size: 2rem; }
.action-text strong { display: block; color: var(--text-heading); }
.action-text span { font-size: 0.83rem; color: var(--text-muted); }

/* === DETAIL === */
.detail-card { background: var(--bg-card); padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow); max-width: 800px; border: 1px solid var(--border); }
.detail-card-wide { max-width: 1000px; }
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
.detail-header h2 { font-size: 1.2rem; color: var(--text-heading); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1.2rem; margin-bottom: 1.5rem; }
.detail-item label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.detail-item p { font-weight: 600; margin-top: 0.2rem; }
.detail-section { margin-bottom: 1.2rem; }
.detail-section label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 0.3rem; }
.detail-actions { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.resposta-admin { background: var(--primary-bg); padding: 1rem; border-radius: var(--radius); border-left: 4px solid var(--primary); }
.terceiro-section { background: var(--table-header); padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--border); margin: 1rem 0; }

/* === SECTION === */
.section { margin-bottom: 2rem; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.section h2 { font-size: 1.15rem; color: var(--text-heading); margin-bottom: 1rem; }

/* === FOTOS === */
.fotos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.8rem; margin-top: 0.8rem; }
.foto-item { position: relative; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; cursor: pointer; }
.foto-item img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.2s; }
.foto-item:hover img { transform: scale(1.05); }
.foto-desc { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.7); color: white; padding: 0.3rem 0.5rem; font-size: 0.75rem; }
.foto-categoria { margin-bottom: 1.5rem; }
.foto-categoria h3 { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.fotos-grid-sm { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.foto-item-sm { border-radius: var(--radius); overflow: hidden; aspect-ratio: 1; }
.foto-item-sm img { width: 100%; height: 100%; object-fit: cover; }
.foto-more { display: flex; align-items: center; justify-content: center; background: var(--bg-card); border-radius: var(--radius); font-weight: 700; color: var(--primary); border: 1px solid var(--border); }
.file-input { padding: 0.5rem; border: 2px dashed var(--border); border-radius: var(--radius); width: 100%; color: var(--text); background: var(--bg-input); }
.foto-modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.9); z-index: 1000; align-items: center; justify-content: center; cursor: pointer; }
.foto-modal.active { display: flex; }
.foto-modal img { max-width: 90vw; max-height: 90vh; border-radius: var(--radius); }

/* Toggle terceiro */
.toggle-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-weight: 600; }
.toggle-label input { width: 18px; height: 18px; accent-color: var(--primary); }
.hidden { display: none; }

/* === EMPTY STATE === */
.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state .btn { margin-top: 1rem; }

/* === TEXT === */
.text-danger { color: var(--danger); font-weight: 600; }
.text-warning { color: var(--warning); font-weight: 600; }
.text-ellipsis { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* === FOOTER === */
.footer { text-align: center; padding: 1.5rem; color: var(--text-muted); font-size: 0.8rem; border-top: 1px solid var(--border); margin-top: auto; }
.footer-versiculo { font-style: italic; opacity: 0.7; margin-bottom: 0.3rem; font-size: 0.75rem; }

/* === PWA INSTALL BANNER === */
#pwa-banner {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  background: var(--primary); color: #fff; padding: 0.6rem 1rem;
  font-size: 0.85rem; font-weight: 600; position: sticky; top: 0; z-index: 200;
}
#pwa-banner span { flex: 1; text-align: center; }
#pwa-install {
  background: #fff; color: var(--primary); border: none; padding: 0.35rem 1rem;
  border-radius: 6px; font-weight: 700; cursor: pointer; font-size: 0.82rem;
}
#pwa-close { background: none; border: none; color: rgba(255,255,255,0.7); cursor: pointer; font-size: 1.1rem; }
.foto-upload-inline { margin-top: 0.5rem; }

/* === STATUS BANNER === */
.status-banner {
  display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem 1.2rem;
  border-radius: var(--radius); margin-bottom: 1.5rem; font-weight: 700; font-size: 1rem;
}
.status-banner .status-icon { font-size: 1.3rem; }
.status-aberta { background: rgba(79,110,247,0.12); color: #4f6ef7; border: 1px solid rgba(79,110,247,0.3); }
.status-em_andamento { background: rgba(245,158,11,0.12); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.status-aprovada { background: rgba(34,197,94,0.12); color: #22c55e; border: 1px solid rgba(34,197,94,0.3); }
.status-negada { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }
.status-concluida { background: rgba(34,197,94,0.15); color: #16a34a; border: 1px solid rgba(34,197,94,0.3); }

/* === ADMIN ACTION BUTTONS === */
.admin-actions { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.admin-actions h3 { margin-bottom: 1rem; font-size: 1rem; }
.action-buttons { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.btn-warning { background: var(--warning); color: #000; }

/* === TAGS NOVOS STATUS === */
.tag-sol-aprovada { background: rgba(34,197,94,0.15); color: #22c55e; }
.tag-sol-negada { background: rgba(239,68,68,0.15); color: #ef4444; }

/* === DESCRICAO BOX === */
.descricao-box { background: var(--table-header); padding: 1rem; border-radius: var(--radius); border: 1px solid var(--border); white-space: pre-wrap; line-height: 1.6; }

/* === PREVIEW FOTOS === */
.preview-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.5rem; }
.preview-img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius); border: 2px solid var(--border); }

/* === ROW URGENTE === */
.row-urgente { border-left: 3px solid var(--danger); }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .navbar { padding: 0.8rem 1rem; flex-wrap: wrap; height: auto; }
  .nav-toggle { display: block; }
  .nav-links { display: none; width: 100%; flex-direction: column; gap: 0.5rem; padding: 0.5rem 0; }
  .nav-links.active { display: flex; }
  .container { padding: 1rem; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cards-grid { grid-template-columns: 1fr; }
  .actions-cell { flex-direction: column; align-items: flex-start; }
  .quick-actions { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .nav-user span { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
}
