/* DESIGN SYSTEM & CUSTOM PROPERTIES */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  /* Harmonious Dark Palette (Tailored HSL) */
  --bg-main: #0b0c10;
  --bg-card: rgba(22, 24, 37, 0.7);
  --bg-card-hover: rgba(28, 30, 47, 0.8);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  /* Text colors */
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  /* Theme Accents (HSL Gradients) */
  --primary-grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --success-grad: linear-gradient(135deg, #10b981 0%, #059669 100%);
  --danger-grad: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  --accent-cyan: #22d3ee;
  
  /* Shadow Systems */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
}

/* RESET & BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  position: relative;
}

/* GRADIENT BACKGROUND BLOBS (Glassmorphism effect) */
.bg-glow {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(160px);
  z-index: -1;
  opacity: 0.45;
  pointer-events: none;
}

.bg-glow-1 {
  background: radial-gradient(circle, #4f46e5 0%, #312e81 100%);
  top: -10%;
  left: -10%;
  animation: float-slow 18s infinite alternate;
}

.bg-glow-2 {
  background: radial-gradient(circle, #7c3aed 0%, #4c1d95 100%);
  bottom: -10%;
  right: -10%;
  animation: float-slow 22s infinite alternate-reverse;
}

@keyframes float-slow {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
  100% { transform: translate(-30px, -20px) scale(0.9); }
}

/* CUSTOM SCROLLBAR */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* TYPOGRAPHY UTILITIES */
h1, h2, h3, h4 {
  font-weight: 600;
  letter-spacing: -0.02em;
}

/* ANIMATIONS */
.fade-in {
  animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* FORM ELEMENTS & INPUTS */
.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
}

label {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"],
input[type="password"],
input[type="date"],
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  background: #161825; /* Fundo sólido escuro para melhor legibilidade */
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all 0.2s ease;
  outline: none;
}

select option {
  background-color: #161825; /* Fundo escuro das opções */
  color: #f3f4f6; /* Texto claro */
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: rgba(255, 255, 255, 0.01);
  color: var(--text-muted);
  cursor: not-allowed;
  border-style: dashed;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 12px 24px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  gap: 8px;
}

.btn-primary {
  background: var(--primary-grad);
  color: white;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-success {
  background: var(--success-grad);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 16px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: underline;
  padding: 2px 6px;
}

.btn-link:hover {
  color: #67e8f9;
}

/* ALERTS */
.alert {
  padding: 14px 18px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
  animation: fadeIn 0.25s ease-out;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.hidden {
  display: none !important;
}

/* 1. SEÇÃO DE AUTHENTICAÇÃO (LOGIN / REGISTRO) */
.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  margin: 20px;
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: var(--primary-grad);
  color: white;
  font-weight: 800;
  font-size: 1.4rem;
  margin-bottom: 16px;
  box-shadow: var(--shadow-glow);
}

.auth-header h1 {
  font-size: 1.6rem;
  margin-bottom: 6px;
  color: var(--text-primary);
}

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

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

/* PASSWORD STRENGTH INDICATOR */
#password-strength-container {
  margin-top: 8px;
}

.strength-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 4px;
}

#strength-fill {
  height: 100%;
  width: 0;
  transition: width 0.3s ease, background-color 0.3s ease;
}

#strength-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* 2. ESTRUTURA DO DASHBOARD (APP LAYOUT) */
.app-layout {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 0 40px 40px 40px;
  z-index: 10;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 30px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 1.6rem;
}

.logo-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-text span {
  color: #8b5cf6;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 20px;
}

.welcome-text {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.welcome-text strong {
  color: var(--text-primary);
}

/* GRID DE METRICAS */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  backdrop-filter: blur(12px);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-icon {
  font-size: 2.2rem;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.metric-details h3 {
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.05em;
}

.metric-details p {
  font-size: 1.8rem;
  font-weight: 700;
  margin-top: 4px;
  line-height: 1;
}

/* GRADIENT BORDERS PARA METRICAS ESPECÍFICAS */
.metric-open { border-left: 4px solid #10b981; }
.metric-closed { border-left: 4px solid #3b82f6; }
.metric-high { border-left: 4px solid #ef4444; }

/* GRID DO DASHBOARD */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.1fr 2fr;
  gap: 30px;
  align-items: start;
}

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

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 30px;
  backdrop-filter: blur(12px);
}

.card-header {
  margin-bottom: 24px;
}

.card-header h2 {
  font-size: 1.35rem;
  color: var(--text-primary);
  margin-bottom: 4px;
}

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

/* GRID FORM ROWS */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* LIST CARD & FILTERS */
.list-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filter-input-wrapper input {
  padding: 10px 14px;
  font-size: 0.85rem;
  width: 200px;
  background: rgba(255, 255, 255, 0.02);
}

.filter-bar select {
  padding: 10px 14px;
  font-size: 0.85rem;
  width: auto;
  background: rgba(255, 255, 255, 0.02);
}

/* TABELA DE OS */
.list-container {
  margin-top: 10px;
  position: relative;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.os-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.os-table th {
  padding: 16px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  letter-spacing: 0.05em;
}

.os-table td {
  padding: 18px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  line-height: 1.4;
}

.os-table tbody tr {
  transition: background-color 0.15s ease;
}

.os-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

/* DETALHES DE OS EXPANDIDOS */
.os-desc-cell {
  max-width: 250px;
}

.os-number-badge {
  font-family: monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* Prioridades */
.badge-baixa {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.badge-media {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-alta {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* Statuses */
.badge-aberta {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-fechada {
  background: rgba(107, 114, 128, 0.15);
  color: #9ca3af;
  border: 1px solid rgba(107, 114, 128, 0.25);
}

/* DEPARTAMENTOS FORMATADOS */
.dept-badge {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  text-transform: capitalize;
}

/* DETALHES ADICIONAIS NA TABELA */
.os-detail-row {
  background-color: rgba(0, 0, 0, 0.2);
}

.os-detail-wrapper {
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.01);
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 24px;
}

.os-info-block h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.os-info-block p {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.os-info-block .resolution-text {
  background: rgba(0, 0, 0, 0.15);
  padding: 8px 12px;
  border-radius: 6px;
  border-left: 3px solid #10b981;
  font-style: italic;
  margin-top: 4px;
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  color: var(--text-secondary);
}

/* 3. MODAL DE FECHAMENTO */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeInOverlay 0.25s ease-out;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: #121420;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: scaleUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  margin: 20px;
}

@keyframes scaleUp {
  from { transform: scale(0.92); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

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

.modal-header h3 {
  font-size: 1.15rem;
  color: var(--text-primary);
}

.btn-close-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.6rem;
  cursor: pointer;
  line-height: 1;
}

.btn-close-icon:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.modal-footer-btns {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 30px;
}

/* RESPONSIVIDADE ADICIONAL */
@media (max-width: 768px) {
  .app-layout {
    padding: 0 16px 16px 16px;
  }
  .app-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .list-header-actions {
    flex-direction: column;
    align-items: flex-start;
  }
  .filter-bar {
    width: 100%;
  }
  .filter-input-wrapper {
    width: 100%;
  }
  .filter-input-wrapper input {
    width: 100%;
  }
}

/* NAVEGAÇÃO POR ABAS */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  width: fit-content;
  align-self: center;
}

.nav-tab {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  color: white;
  background: var(--primary-grad);
  box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
}

/* Ocultar views inativas */
.view-section {
  display: none;
  width: 100%;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Outros ajustes de formulário */
.readonly-field {
  background: rgba(255, 255, 255, 0.02) !important;
  color: var(--text-secondary) !important;
  cursor: not-allowed;
  border-style: dashed;
}
