/* ==========================================================
   Workslean V-Inspection — Design System
   Baseado no Manual de Marca Workslean v1.0
   ========================================================== */

:root {
  /* Cores Primárias */
  --azul-primario: #1430D0;
  --roxo-destaque: #8975FF;
  
  /* Cores Secundárias */
  --azul-brilhante: #1296F0;
  --ciano-claro: #1DCDFE;
  --ciano-profundo: #0A9AC3;
  
  /* Cores de Suporte */
  --azul-noturno: #1A2B5F;
  --branco: #FFFFFF;
  --cinza-claro: #DBE1EF;
  --cinza-bg: #F3F5FA;
  
  /* Texto */
  --texto-primario: #1F2937;
  --texto-secundario: #6B7280;
  --texto-terciario: #9CA3AF;
  
  /* Status */
  --verde-sucesso: #10B981;
  --amarelo-alerta: #F59E0B;
  --vermelho-erro: #EF4444;
  --azul-info: #3B82F6;
  
  /* Gradientes */
  --grad-primario: linear-gradient(90deg, #1430D0, #8975FF);
  --grad-secundario: linear-gradient(90deg, #0A9AC3, #1DCDFE);
  
  /* Tipografia */
  --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  
  /* Espaçamento */
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --transition: all 0.2s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }
body {
  font-family: var(--font-family);
  background: var(--cinza-bg);
  color: var(--texto-primario);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--azul-brilhante); text-decoration: none; }
a:hover { color: var(--azul-primario); }

/* ==========================================================
   LAYOUT — Sidebar + Main
   ========================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--azul-noturno);
  color: var(--branco);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo img {
  height: 32px;
  width: auto;
}

.sidebar-logo h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sidebar-logo span {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.6;
  display: block;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section {
  margin-bottom: 24px;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.4;
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.7);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
}

.nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--branco);
}

.nav-link.active {
  background: var(--azul-primario);
  color: var(--branco);
}

.nav-link .icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-link .badge {
  margin-left: auto;
  background: var(--roxo-destaque);
  color: var(--branco);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--roxo-destaque);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.sidebar-user .info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .info .name {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .info .role {
  font-size: 0.65rem;
  opacity: 0.5;
  text-transform: capitalize;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* Header */
.main-header {
  height: var(--header-height);
  background: var(--branco);
  border-bottom: 1px solid var(--cinza-claro);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--azul-noturno);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Page content */
.page-content {
  padding: 28px 32px;
}

/* ==========================================================
   COMPONENTES — Cards
   ========================================================== */
.card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--cinza-claro);
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--cinza-claro);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--azul-noturno);
}

.card-body {
  padding: 24px;
}

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cinza-claro);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Stats cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--cinza-claro);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-card .stat-icon.blue { background: rgba(20,48,208,0.1); color: var(--azul-primario); }
.stat-card .stat-icon.green { background: rgba(16,185,129,0.1); color: var(--verde-sucesso); }
.stat-card .stat-icon.yellow { background: rgba(245,158,11,0.1); color: var(--amarelo-alerta); }
.stat-card .stat-icon.red { background: rgba(239,68,68,0.1); color: var(--vermelho-erro); }
.stat-card .stat-icon.purple { background: rgba(137,117,255,0.1); color: var(--roxo-destaque); }

.stat-card .stat-info h4 {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--texto-secundario);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-card .stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--azul-noturno);
  line-height: 1;
}

/* ==========================================================
   COMPONENTES — Botões
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font-family);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background: var(--grad-primario);
  color: var(--branco);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-secondary {
  background: var(--branco);
  color: var(--azul-noturno);
  border: 1px solid var(--cinza-claro);
}
.btn-secondary:hover { background: var(--cinza-bg); }

.btn-success {
  background: var(--verde-sucesso);
  color: var(--branco);
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--vermelho-erro);
  color: var(--branco);
}
.btn-danger:hover { opacity: 0.9; }

.btn-warning {
  background: var(--amarelo-alerta);
  color: var(--branco);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  padding: 8px;
  width: 36px;
  height: 36px;
}

/* ==========================================================
   COMPONENTES — Formulários
   ========================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--azul-noturno);
  margin-bottom: 6px;
}

.form-label .required { color: var(--vermelho-erro); }

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.875rem;
  font-family: var(--font-family);
  color: var(--texto-primario);
  background: var(--branco);
  border: 1px solid var(--cinza-claro);
  border-radius: var(--radius);
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--azul-primario);
  box-shadow: 0 0 0 3px rgba(20,48,208,0.1);
}

.form-control::placeholder { color: var(--texto-terciario); }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--texto-terciario);
  margin-top: 4px;
}

/* ==========================================================
   COMPONENTES — Tabela
   ========================================================== */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table thead th {
  background: var(--cinza-bg);
  color: var(--azul-noturno);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--cinza-claro);
  white-space: nowrap;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--cinza-claro);
  vertical-align: middle;
}

.table tbody tr:hover { background: rgba(20,48,208,0.02); }

.table tbody tr:last-child td { border-bottom: none; }

/* ==========================================================
   COMPONENTES — Badges e Status
   ========================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-rascunho { background: #E5E7EB; color: #4B5563; }
.badge-em_preenchimento { background: #DBEAFE; color: #1E40AF; }
.badge-em_aprovacao { background: #FEF3C7; color: #92400E; }
.badge-aprovado { background: #D1FAE5; color: #065F46; }
.badge-emitido { background: #C7D2FE; color: #3730A3; }
.badge-reprovado { background: #FEE2E2; color: #991B1B; }
.badge-devolvido { background: #FFEDD5; color: #9A3412; }
.badge-cancelado { background: #F3F4F6; color: #6B7280; }

.badge-conforme { background: #D1FAE5; color: #065F46; }
.badge-nao_conforme { background: #FEE2E2; color: #991B1B; }
.badge-pendente { background: #FEF3C7; color: #92400E; }
.badge-nao_aplicavel { background: #E5E7EB; color: #4B5563; }

/* ==========================================================
   COMPONENTES — Modal
   ========================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--branco);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--cinza-claro);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--azul-noturno);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--texto-terciario);
  cursor: pointer;
  padding: 4px;
}

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--cinza-claro);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================
   COMPONENTES — Toast / Notificação
   ========================================================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--branco);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 420px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--azul-primario);
}

.toast.success { border-left-color: var(--verde-sucesso); }
.toast.error { border-left-color: var(--vermelho-erro); }
.toast.warning { border-left-color: var(--amarelo-alerta); }

.toast .toast-msg {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
}

.toast .toast-close {
  background: none;
  border: none;
  color: var(--texto-terciario);
  cursor: pointer;
  font-size: 1.1rem;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================
   COMPONENTES — Paginação
   ========================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
}

.pagination button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--cinza-claro);
  border-radius: var(--radius);
  background: var(--branco);
  color: var(--texto-secundario);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.pagination button:hover { border-color: var(--azul-primario); color: var(--azul-primario); }
.pagination button.active { background: var(--azul-primario); color: var(--branco); border-color: var(--azul-primario); }

/* ==========================================================
   COMPONENTES — Filtros
   ========================================================== */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 24px;
  padding: 16px 20px;
  background: var(--branco);
  border-radius: var(--radius-lg);
  border: 1px solid var(--cinza-claro);
}

.filters-bar .form-group { margin-bottom: 0; min-width: 160px; }
.filters-bar .form-control { padding: 8px 12px; font-size: 0.8rem; }

/* ==========================================================
   COMPONENTES — Empty state
   ========================================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--texto-terciario);
}

.empty-state .icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.4; }
.empty-state h4 { font-size: 1rem; color: var(--texto-secundario); margin-bottom: 8px; }
.empty-state p { font-size: 0.85rem; }

/* ==========================================================
   LOGIN PAGE
   ========================================================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--azul-noturno);
  background-image: linear-gradient(135deg, var(--azul-noturno) 0%, #0f1d42 100%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}

.login-card .logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-card .logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--grad-primario);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-card .logo p {
  font-size: 0.8rem;
  color: var(--texto-secundario);
  margin-top: 4px;
}

.login-card .form-control {
  padding: 12px 16px;
}

.login-card .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 0.95rem;
}

.login-error {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #991B1B;
  margin-bottom: 16px;
  display: none;
}

/* ==========================================================
   UTILITÁRIOS
   ========================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--texto-secundario); }
.text-sm { font-size: 0.8rem; }
.text-xs { font-size: 0.7rem; }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.gap-2 { gap: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none !important; }

/* ==========================================================
   RESPONSIVO
   ========================================================== */
@media (max-width: 1024px) {
  .sidebar { width: 220px; }
  :root { --sidebar-width: 220px; }
  .page-content { padding: 20px; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  :root { --sidebar-width: 0px; }
  .page-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .main-header { padding: 0 16px; }
  
  .menu-toggle { display: flex !important; }
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--azul-noturno);
  cursor: pointer;
  padding: 8px;
}

/* Charts container */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 24px;
  margin-top: 24px;
}

.chart-card {
  background: var(--branco);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--cinza-claro);
  padding: 24px;
}

.chart-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--azul-noturno);
  margin-bottom: 16px;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--cinza-claro);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--texto-secundario);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.tab:hover { color: var(--azul-primario); }
.tab.active { color: var(--azul-primario); border-bottom-color: var(--azul-primario); }

/* File upload area */
.upload-area {
  border: 2px dashed var(--cinza-claro);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

.upload-area:hover { border-color: var(--azul-primario); background: rgba(20,48,208,0.02); }

.upload-area .icon { font-size: 2rem; color: var(--texto-terciario); margin-bottom: 8px; }
.upload-area p { font-size: 0.85rem; color: var(--texto-secundario); }

/* Attachment list */
.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--cinza-bg);
  border-radius: var(--radius);
  font-size: 0.8rem;
}

.attachment-item .name { flex: 1; font-weight: 500; }
.attachment-item .size { color: var(--texto-terciario); font-size: 0.75rem; }
.attachment-item .remove-btn {
  background: none;
  border: none;
  color: var(--vermelho-erro);
  cursor: pointer;
  font-size: 1rem;
}
