/* ==========================================================================
   CENTRO COMERCIAL POPULAR LOS COMUNEROS - PROPIEDAD HORIZONTAL
   SISTEMA DE GESTIÓN DEL RÉGIMEN SANCIONATORIO (SGS)
   Estilos CSS Profesionales e Institucionales (UX/UI y Accesibilidad)
   ========================================================================== */

:root {
  /* Paleta Institucional Los Comuneros */
  --primary: #0b2545;
  --primary-light: #134074;
  --primary-dark: #081a30;
  --secondary: #009fe3;
  --secondary-light: #48cae4;
  --accent-gold: #fdb913;
  --accent-orange: #f77f00;
  --danger: #d90429;
  --danger-light: #ff4d6d;
  --success: #10b981;
  --warning: #f59e0b;
  --info: #0284c7;

  /* Colores de Fondo y Superficie */
  --bg-main: #f4f7fb;
  --bg-card: #ffffff;
  --bg-sidebar: #0b2545;
  --bg-header: #ffffff;
  --border-color: #e2e8f0;
  --border-focus: #009fe3;

  /* Tipografía y Textos */
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #f8fafc;
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;

  /* Sombras y Efectos */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Modo Oscuro Opcional */
[data-theme="dark"] {
  --bg-main: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #090e1a;
  --bg-header: #1e293b;
  --border-color: #334155;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
}

/* Reseteo y Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* Estructura del Layout Principal */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Barra Lateral (Sidebar) */
.sidebar {
  width: 280px;
  background: var(--bg-sidebar);
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  transition: var(--transition);
  z-index: 100;
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--secondary), var(--accent-gold));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 20px;
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 159, 227, 0.4);
}

.brand-text h2 {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.5px;
  line-height: 1.2;
  text-transform: uppercase;
  color: #ffffff;
}

.brand-text span {
  font-size: 11px;
  color: var(--secondary-light);
  font-weight: 600;
}

.sidebar-user-card {
  margin: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  color: white;
  border: 2px solid var(--accent-gold);
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-info .user-name {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info .user-role-badge {
  display: inline-block;
  font-size: 10px;
  background: var(--secondary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
}

.menu-category {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.45);
  font-weight: 700;
  margin: 16px 0 8px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: var(--transition);
  cursor: pointer;
  margin-bottom: 3px;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(3px);
}

.nav-item.active {
  background: linear-gradient(90deg, var(--secondary) 0%, rgba(0, 159, 227, 0.6) 100%);
  color: #ffffff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 159, 227, 0.3);
}

.nav-item .nav-icon {
  font-size: 17px;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
}

/* Contenido Principal */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  height: 100vh;
}

/* Cabecera Superior (Navbar) */
.top-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

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

.header-title h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
}

.header-title p {
  font-size: 12px;
  color: var(--text-muted);
}

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

.role-switcher-select {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.role-switcher-select:focus {
  border-color: var(--secondary);
}

/* Área de Vistas Dinámicas */
.content-area {
  padding: 28px;
  flex: 1;
}

/* Tarjetas y Contenedores */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-bottom: 24px;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Grilla de Métricas (KPIs) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  border-left: 4px solid var(--primary);
}

.kpi-card.kpi-primary { border-left-color: var(--primary); }
.kpi-card.kpi-secondary { border-left-color: var(--secondary); }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-danger { border-left-color: var(--danger); }
.kpi-card.kpi-success { border-left-color: var(--success); }

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(11, 37, 69, 0.08);
  color: var(--primary);
}

.kpi-primary .kpi-icon { background: rgba(11, 37, 69, 0.1); color: var(--primary); }
.kpi-secondary .kpi-icon { background: rgba(0, 159, 227, 0.1); color: var(--secondary); }
.kpi-warning .kpi-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.kpi-danger .kpi-icon { background: rgba(217, 4, 41, 0.1); color: var(--danger); }
.kpi-success .kpi-icon { background: rgba(16, 185, 129, 0.1); color: var(--success); }

.kpi-info h4 {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.kpi-info .kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
  margin-top: 4px;
}

.kpi-info .kpi-detail {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Tablas de Datos */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.custom-table th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
}

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

.custom-table tbody tr:hover {
  background: rgba(0, 159, 227, 0.03);
}

/* Badges de Estados Procesales */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.badge-reportado { background: #e0f2fe; color: #0369a1; }
.badge-notificado { background: #fef3c7; color: #b45309; }
.badge-descargos { background: #ede9fe; color: #6d28d9; }
.badge-evaluacion { background: #ffedd5; color: #c2410c; }
.badge-sancionado { background: #fee2e2; color: #b91c1c; }
.badge-recurso { background: #fdf2f8; color: #be185d; }
.badge-cerrado { background: #dcfce7; color: #15803d; }
.badge-archivado { background: #f1f5f9; color: #475569; }

.badge-leve { background: #e0f2fe; color: #0284c7; }
.badge-grave { background: #fef3c7; color: #d97706; }
.badge-gravisima { background: #fee2e2; color: #dc2626; }

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-family: inherit;
}

.btn:active {
  transform: scale(0.98);
}

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

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover {
  background: #008cc9;
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover {
  background: #059669;
}

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover {
  background: #b90322;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: #f1f5f9;
  border-color: var(--text-muted);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* Formularios */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

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

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

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

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13.5px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 3px rgba(0, 159, 227, 0.15);
}

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

/* Modales */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 37, 69, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px);
  transition: var(--transition);
}

.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

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

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background: #f8fafc;
}

/* Línea de Tiempo del Expediente (Workflow Timeline) */
.timeline {
  position: relative;
  padding-left: 30px;
  margin: 20px 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 24px;
}

.timeline-point {
  position: absolute;
  left: -30px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--secondary);
  box-shadow: var(--shadow-sm);
}

.timeline-item.completed .timeline-point {
  background: var(--success);
  border-color: var(--success);
}

.timeline-item.active .timeline-point {
  background: var(--accent-gold);
  border-color: var(--primary);
  animation: pulse 2s infinite;
}

.timeline-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
}

.timeline-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
}

.timeline-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Formato de Documentos Oficiales e Impresión */
.document-paper {
  background: white;
  color: #1a1a1a;
  padding: 40px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  box-shadow: var(--shadow-lg);
  max-width: 800px;
  margin: 0 auto 30px auto;
  font-family: 'Times New Roman', Times, serif;
  line-height: 1.6;
}

.doc-header {
  text-align: center;
  border-bottom: 2px solid #0b2545;
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.doc-header h2 {
  font-size: 16px;
  font-weight: bold;
  color: #0b2545;
  text-transform: uppercase;
}

.doc-header p {
  font-size: 12px;
  color: #4b5563;
  margin: 2px 0;
}

.doc-body {
  font-size: 13.5px;
  text-align: justify;
}

.doc-body h3 {
  font-size: 14px;
  text-align: center;
  margin: 20px 0 10px 0;
  text-transform: uppercase;
}

.doc-footer {
  margin-top: 40px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.signature-box {
  text-align: center;
  border-top: 1px solid #1a1a1a;
  width: 240px;
  padding-top: 6px;
  font-size: 12px;
}

.doc-hash-stamp {
  font-family: monospace;
  font-size: 9.5px;
  color: #6b7280;
  border: 1px dashed #9ca3af;
  padding: 6px;
  border-radius: 4px;
}

/* Toast Alerts */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  box-shadow: var(--shadow-xl);
  border-left: 4px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.3s ease-out;
}

.toast-success { border-left-color: var(--success); }
.toast-danger { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

/* Animaciones */
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 159, 227, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(0, 159, 227, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 159, 227, 0); }
}

/* Reglas de Impresión */
@media print {
  body {
    background: white;
    color: black;
  }
  .sidebar, .top-header, .no-print, .btn, .modal-backdrop {
    display: none !important;
  }
  .main-wrapper, .content-area {
    padding: 0;
    overflow: visible;
    height: auto;
  }
  .document-paper {
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
  }
}

/* Responsive */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -280px;
    height: 100vh;
  }
  .sidebar.mobile-open {
    left: 0;
  }
  .top-header {
    padding: 12px 16px;
  }
  .content-area {
    padding: 16px;
  }
}
