/* ===================================================
   VARIABLES DE DISEÑO Y TEMA PROFESIONAL (ESTILO SAAS / SALUD)
   =================================================== */
:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #0f172a;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --border-focus: #3b82f6;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-white: #ffffff;
  
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ===================================================
   HEADER & NAVBAR
   =================================================== */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), #1e40af);
  color: var(--text-white);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--secondary);
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-tabs {
  display: flex;
  gap: 8px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: var(--radius-md);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ===================================================
   LAYOUT PRINCIPAL
   =================================================== */
.main-content {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px;
  min-height: calc(100vh - 180px);
}

.tab-panel {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

.tab-panel.active {
  display: block;
}

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

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 16px;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--secondary);
}

.panel-description {
  font-size: 0.925rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===================================================
   BADGES & CHIPS
   =================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 9999px;
}

.badge-live {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ===================================================
   FORMULARIO Y GRID
   =================================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.col-4 { grid-column: span 4; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

@media (max-width: 900px) {
  .col-4, .col-6 { grid-column: span 12; }
}

.form-section-title {
  grid-column: span 12;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

.form-section-title span {
  width: 22px;
  height: 22px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.required {
  color: var(--danger);
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #ffffff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea {
  resize: vertical;
}

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

/* TARJETA INFORMATIVA DE SLA */
.sla-card {
  background: linear-gradient(135deg, #eff6ff, #f0fdf4);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.sla-icon {
  width: 44px;
  height: 44px;
  background: var(--bg-card);
  border-radius: 50%;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.sla-info {
  flex: 1;
}

.sla-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--secondary);
}

.sla-details {
  font-size: 0.9rem;
  color: var(--primary);
  font-weight: 600;
}

.sla-tag {
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

/* BOTONES */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.925rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: var(--text-white);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

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

.btn-secondary {
  background: #f1f5f9;
  color: var(--secondary);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-success {
  background: #059669;
  color: white;
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

.btn-success:hover {
  background: #047857;
}

.w-100 {
  width: 100%;
}

.btn-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); }
}

/* ===================================================
   SECCIÓN 2: CONSULTA Y RASTREO
   =================================================== */
.search-box {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrap svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
}

.search-input-wrap input {
  padding-left: 44px;
}

.ticket-status-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  background: #f8fafc;
}

.ticket-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.ticket-code {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  font-family: monospace;
}

.ticket-sub {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--secondary);
}

.status-badge {
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 9999px;
}

.status-badge.PENDIENTE { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.status-badge.ACEPTADO { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }
.status-badge.ESCALADO { background: var(--purple-bg); color: var(--purple); border: 1px solid #ddd6fe; }
.status-badge.FINALIZADO { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }

.ticket-grid-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-item .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.info-item .value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--secondary);
}

.ticket-notes-box {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.ticket-notes-box h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--secondary);
  margin-bottom: 8px;
}

.notes-content {
  font-size: 0.875rem;
  white-space: pre-line;
  color: #475569;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 12px;
  color: #cbd5e1;
}

/* ===================================================
   SECCIÓN 3: REPORTES Y EXCEL
   =================================================== */
.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.filter-btn-wrap {
  display: flex;
  align-items: flex-end;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--secondary);
  margin-top: 4px;
}

.text-amber { color: var(--warning); }
.text-green { color: var(--success); }
.text-blue { color: var(--primary); }

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

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

.report-table th {
  background: #f1f5f9;
  color: var(--secondary);
  font-weight: 700;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.report-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: #334155;
  white-space: nowrap;
}

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

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

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 32px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-icon-success {
  width: 64px;
  height: 64px;
  background: var(--success-bg);
  color: var(--success);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 8px;
}

.modal-message {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.ticket-created-box {
  background: #f8fafc;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 24px;
}

.copy-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 8px 0;
}

.copy-box strong {
  font-size: 1.4rem;
  color: var(--primary);
  letter-spacing: 0.05em;
  font-family: monospace;
}

.btn-copy {
  padding: 4px 10px;
  font-size: 0.75rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}

.sla-sub {
  font-size: 0.8rem;
  color: #059669;
  font-weight: 600;
}

.app-footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: #ffffff;
}
