/* ================================================================
   CONTROLE DE FROTAS — Design System
   Premium dark/light theme, responsive, glassmorphism
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ---------- CSS Variables (Dark Theme - Default) ---------- */
:root {
  --bg-primary: #0f111a;
  --bg-secondary: #161925;
  --bg-card: rgba(30, 33, 48, 0.7);
  --bg-card-hover: rgba(37, 40, 64, 0.8);
  --bg-input: #12141c;
  --bg-topbar: rgba(15, 17, 26, 0.8);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: 1px solid rgba(255, 255, 255, 0.08);
  --blur: blur(12px);

  --text-primary: #f0f2f5;
  --text-secondary: #a0a5b8;
  --text-muted: #646a7e;

  --accent-primary: #6c5ce7;
  --accent-primary-hover: #8275f3;
  --accent-secondary: #00cec9;
  --accent-danger: #ff7675;
  --accent-success: #00b894;
  --accent-warning: #fab1a0;

  --border-color: rgba(255, 255, 255, 0.1);
  --border-radius: 16px;
  --border-radius-sm: 10px;
  --border-radius-lg: 24px;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.2);

  --font: 'Inter', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 80px;
}

/* ---------- Light Theme ---------- */
[data-theme="light"] {
  --bg-primary: #f8f9fc;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.7);
  --bg-card-hover: rgba(255, 255, 255, 0.9);
  --bg-input: #f0f2f7;
  --bg-topbar: rgba(255, 255, 255, 0.8);
  --bg-glass: rgba(0, 0, 0, 0.02);
  --border-glass: 1px solid rgba(0, 0, 0, 0.05);

  --text-primary: #12141a;
  --text-secondary: #646a7e;
  --text-muted: #a0a5b8;

  --border-color: rgba(0, 0, 0, 0.08);

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.08);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.1);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

a {
  color: var(--accent-secondary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: #55efc4;
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Layout & Sidebar ---------- */
.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: var(--border-glass);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  transition: var(--transition);
  backdrop-filter: var(--blur);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
  border-bottom: var(--border-glass);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--accent-primary);
  letter-spacing: -0.5px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-brand-text {
  display: none;
}

.sidebar-toggle {
  background: var(--bg-glass);
  border: var(--border-glass);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.sidebar-toggle:hover {
  background: var(--accent-primary);
  color: #fff;
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  overflow-y: auto;
  list-style: none;
}

.sidebar-nav li {
  margin-bottom: 4px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--bg-glass);
  color: var(--text-primary);
}

.sidebar-nav a.active {
  background: rgba(108, 92, 231, 0.1);
  color: var(--accent-primary);
  box-shadow: inset 0 0 0 1px rgba(108, 92, 231, 0.2);
}

.sidebar.collapsed .sidebar-nav a span {
  display: none;
}

.sidebar-footer {
  padding: 16px;
  border-top: var(--border-glass);
}

.btn-sidebar-logout {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: none;
  border: none;
  border-radius: var(--border-radius-sm);
  color: var(--accent-danger);
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-sidebar-logout:hover {
  background: rgba(255, 118, 117, 0.1);
}

.sidebar.collapsed .btn-sidebar-logout span {
  display: none;
}

/* ---------- Topbar Replacement (Light version for mobile/actions) ---------- */
.topbar {
  display: none; /* Hide on desktop, will handle in media query or JS */
}

/* ---------- Main Container ---------- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 40px 48px;
  min-height: 100vh;
  transition: var(--transition);
}

.sidebar.collapsed + .main {
  margin-left: var(--sidebar-collapsed-width);
}

@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    width: 280px;
  }
  .main {
    margin-left: 0 !important;
    padding: 80px 20px 40px;
  }
}

.main.narrow {
  max-width: 520px;
}

.main.medium {
  max-width: 800px;
}

/* ---------- Page Header ---------- */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-header h1 svg {
  color: var(--accent-primary);
  flex-shrink: 0;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  transition: var(--transition);
}

.card:hover {
  border-color: rgba(108, 92, 231, 0.3);
  box-shadow: var(--shadow-glow);
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--bg-card);
  border: var(--border-glass);
  border-radius: var(--border-radius);
  padding: 24px;
  backdrop-filter: var(--blur);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.kpi-card:hover {
  transform: translateY(-4px);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow);
  border-color: rgba(108, 92, 231, 0.3);
}

.kpi-icon {
  width: 42px;
  height: 42px;
  background: var(--bg-glass);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--accent-primary);
  margin-bottom: 4px;
}

.kpi-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.2px;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-primary);
}

.kpi-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Tables ---------- */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  margin-bottom: 24px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table caption {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

thead th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-color);
}

tbody td {
  padding: 12px 16px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Checkbox row */
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn svg {
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.btn-danger {
  background: rgba(255, 107, 107, 0.1);
  color: var(--accent-danger);
  border: 1px solid rgba(255, 107, 107, 0.2);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(255, 107, 107, 0.2);
  border-color: var(--accent-danger);
}

.btn-success {
  background: rgba(0, 184, 148, 0.1);
  color: var(--accent-success);
  border: 1px solid rgba(0, 184, 148, 0.2);
}

.btn-success:hover:not(:disabled) {
  background: rgba(0, 184, 148, 0.2);
  border-color: var(--accent-success);
}

.btn-accent { background: var(--accent-primary); color: #fff; border: 1px solid rgba(255, 255, 255, 0.1); } .btn-accent:hover:not(:disabled) { background: var(--accent-primary-hover); transform: translateY(-1px); box-shadow: 0 4px 15px rgba(108, 92, 231, 0.35); } .btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

/* ---------- Notices ---------- */
.notice {
  position: fixed;
  top: 76px;
  right: 24px;
  z-index: 9999;
  padding: 14px 24px;
  border-radius: var(--border-radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.notice-ok {
  background: rgba(0, 184, 148, 0.15);
  border: 1px solid rgba(0, 184, 148, 0.3);
  color: var(--accent-success);
}

.notice-err {
  background: rgba(255, 107, 107, 0.15);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--accent-danger);
}

.notice-warn {
  background: rgba(253, 203, 110, 0.15);
  border: 1px solid rgba(253, 203, 110, 0.3);
  color: var(--accent-warning);
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(-20px); }
}

.main > * {
  animation: fadeIn 0.5s ease backwards;
}

.main > *:nth-child(2) { animation-delay: 0.1s; }
.main > *:nth-child(3) { animation-delay: 0.2s; }
.main > *:nth-child(4) { animation-delay: 0.3s; }

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* The original slideOut keyframe is replaced by the new one above */

/* ---------- Auth Pages (Login / Cadastro) ---------- */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 32px;
}

.auth-card .auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-card .auth-links {
  display: flex;
  justify-content: space-between;
  margin-top: 16px;
  font-size: 0.85rem;
}

/* ---------- Section Titles ---------- */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* ---------- Filter Bar ---------- */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-bar .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 150px;
}

.filter-bar .btn {
  align-self: flex-end;
}

@media (max-width: 600px) {
  .filter-bar {
    flex-direction: column;
  }

  .filter-bar .form-group {
    min-width: 100%;
  }
}

/* ---------- Charts ---------- */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  overflow: hidden;
}

/* Previne que o canvas do Chart.js expanda infinitamente — Ajuste para MacBook M4 */
.chart-card canvas {
  max-height: 280px !important;
  width: 100% !important;
}

.chart-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}

/* ---------- Admin Nav Links ---------- */
.admin-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.admin-link-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 20px 24px;
  color: var(--text-primary);
  text-decoration: none;
  transition: var(--transition);
}

.admin-link-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  color: var(--text-primary);
}

.admin-link-card .icon {
  font-size: 1.6rem;
  color: var(--accent-primary);
  display: flex;
}

.admin-link-card .info h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.admin-link-card .info p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ---------- Badge ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-admin {
  background: rgba(108, 92, 231, 0.15);
  color: var(--accent-primary);
}

.badge-gestor {
  background: rgba(0, 206, 201, 0.15);
  color: var(--accent-secondary);
}

.badge-motorista {
  background: rgba(253, 203, 110, 0.15);
  color: var(--accent-warning);
}

.badge-ativo {
  background: rgba(0, 184, 148, 0.15);
  color: var(--accent-success);
}

.badge-inativo {
  background: rgba(255, 107, 107, 0.15);
  color: var(--accent-danger);
}

.badge-em-andamento {
  background: rgba(253, 203, 110, 0.18);
  color: var(--accent-warning);
}

.badge-finalizada {
  background: rgba(0, 184, 148, 0.15);
  color: var(--accent-success);
}

/* Row highlight for in-progress trips */
.row-em-andamento {
  background: rgba(253, 203, 110, 0.06);
}

.row-em-andamento:hover {
  background: rgba(253, 203, 110, 0.12) !important;
}

/* KPI highlight card */
.kpi-card-highlight {
  border-color: var(--accent-warning);
}

.kpi-card-highlight::before {
  background: var(--accent-warning) !important;
}

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 3rem;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state .icon svg {
  width: 48px;
  height: 48px;
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.9rem;
}

/* ---------- Divider ---------- */
.divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 32px 0;
}

/* ---------- Form Section ---------- */
.form-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 24px;
}

.form-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--accent-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-section h2 svg {
  color: var(--accent-secondary);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

.modal-content h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ---------- Spinner ---------- */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-center {
  display: flex;
  justify-content: center;
  padding: 48px;
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ---------- Utilities ---------- */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-secondary);
}

.text-danger {
  color: var(--accent-danger);
}

.text-success {
  color: var(--accent-success);
}

.mt-8 {
  margin-top: 8px;
}

.mt-16 {
  margin-top: 16px;
}

.mt-24 {
  margin-top: 24px;
}

.mb-8 {
  margin-bottom: 8px;
}

.mb-16 {
  margin-bottom: 16px;
}

.mb-24 {
  margin-bottom: 24px;
}

.gap-12 {
  gap: 12px;
}

.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.flex-wrap {
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}

/* ---------- Select Styling ---------- */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239498a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Action buttons in tables ---------- */
.action-btns {
  display: flex;
  gap: 6px;
}

.action-btns .btn {
  padding: 4px 10px;
}

/* ---------- Highlight value ---------- */
.highlight-value {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(108, 92, 231, 0.1);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-primary);
}.maintenance-badges { display: flex; flex-direction: column; gap: 4px; }
.checklist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 8px; }

.btn-group-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.ml-16 { margin-left: 16px; }
.cursor-pointer { cursor: pointer; }

/* ================================================================
   RESPONSIVIDADE — Mobile, Tablet, Notebook
   ================================================================ */

/* ── Topbar Mobile (cabeçalho que aparece em telas ≤900px) ────── */
.topbar-mobile {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-secondary);
  border-bottom: var(--border-glass);
  backdrop-filter: var(--blur);
  z-index: 900;
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-primary);
}

/* ── Overlay escuro ao abrir sidebar mobile ───────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
  animation: fadeIn 0.2s ease;
}

.sidebar-overlay.active {
  display: block;
}

/* ── Breakpoint: Tablet e Mobile (≤900px) ─────────────────────── */
@media (max-width: 900px) {
  /* Mostrar topbar mobile */
  .topbar-mobile {
    display: flex;
  }

  /* Sidebar: escondida por padrão, desliza ao abrir */
  .sidebar {
    transform: translateX(-100%);
    width: 280px !important;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Main: sem margem da sidebar, com espaço para topbar */
  .main {
    margin-left: 0 !important;
    padding: 72px 16px 32px;
  }

  /* Page header: empilha título e botão em telas pequenas */
  .page-header.flex-between {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* KPIs: mínimo menor para caber em celular */
  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
  }

  /* Valor KPI menor */
  .kpi-value {
    font-size: 1.4rem;
  }

  .kpi-card {
    padding: 16px;
  }

  /* Modal: padding reduzido e margem para não encostar nas bordas */
  .modal-overlay {
    padding: 12px;
    align-items: flex-end; /* modal sobe do fundo no mobile */
  }

  .modal-content {
    padding: 20px 16px;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    max-height: 92vh;
    width: 100%;
    max-width: 100%;
  }

  /* Notice: ajustar posição no mobile */
  .notice {
    top: 68px;
    right: 12px;
    left: 12px;
    max-width: 100%;
  }

  /* Botão de ação do page-header: largura total */
  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  /* Filter-bar: já vira coluna em ≤600px, mas aqui garante */
  .filter-bar {
    flex-direction: column;
  }
  .filter-bar .form-group,
  .filter-bar .btn-group,
  .filter-bar .btn-group-row {
    width: 100%;
  }
  .filter-bar .btn {
    flex: 1;
  }

  /* btn-group: quando tem múltiplos botões */
  .btn-group {
    flex-wrap: wrap;
  }
}

/* ── Breakpoint: Apenas Mobile (≤600px) ──────────────────────── */
@media (max-width: 600px) {
  /* Título da página menor */
  .page-header h1 {
    font-size: 1.35rem;
  }

  /* KPIs: forçar 2 colunas em celular pequeno */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  .kpi-icon {
    width: 34px;
    height: 34px;
  }

  /* Gráficos: 1 coluna */
  .chart-grid {
    grid-template-columns: 1fr;
  }

  /* Form section: padding reduzido */
  .form-section {
    padding: 16px;
  }

  /* form-row: 1 coluna */
  .form-row {
    grid-template-columns: 1fr;
  }

  /* Tabelas: mostrar scroll hint + esconder colunas secundárias */
  .table-wrapper {
    border-radius: var(--border-radius-sm);
    position: relative;
  }

  /* Colunas que podem ser ocultadas no mobile */
  .col-mobile-hide {
    display: none;
  }

  /* Botões de ação na tabela: empilhar verticalmente */
  .action-btns {
    flex-direction: column;
    gap: 4px;
  }

  .action-btns .btn {
    width: 100%;
    justify-content: center;
  }

  /* Checklist: 1 coluna */
  .checklist-grid {
    grid-template-columns: 1fr;
  }

  /* Auth card: padding reduzido */
  .auth-card {
    padding: 24px 20px;
  }

  /* Btn-group: todos os botões 100% */
  .btn-group .btn {
    flex: 1;
    min-width: 120px;
  }
}

/* ── Vista de Cards para tabelas no mobile ────────────────────── */
/* Classe .table-cards: transforma <table> em lista de cards */
@media (max-width: 600px) {
  .table-cards thead {
    display: none; /* esconde cabeçalho */
  }

  .table-cards tbody tr {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    margin-bottom: 12px;
    padding: 12px;
    gap: 6px;
  }

  .table-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: none;
    font-size: 0.88rem;
    gap: 8px;
  }

  .table-cards tbody td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
    min-width: 80px;
  }

  /* Linha de ações: centralizada */
  .table-cards td[data-label="Ações"] {
    justify-content: flex-end;
    gap: 8px;
  }

  .table-cards td[data-label="Ações"]::before {
    display: none;
  }
}

/* ── Tablet landscape (768px–1024px): ajustes finos ──────────── */
@media (min-width: 601px) and (max-width: 1024px) {
  .main {
    padding: 72px 24px 32px;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .chart-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Desktop grande (≥1600px): limitar largura máxima ────────── */
@media (min-width: 1600px) {
  .main {
    max-width: 1400px;
  }
}
