:root {
  --sidebar-width: 260px;
  --header-height: 70px;
  --primary-color: #1e293b;
  --primary-dark: #334155;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --text-muted: #94a3b8;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f8fafc;
  overflow-x: hidden;
}

/* ═══════════════ HEADER ═══════════════ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, var(--sidebar-hover) 0%, var(--primary-color) 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  z-index: 1030;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: white;
}

.topbar-title h4 {
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0;
  letter-spacing: -0.02em;
}

.topbar-logo {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: white;
}

.topbar-user span {
  font-weight: 500;
  font-size: 0.95rem;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* ═══════════════ BOTÃO MENU MOBILE ═══════════════ */
/* ✅ ESCONDIDO por padrão no desktop — deve vir ANTES do @media */
.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.75rem;
  cursor: pointer;
  padding: 0.5rem;
  line-height: 1;
}

/* ═══════════════ SIDEBAR ═══════════════ */
.sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  background: var(--sidebar-bg);
  padding: 1.5rem 0;
  overflow-y: auto;
  z-index: 1020;
  transition: transform 0.3s ease;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

.sidebar a {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.sidebar a:hover {
  background: var(--sidebar-hover);
  color: white;
  border-left-color: var(--primary-color);
  padding-left: 1.75rem;
}

.sidebar a.active {
  background: var(--sidebar-hover);
  color: white;
  border-left-color: var(--primary-color);
}

.sidebar a i {
  font-size: 1.25rem;
  width: 24px;
  text-align: center;
}

.sidebar-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 1rem 1.5rem;
}

.sidebar-label {
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 1.5rem;
  margin: 1.5rem 0 0.5rem;
}

/* ═══════════════ CONTENT ═══════════════ */
.content {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  padding: 2rem;
  min-height: calc(100vh - var(--header-height) - 60px);
  animation: fadeIn 0.4s ease;
}

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

/* ═══════════════ FOOTER ═══════════════ */
footer {
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  background: white;
  border-top: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 0.875rem;
}

/* ═══════════════ CARDS ═══════════════ */
.card {
  border: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-2px);
}

/* ═══════════════ BUTTONS ═══════════════ */
.btn {
  font-weight: 500;
  border-radius: 8px;
  padding: 0.5rem 1.25rem;
  transition: all 0.2s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
  border: none;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* ═══════════════ PAGINAÇÃO ═══════════════ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 2rem 0;
}

.pagination a, .pagination strong {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.pagination a {
  color: #4a5568;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
}

.pagination a:hover {
  background-color: #f7fafc;
  border-color: #cbd5e0;
  color: #2d3748;
  transform: translateY(-1px);
}

.pagination strong {
  color: #ffffff;
  background-color: #4299e1;
  border: 1px solid #4299e1;
}

.pagination a.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.pagination-info {
  text-align: center;
  font-size: 0.9rem;
  color: #718096;
  margin: 1rem 0 2rem 0;
  padding: 0.5rem 1.5rem;
  background-color: #f7fafc;
  border-radius: 2rem;
  display: inline-block;
}

/* ═══════════════ TABLET ═══════════════ */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
  }
  .content {
    padding: 1.5rem;
  }
}

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

  .mobile-menu-toggle { display: block !important; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); z-index: 1025; }

  .content, footer { margin-left: 0; }

  /* ── Topbar mobile ── */
  .topbar { padding: 0 0.875rem; gap: 0.5rem; }

  .topbar-title { flex: 0; }
  .topbar-title h4 { display: none; }

  .topbar-logo {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .topbar-user { gap: 0.5rem; }
  .topbar-user span {
    display: block !important;
    font-size: 0.78rem;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .user-avatar { width: 32px; height: 32px; font-size: 0.8rem; }

  /* ── Conteúdo ── */
  .content { padding: 1rem; }

  .form-control, .form-select {
    font-size: 0.9rem;
    min-height: unset;
    height: auto;
    padding: 0.4rem 0.75rem;
  }

  .btn { padding: 0.5rem 0.875rem; font-size: 0.875rem; }

  footer { text-align: center; flex-direction: column; gap: 0.5rem; }

  h1 { font-size: 1.4rem; }

  .pagination a, .pagination strong {
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.85rem;
  }

  /* ── Viatura detail ── */
  .viatura-detail-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem;
    gap: 0.875rem;
  }

  .viatura-avatar { display: none; }

  .viatura-detail-header h5 {
    font-size: 1.1rem;
    word-break: break-word;
  }

  .viatura-detail-header p { font-size: 0.75rem; }

  .header-actions { width: 100%; display: flex; gap: 0.5rem; }

  .btn-header-edit,
  .btn-header-delete {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 0;
    font-size: 0.82rem;
    border-radius: 10px;
  }

  .viatura-detail-body { padding: 1rem; }
  .doc-card-header { padding: 1rem 1.25rem; flex-wrap: wrap; gap: 0.5rem; }
  .doc-card-body { padding: 1rem; }
}
