/* ==============================================================================
   PORTAL DE DOCUMENTOS AET - SINFRA/MT - ESTILOS VISUAIS
   ============================================================================== */

:root {
  --primary: #0f2942;
  --primary-hover: #0a1c2e;
  --primary-light: #1e3a8a;
  --accent: #d97706;
  --accent-hover: #b45309;
  --accent-light: #fef3c7;
  --success: #059669;
  --success-light: #d1fae5;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Utilitários */
.hidden { display: none !important; }
.text-center { text-align: center; }
.py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }

/* Ícones */
.icon-sm { width: 16px; height: 16px; display: inline-block; vertical-align: middle; }
.icon-md { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }

/* ==================== TELA DE LOGIN ==================== */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: radial-gradient(circle at top, #1e3a8a 0%, #0f2942 100%);
}

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

.auth-header {
  text-align: center;
  margin-bottom: 2rem;
}

.sinfra-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent-hover);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.auth-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.auth-header .subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.5rem;
}

.input-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  width: 18px;
  height: 18px;
  color: var(--text-light);
}

.input-icon-wrapper input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  color: var(--text-main);
  transition: all 0.2s ease;
  outline: none;
}

.input-icon-wrapper input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.alert {
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fca5a5;
}

.btn-toggle-pwd {
  position: absolute;
  right: 0.75rem;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.2s;
}

.btn-toggle-pwd:hover {
  color: var(--primary);
}

/* ==================== BOX DE AJUDA / RECUPERAÇÃO DE SENHA ==================== */
.auth-help-box {
  margin-top: 1.5rem;
  padding: 1.125rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  text-align: left;
}

.help-box-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 0.4rem;
}

.help-icon {
  width: 16px;
  height: 16px;
  color: var(--primary);
  flex-shrink: 0;
}

.help-box-text {
  font-size: 0.775rem;
  color: #475569;
  line-height: 1.45;
  margin-bottom: 0.75rem;
}

.help-box-text strong {
  color: #1e293b;
}

.whatsapp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.875rem;
  background: #25d366;
  color: #ffffff;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(37, 211, 102, 0.2);
  transition: all 0.2s ease;
}

.whatsapp-btn:hover {
  background: #20ba5a;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 211, 102, 0.3);
}

.whatsapp-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.auth-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
  line-height: 1.4;
}

/* ==================== BOTÕES ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-block { width: 100%; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: var(--radius-sm); }

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-success {
  background: var(--success);
  color: #ffffff;
}
.btn-success:hover:not(:disabled) { background: #047857; transform: translateY(-1px); }
.btn-success:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-outline-light {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.btn-outline-light:hover { background: rgba(255, 255, 255, 0.2); }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==================== DASHBOARD ==================== */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-header {
  background: var(--primary);
  color: #ffffff;
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.sinfra-logo {
  background: #ffffff;
  color: var(--primary);
  font-weight: 800;
  font-size: 1rem;
  padding: 0.375rem 0.75rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.header-titles h2 {
  font-size: 1.125rem;
  font-weight: 700;
}

.system-tag {
  font-size: 0.75rem;
  color: #94a3b8;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.user-info {
  text-align: right;
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #ffffff;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-doc {
  font-size: 0.75rem;
  color: #94a3b8;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Conteúdo Principal */
.main-content {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Grid de Filtros */
.filter-grid {
  padding: 1.25rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.filter-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
}

.filter-group input {
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s ease;
}

.filter-group input:focus {
  border-color: var(--primary-light);
}

.filter-actions {
  display: flex;
  gap: 0.5rem;
}

/* Toolbar de Ações */
.results-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.results-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Tabela de Dados */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.th-checkbox { width: 40px; text-align: center; }
.th-action { width: 140px; text-align: center; }

/* Badges e Tags */
.aet-badge {
  display: inline-block;
  font-weight: 700;
  color: var(--primary);
  font-size: 0.9375rem;
}

.tag-placa {
  display: inline-block;
  background: #e2e8f0;
  color: #334155;
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  margin: 0.15rem 0.2rem 0.15rem 0;
  letter-spacing: 0.05em;
}

.status-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  margin-top: 0.25rem;
}

.status-vigente { background: var(--success-light); color: var(--success); }
.status-vencida { background: #f1f5f9; color: var(--text-muted); }

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-lg { max-width: 900px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}
.btn-close:hover { color: var(--danger); }

.modal-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.5rem;
  background: #f8fafc;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.log-table th, .log-table td {
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
}

/* Responsividade */
@media (max-width: 768px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
  }
  .header-user {
    width: 100%;
    justify-content: space-between;
  }
  .user-info { text-align: left; }
  .filter-grid { grid-template-columns: 1fr; }
}
