:root {
  --color-primary: #0d3b66;
  --color-primary-light: #1b4d7e;
  --color-primary-dark: #072542;
  --color-accent: #f4a261;
  --color-accent-hover: #e76f51;
  
  --color-bg-base: #0f172a;
  --color-bg-surface: #1e293b;
  --color-bg-surface-elevated: #334155;
  --color-border: #475569;
  
  --color-text-main: #f8fafc;
  --color-text-muted: #94a3b8;
  --color-text-inverse: #0f172a;

  --color-status-registrado: #38bdf8;
  --color-status-asignado: #818cf8;
  --color-status-proceso: #fbbf24;
  --color-status-derivacion: #c084fc;
  --color-status-resuelto: #4ade80;
  --color-status-cerrado: #94a3b8;

  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --transition-smooth: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--color-bg-base);
  color: var(--color-text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* Layout Principal */
.app-container {
  display: grid;
  grid-template-columns: 280px 1fr;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Institucional */
.sidebar {
  background-color: var(--color-bg-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  gap: 1.5rem;
}

.institutional-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.institutional-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--color-primary-light), var(--color-accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.2rem;
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

.institutional-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.institutional-title span {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.inbox-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition-smooth);
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: var(--color-bg-surface-elevated);
  color: var(--color-text-main);
}

.nav-item.active {
  background-color: var(--color-primary-light);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

.nav-badge {
  background-color: var(--color-bg-base);
  color: var(--color-accent);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
}

/* Área de Contenido Principal */
.main-content {
  display: grid;
  grid-template-rows: 72px 1fr;
  height: 100vh;
  overflow: hidden;
  background-color: var(--color-bg-base);
}

.top-bar {
  background-color: var(--color-bg-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  border: 2px solid var(--color-border);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 420px 1fr;
  height: 100%;
  overflow: hidden;
}

/* Panel de Lista de Casos (Inbox) */
.cases-inbox-panel {
  border-right: 1px solid var(--color-border);
  background-color: var(--color-bg-surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.cases-scroll-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.case-card {
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.case-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.case-card.selected {
  border-color: var(--color-primary-light);
  background-color: rgba(27, 77, 126, 0.15);
}

.case-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.case-code {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-accent);
}

.status-tag {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
}

.case-title {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  line-height: 1.3;
}

.case-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Panel de Detalle y Expediente del Caso */
.case-detail-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow-y: auto;
  padding: 2rem;
  background-color: var(--color-bg-base);
}

.detail-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.timeline-novedades {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.timeline-item {
  position: relative;
  padding-left: 2rem;
  border-left: 2px solid var(--color-border);
}

.timeline-dot {
  position: absolute;
  left: -7px;
  top: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--color-accent);
}

.timeline-content {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Botones */
.btn-primary {
  background-color: var(--color-primary-light);
  color: #ffffff;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

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

.btn-accent {
  background-color: var(--color-accent);
  color: var(--color-text-inverse);
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-accent:hover {
  background-color: var(--color-accent-hover);
}

.btn-secondary {
  background-color: var(--color-bg-surface-elevated);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  padding: 0.55rem 1rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-secondary:hover {
  background-color: var(--color-border);
}

/* Modales Institucionales */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  width: 100%;
  max-width: 580px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

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

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--color-bg-base);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-input, .form-select, .form-textarea {
  background-color: var(--color-bg-base);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition-smooth);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary-light);
  box-shadow: 0 0 0 2px rgba(27, 77, 126, 0.25);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

/* Vistas de Dashboard y Métricas */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

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

.metric-card-value {
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 0.25rem;
  color: var(--color-accent);
}

.badge-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ==========================================================================
   WIDGET FLOTANTE TIPO WHATSAPP — COPILOTO DE SOPORTE GAMEA
   ========================================================================== */
.whatsapp-widget-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(37, 211, 102, 0.4), var(--shadow-lg);
  cursor: pointer;
  z-index: 999;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.whatsapp-widget-btn:hover {
  transform: scale(1.08) translateY(-2px);
}

.whatsapp-badge-pulse {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background-color: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--color-bg-base);
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Ventana de Chat Tipo WhatsApp */
.chat-window {
  position: fixed;
  bottom: 6.5rem;
  right: 2rem;
  width: 380px;
  height: 540px;
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  animation: slide-up 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-window.active {
  display: flex;
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-header {
  background: linear-gradient(135deg, #128C7E, #075E54);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #ffffff;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-agent-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #25D366;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.4);
}

.chat-title-group h4 {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.2;
}

.chat-status-indicator {
  font-size: 0.75rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.chat-status-dot {
  width: 8px;
  height: 8px;
  background-color: #4ade80;
  border-radius: 50%;
}

.chat-body-messages {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background-color: #0b141a;
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 0);
  background-size: 16px 16px;
}

.chat-bubble {
  max-width: 85%;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.35;
  position: relative;
}

.chat-bubble.bot {
  align-self: flex-start;
  background-color: #202c33;
  color: #e9edef;
  border-top-left-radius: 2px;
}

.chat-bubble.user {
  align-self: flex-end;
  background-color: #005c4b;
  color: #e9edef;
  border-top-right-radius: 2px;
}

.chat-bubble-time {
  font-size: 0.65rem;
  color: #8696a0;
  text-align: right;
  margin-top: 0.25rem;
}

.chat-footer-input {
  background-color: #202c33;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.chat-text-input {
  flex: 1;
  background-color: #2a3942;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  color: #e9edef;
  font-size: 0.88rem;
  outline: none;
}

.chat-send-btn {
  background: none;
  border: none;
  color: #25D366;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem;
  border-radius: 50%;
  transition: transform 0.15s ease;
}

.chat-send-btn:hover {
  transform: scale(1.15);
}
