/**
 * IEA Proyectos - Design System & Theme Engine
 * Variables CSS para personalización de paleta de colores y tipografía
 */

:root {
  /* Tipografía por defecto */
  --app-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Paleta IEA Institucional (Por Defecto) */
  --app-color-primary: #021F54;
  --app-color-primary-rgb: 2, 31, 84;
  --app-color-primary-hover: #0a2f73;
  --app-color-accent: #38bdf8;
  --app-color-accent-rgb: 56, 189, 248;
  --app-color-accent-hover: #0ea5e9;

  /* Superficies y Neutros */
  --app-color-bg: #0b1329;
  --app-color-surface: #ffffff;
  --app-color-surface-translucent: rgba(255, 255, 255, 0.08);
  --app-color-border: rgba(255, 255, 255, 0.14);
  --app-color-text: #0f172a;
  --app-color-text-muted: #64748b;
  --app-color-text-light: #f8fafc;

  /* Geometría y Sombras */
  --app-radius-sm: 8px;
  --app-radius: 14px;
  --app-radius-lg: 20px;
  --app-shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.45);
  --app-shadow-glow: 0 0 25px rgba(var(--app-color-accent-rgb), 0.35);
  --app-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
  font-family: var(--app-font-family);
  transition: font-family 0.2s ease, background-color 0.25s ease;
}

/* -------------------------------------------------------------
   Utilidades del Sistema de Temas
------------------------------------------------------------- */
.theme-font {
  font-family: var(--app-font-family) !important;
}

.theme-bg-primary {
  background-color: var(--app-color-primary) !important;
}

.theme-color-primary {
  color: var(--app-color-primary) !important;
}

.theme-color-accent {
  color: var(--app-color-accent) !important;
}

.btn-theme-primary {
  background: linear-gradient(135deg, var(--app-color-primary) 0%, var(--app-color-primary-hover) 100%);
  border: 1px solid rgba(var(--app-color-accent-rgb), 0.4);
  color: #ffffff !important;
  font-weight: 600;
  border-radius: var(--app-radius);
  padding: 0.75rem 1.5rem;
  transition: var(--app-transition);
  position: relative;
  overflow: hidden;
}

.btn-theme-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(var(--app-color-primary-rgb), 0.4), var(--app-shadow-glow);
  border-color: var(--app-color-accent);
}

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

.btn-theme-accent {
  background: linear-gradient(135deg, var(--app-color-accent) 0%, var(--app-color-accent-hover) 100%);
  color: #021F54 !important;
  font-weight: 700;
  border: none;
  border-radius: var(--app-radius);
  padding: 0.75rem 1.5rem;
  transition: var(--app-transition);
}

.btn-theme-accent:hover {
  transform: translateY(-2px);
  box-shadow: var(--app-shadow-glow);
}

/* Inputs Modernos con Focus Ring Dinámico */
.theme-input-group {
  position: relative;
}

.theme-input {
  border-radius: var(--app-radius);
  padding: 0.8rem 1rem 0.8rem 2.75rem;
  font-size: 0.95rem;
  background-color: rgba(255, 255, 255, 0.95);
  border: 1.5px solid #e2e8f0;
  color: #1e293b;
  transition: var(--app-transition);
}

.theme-input:focus {
  background-color: #ffffff;
  border-color: var(--app-color-accent);
  box-shadow: 0 0 0 4px rgba(var(--app-color-accent-rgb), 0.2);
  outline: none;
}

.theme-input-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #64748b;
  font-size: 1.15rem;
  pointer-events: none;
  z-index: 4;
  transition: color 0.2s ease;
}

.theme-input-group:focus-within .theme-input-icon {
  color: var(--app-color-primary);
}

/* -------------------------------------------------------------
   Panel de Personalización (Offcanvas / Modal de Apariencia)
------------------------------------------------------------- */
.theme-customizer-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--app-transition);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.theme-customizer-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: rotate(20deg) scale(1.08);
  box-shadow: var(--app-shadow-glow);
  color: var(--app-color-accent);
}

.theme-panel {
  border-radius: var(--app-radius-lg);
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* Tarjetas de Selección de Paleta */
.palette-swatch-item {
  border: 2px solid #e2e8f0;
  border-radius: var(--app-radius);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: var(--app-transition);
  background: #f8fafc;
  display: flex;
  align-items: center;
  gap: 10px;
}

.palette-swatch-item:hover {
  border-color: var(--app-color-primary);
  transform: translateY(-2px);
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.palette-swatch-item.active {
  border-color: var(--app-color-primary);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(var(--app-color-primary-rgb), 0.2);
}

.palette-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

/* Tarjetas de Selección de Fuente */
.font-option-item {
  border: 2px solid #e2e8f0;
  border-radius: var(--app-radius);
  padding: 0.7rem 0.9rem;
  cursor: pointer;
  transition: var(--app-transition);
  background: #f8fafc;
}

.font-option-item:hover {
  border-color: var(--app-color-primary);
  background: #ffffff;
  transform: translateY(-2px);
}

.font-option-item.active {
  border-color: var(--app-color-primary);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(var(--app-color-primary-rgb), 0.2);
}

/* Color Pickers Personalizados */
.custom-color-field {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: var(--app-radius);
  padding: 0.5rem 0.75rem;
}

.custom-color-field input[type="color"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  padding: 0;
}

.custom-color-field input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-field input[type="color"]::-webkit-color-swatch {
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* -------------------------------------------------------------
   Header & Navbar Global Rediseñado
------------------------------------------------------------- */
.main-navbar {
  background-color: var(--app-color-primary) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(var(--app-color-accent-rgb), 0.25);
  transition: background-color 0.3s ease, border-color 0.3s ease;
  z-index: 1030;
}

.brand-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--app-color-primary-hover) 0%, var(--app-color-accent) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #ffffff;
  box-shadow: var(--app-shadow-glow);
  flex-shrink: 0;
}

.brand-badge-header {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--app-color-accent);
  background: rgba(var(--app-color-accent-rgb), 0.15);
  border: 1px solid rgba(var(--app-color-accent-rgb), 0.3);
  border-radius: 20px;
  padding: 0.1rem 0.55rem;
  line-height: 1.2;
}

.nav-pill-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.85) !important;
  text-decoration: none !important;
  font-weight: 500;
  font-size: 0.88rem;
  transition: var(--app-transition);
}

.nav-pill-item:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff !important;
  transform: translateY(-1px);
}

.nav-pill-item.active {
  background: rgba(var(--app-color-accent-rgb), 0.22);
  color: #ffffff !important;
  font-weight: 700;
  border: 1px solid rgba(var(--app-color-accent-rgb), 0.5);
  box-shadow: 0 0 12px rgba(var(--app-color-accent-rgb), 0.25);
}

.main-content-wrapper {
  max-width: 1920px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
  width: 100%;
}

/* -------------------------------------------------------------
   Dropdown de Administrador & Perfil Ultra-Moderno
------------------------------------------------------------- */
.user-profile-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.32rem 0.85rem 0.32rem 0.4rem;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  transition: var(--app-transition);
  text-decoration: none !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.user-profile-btn:hover, 
.user-profile-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.24);
  border-color: rgba(var(--app-color-accent-rgb), 0.7);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.user-avatar-pill {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--app-color-accent) 0%, var(--app-color-primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  position: relative;
  flex-shrink: 0;
}

.user-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #10b981;
  border: 2px solid var(--app-color-primary);
  box-shadow: 0 0 4px #10b981;
}

.user-profile-menu {
  min-width: 300px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 38px -6px rgba(15, 23, 42, 0.2), 0 8px 18px -4px rgba(15, 23, 42, 0.08);
  padding: 0.6rem;
  background: #ffffff;
  animation: userMenuFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes userMenuFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.user-menu-header {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.5rem;
  border: 1px solid #e2e8f0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: #334155 !important;
  text-decoration: none !important;
  font-size: 0.88rem;
  font-weight: 500;
  transition: var(--app-transition);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.user-menu-item:hover {
  background-color: #f1f5f9;
  color: var(--app-color-primary) !important;
  transform: translateX(3px);
}

.user-menu-item.logout-item:hover {
  background-color: #fef2f2;
  color: #dc2626 !important;
}

.user-menu-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  background: rgba(var(--app-color-primary-rgb), 0.08);
  color: var(--app-color-primary);
  transition: var(--app-transition);
}

.user-menu-item:hover .user-menu-icon {
  background: var(--app-color-primary);
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(var(--app-color-primary-rgb), 0.3);
}

.user-menu-item.logout-item .user-menu-icon {
  background: #fee2e2;
  color: #dc2626;
}

.user-menu-item.logout-item:hover .user-menu-icon {
  background: #dc2626;
  color: #ffffff;
  box-shadow: 0 4px 10px rgba(220, 38, 38, 0.3);
}

.theme-preview-swatch {
  display: flex;
  gap: 3px;
  padding: 3px 5px;
  background: #ffffff;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
}

.theme-preview-swatch span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: inline-block;
}

/* -------------------------------------------------------------
   Pestañas de Módulos (Segmented Pill Tabs)
------------------------------------------------------------- */
.module-tabs-nav {
  background: #ffffff;
  padding: 0.4rem;
  border-radius: var(--app-radius);
  border: 1px solid #e2e8f0;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.module-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  border-radius: calc(var(--app-radius) - 4px);
  border: none;
  background: transparent;
  color: #64748b;
  font-weight: 600;
  font-size: 0.88rem;
  transition: var(--app-transition);
  cursor: pointer;
  text-decoration: none;
}

.module-tab-btn:hover {
  color: var(--app-color-primary);
  background: #f1f5f9;
}

.module-tab-btn.active {
  background: var(--app-color-primary);
  color: #ffffff !important;
  box-shadow: 0 4px 12px rgba(var(--app-color-primary-rgb), 0.3);
}

.module-tab-badge {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.08);
  font-weight: 700;
}

.module-tab-btn.active .module-tab-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

/* -------------------------------------------------------------
   Contenedores de Tablas Modernas y Responsive
------------------------------------------------------------- */
.modern-table-card {
  background: #ffffff;
  border-radius: var(--app-radius);
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.modern-table {
  margin-bottom: 0;
}

.modern-table thead th {
  background-color: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.modern-table tbody td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
  vertical-align: middle;
}

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

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

/* Estados de Presentación y Contenido */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.28rem 0.65rem;
  border-radius: 30px;
  line-height: 1.2;
  vertical-align: middle;
}

.badge-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.modern-table tbody td .badge,
.modern-table tbody td .badge-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.28rem 0.65rem;
  border-radius: 30px;
  box-sizing: border-box;
  height: 25px;
}

.modern-table tbody td .badge i,
.modern-table tbody td .badge-status i {
  font-size: 0.78rem;
  line-height: 1;
  vertical-align: middle;
}

/* Botones de Acción Táctil */
.action-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #475569;
  transition: var(--app-transition);
  cursor: pointer;
  text-decoration: none;
}

.action-icon-btn:hover {
  background: #f1f5f9;
  color: var(--app-color-primary);
  border-color: var(--app-color-primary);
  transform: translateY(-1px);
}

.action-icon-btn.btn-danger-soft:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}

/* -------------------------------------------------------------
   Vista Adaptativa Móvil (Mobile Cards)
------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .module-tabs-nav {
    width: 100%;
  }

  .module-tab-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
  }
}

/* -------------------------------------------------------------
   Sistema Híbrido: Tabla (Desktop) vs Tarjetas (Mobile/Tablet)
------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .responsive-table-mode {
    display: none !important;
  }
  .responsive-card-mode {
    display: flex !important;
    flex-direction: column;
    gap: 0.85rem;
  }
}

@media (min-width: 768px) {
  .responsive-table-mode {
    display: block !important;
  }
  .responsive-card-mode {
    display: none !important;
  }
}

.data-mobile-card {
  background: #ffffff;
  border-radius: var(--app-radius);
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.04);
  padding: 1.15rem;
  position: relative;
  transition: var(--app-transition);
}

.data-mobile-card:hover {
  border-color: rgba(var(--app-color-primary-rgb), 0.3);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.data-mobile-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  padding-bottom: 0.65rem;
  border-bottom: 1px solid #f1f5f9;
}

.data-mobile-card-prop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.3rem 0;
  font-size: 0.84rem;
}

.data-mobile-card-prop .prop-label {
  color: #64748b;
  font-weight: 500;
  font-size: 0.78rem;
}

.data-mobile-card-prop .prop-value {
  color: #1e293b;
  font-weight: 600;
  text-align: right;
}

.data-mobile-card-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #f1f5f9;
  flex-wrap: wrap;
}

.data-mobile-card-actions .btn-action-touch {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: var(--app-radius-sm);
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #334155;
  text-decoration: none;
  transition: var(--app-transition);
}

.data-mobile-card-actions .btn-action-touch:hover {
  background: #f1f5f9;
  color: var(--app-color-primary);
  border-color: var(--app-color-primary);
}

.data-mobile-card-actions .btn-action-touch.btn-danger-touch:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fca5a5;
}





/* Modern Search Box */
.search-box-modern {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--app-radius);
  padding: 0.25rem 0.5rem;
  transition: var(--app-transition);
}
.search-box-modern:focus-within {
  border-color: var(--app-color-primary);
  box-shadow: 0 0 0 3px rgba(var(--app-color-primary-rgb), 0.15);
}
