/* ==========================================================================
   Tablero de Control Gestión Soporte - Design System & Styles
   Inspirado directamente en la plantilla oficial Service Desk
   ========================================================================== */

:root {
  --primary-navy: #0f172a;
  --primary-navy-light: #1e293b;
  --header-bg: #0b1528;
  --body-bg: #f1f5f9;
  --card-bg: #ffffff;
  
  --color-blue-start: #2563eb;
  --color-blue-end: #1d4ed8;
  --color-orange-start: #f97316;
  --color-orange-end: #ea580c;
  --color-green-start: #10b981;
  --color-green-end: #059669;
  --color-red-start: #ef4444;
  --color-red-end: #dc2626;

  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #ffffff;

  --border-color: #e2e8f0;
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);

  --font-heading: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

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

/* ==========================================================================
   Header Superior
   ========================================================================== */
.top-header {
  background: linear-gradient(135deg, #0b1528 0%, #112240 100%);
  color: var(--text-white);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

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

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.5);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.sub-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #93c5fd;
  text-transform: uppercase;
}

.main-title {
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.3px;
}

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

.sync-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  color: #34d399;
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-animation 2s infinite cubic-bezier(0.66, 0, 0, 1);
}

@keyframes pulse-animation {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.public-tunnel-badge {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid rgba(59, 130, 246, 0.5);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 6px;
}

.public-tunnel-badge a {
  color: #60a5fa;
  text-decoration: none;
  font-weight: 600;
}

.public-tunnel-badge a:hover {
  text-decoration: underline;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius-sm);
  padding: 3px;
  gap: 2px;
}

.nav-tab {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover {
  color: #ffffff;
}

.nav-tab.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-refresh {
  background: #2563eb;
  color: #ffffff;
  border: none;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}

.btn-refresh:hover {
  background: #1d4ed8;
}

.btn-refresh:active {
  transform: scale(0.97);
}

.btn-refresh.spinning i {
  animation: spin 1s linear infinite;
}

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

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px 4px 4px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: #3b82f6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 14px;
}

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

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #ffffff;
}

.user-role {
  font-size: 10px;
  color: #94a3b8;
}

/* ==========================================================================
   Toolbar de Filtros
   ========================================================================== */
.toolbar-section {
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 28px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.toolbar-container {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-select {
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--border-radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-select:hover {
  border-color: #cbd5e1;
}

.form-select:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.sync-countdown {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  padding: 6px 12px;
  border-radius: 16px;
}

.sync-countdown strong {
  color: #2563eb;
  font-weight: 700;
  font-family: monospace;
  font-size: 13px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
}

.btn-export-excel {
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.btn-export-excel:hover {
  background: #059669;
}

.btn-export-excel:active {
  transform: scale(0.97);
}

/* ==========================================================================
   Contenido Principal del Tablero
   ========================================================================== */
.dashboard-main {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ==========================================================================
   Tarjetas KPI (4 Cards)
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

.kpi-card {
  border-radius: var(--border-radius-md);
  padding: 18px 20px;
  color: #ffffff;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-blue {
  background: linear-gradient(135deg, #1d4ed8 0%, #2563eb 100%);
}

.card-orange {
  background: linear-gradient(135deg, #ea580c 0%, #f97316 100%);
}

.card-green {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
}

.card-red {
  background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.kpi-title {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}

.kpi-icon {
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.kpi-body {
  margin-bottom: 16px;
}

.kpi-value-container {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.kpi-number {
  font-family: var(--font-heading);
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}

.kpi-label {
  font-size: 13px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.kpi-badge-pct {
  background: rgba(255, 255, 255, 0.25);
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.kpi-footer-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.12);
  padding: 8px 12px;
  border-radius: var(--border-radius-sm);
}

.mini-pill {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mini-pill .label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.75);
}

.mini-pill strong {
  font-size: 12px;
  font-weight: 700;
}

.kpi-sub-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: rgba(0, 0, 0, 0.12);
  padding: 8px 10px;
  border-radius: var(--border-radius-sm);
}

.card-red .kpi-sub-stats {
  grid-template-columns: 1fr 1fr;
}

.sub-stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.sub-stat-item strong {
  font-size: 14px;
  font-weight: 800;
}

.sub-stat-item span {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.8);
  white-space: nowrap;
}

/* ==========================================================================
   Gráficas Principales
   ========================================================================== */
.charts-row {
  display: grid;
  grid-template-columns: 65% calc(35% - 20px);
  gap: 20px;
}

.chart-card {
  background: var(--card-bg);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  gap: 12px;
}

.chart-title-box {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chart-title-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.orange-icon {
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid #ffedd5;
}

.blue-icon {
  background: #eff6ff;
  color: #2563eb;
  border: 1px solid #dbeafe;
}

.green-icon {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #d1fae5;
}

.red-icon {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
}

.chart-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.chart-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.badge-abiertos-tag {
  background: #fff7ed;
  color: #c2410c;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.badge-cerrados-tag {
  background: #ecfdf5;
  color: #047857;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.chart-legend-custom {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.orange-dot {
  background-color: #f97316;
}

.green-dot {
  background-color: #10b981;
}

.chart-card-body {
  flex: 1;
  position: relative;
  min-height: 280px;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 280px;
}

/* ==========================================================================
   Rankings Top 5 Especialistas (Verde y Rojo)
   ========================================================================== */
.rankings-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.ranking-card {
  background: var(--card-bg);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}

.ranking-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.ranking-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ranking-title {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.ranking-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.ranking-badge-status {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.green-status {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.red-status {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.ranking-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.specialist-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.avatar-green {
  background: #d1fae5;
  color: #065f46;
}

.avatar-red {
  background: #fee2e2;
  color: #991b1b;
}

.specialist-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.specialist-name-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.specialist-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.specialist-count-badge {
  font-size: 12px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 8px;
}

.count-green {
  background: #10b981;
  color: #ffffff;
}

.count-red {
  background: #ef4444;
  color: #ffffff;
}

.specialist-progress-bg {
  width: 100%;
  height: 8px;
  background: #f1f5f9;
  border-radius: 4px;
  overflow: hidden;
}

.specialist-progress-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.bar-green {
  background: linear-gradient(90deg, #10b981, #059669);
}

.bar-red {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

.ranking-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

/* ==========================================================================
   Monitor SLA / ANS en Tiempo Real (Parte Inferior)
   ========================================================================== */
.sla-monitor-section {
  margin-bottom: 20px;
}

.sla-card {
  background: var(--card-bg);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
}

.sla-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 16px;
}

.sla-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sla-icon {
  width: 36px;
  height: 36px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sla-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.sla-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.sla-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box i {
  position: absolute;
  left: 12px;
  color: var(--text-light);
  font-size: 13px;
}

.search-box input {
  padding: 7px 14px 7px 34px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  font-size: 13px;
  background: #f8fafc;
  outline: none;
  min-width: 240px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  background: #ffffff;
}

.sla-filter-pills {
  display: flex;
  gap: 6px;
}

.filter-pill {
  border: 1px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-pill.active {
  background: #0f172a;
  color: #ffffff;
  border-color: #0f172a;
}

.danger-pill.active {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

.warning-pill.active {
  background: #d97706;
  color: #ffffff;
  border-color: #d97706;
}

.sla-table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  max-height: 400px;
  overflow-y: auto;
}

.sla-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}

.sla-table thead {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sla-table th {
  padding: 10px 14px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.sla-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-main);
  vertical-align: middle;
}

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

.badge-risk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.badge-breached {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.badge-atrisk {
  background: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
}

.time-exceeded {
  color: #dc2626;
  font-weight: 700;
}

.time-remaining {
  color: #d97706;
  font-weight: 600;
}

.table-empty-msg {
  text-align: center;
  padding: 30px !important;
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.dashboard-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  padding: 14px 28px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: auto;
}

.footer-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sep {
  color: #cbd5e1;
}

/* ==========================================================================
   Media Queries & Responsividad
   ========================================================================== */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .charts-row {
    grid-template-columns: 1fr;
  }
  .rankings-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .toolbar-container {
    flex-direction: column;
    align-items: stretch;
  }
  .sync-countdown {
    margin-left: 0;
  }
}
