/* ==========================================================================
   SISTEMA DE DISEÑO CCLARA - ESTILOS BASE Y COMPONENTES
   Cámara de Comercio del Estado Lara
   ========================================================================== */

/* 1. Reset y Fuentes Base */
html, body {
  font-family: 'Poppins', sans-serif;
  margin: 0;
  padding: 0;
  color: #1B1C18;
  background-color: #F7F6F3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Scrollbars sutiles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(209, 208, 203, 0.2);
}
::-webkit-scrollbar-thumb {
  background: rgba(32, 45, 80, 0.25);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(32, 45, 80, 0.45);
}

.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}
.sidebar-scroll::-webkit-scrollbar-track {
  background: #202D50;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: rgba(209, 208, 203, 0.3);
  border-radius: 2px;
}

/* 2. Botones Institucionales (alto 40px, px-5, text-[13px] font-semibold, rounded-ccl) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
  border: 1px solid transparent;
}
.btn:focus-visible {
  outline: 2px solid #EF823F;
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-sm {
  height: 32px;
  padding: 0 14px;
  font-size: 12px;
  border-radius: 8px;
}
.btn-lg {
  height: 48px;
  padding: 0 24px;
  font-size: 14px;
}

/* Variantes de Botón */
.btn-primary {
  background-color: #202D50;
  color: #FFFFFF;
  border-color: #202D50;
}
.btn-primary:hover {
  background-color: #17213c;
  border-color: #17213c;
}

.btn-secondary {
  background-color: #FFFFFF;
  color: #202D50;
  border-color: #D1D0CB;
}
.btn-secondary:hover {
  background-color: rgba(231, 229, 223, 0.4);
}

.btn-danger {
  background-color: #BA0000;
  color: #FFFFFF;
  border-color: #BA0000;
}
.btn-danger:hover {
  background-color: #960000;
  border-color: #960000;
}

.btn-success {
  background-color: #006633;
  color: #FFFFFF;
  border-color: #006633;
}
.btn-success:hover {
  background-color: #004d26;
  border-color: #004d26;
}

.btn-ghost {
  background-color: transparent;
  color: #202D50;
  border-color: transparent;
}
.btn-ghost:hover {
  background-color: rgba(231, 229, 223, 0.5);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

/* 3. Campos de Formulario (alto 40px, rounded-field 8px, border-ccl-gray text-[13px]) */
.input, .select, .textarea {
  width: 100%;
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  color: #1B1C18;
  background-color: #FFFFFF;
  border: 1px solid #D1D0CB;
  border-radius: 8px;
  padding: 0 14px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  outline: none;
}
.input, .select {
  height: 40px;
}
.textarea {
  min-height: 90px;
  padding: 10px 14px;
  resize: vertical;
}

.input:focus, .select:focus, .textarea:focus {
  border-color: #202D50;
  box-shadow: 0 0 0 3px rgba(32, 45, 80, 0.15);
}

.input.error, .select.error, .textarea.error {
  border-color: #BA0000;
}
.input.error:focus, .select.error:focus, .textarea.error:focus {
  box-shadow: 0 0 0 3px rgba(186, 0, 0, 0.15);
}

.input-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #1B1C18;
  margin-bottom: 6px;
}
.input-required {
  color: #BA0000;
  margin-left: 2px;
}
.input-hint {
  font-size: 11px;
  color: #71717A;
  margin-top: 4px;
}
.input-error-msg {
  font-size: 11px;
  color: #BA0000;
  margin-top: 4px;
  display: none;
}
.has-error .input-error-msg {
  display: block;
}

/* 4. Badges de Estado (rounded-full, px-3 py-1, text-[11px] font-semibold uppercase) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-family: 'Poppins', sans-serif;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1.2;
}

.badge-green,
.badge-success {
  background-color: rgba(0, 102, 51, 0.12);
  color: #006633;
  border: 1px solid rgba(0, 102, 51, 0.22);
}
.badge-red,
.badge-danger {
  background-color: rgba(186, 0, 0, 0.12);
  color: #BA0000;
  border: 1px solid rgba(186, 0, 0, 0.22);
}
.badge-orange,
.badge-warning {
  background-color: rgba(239, 130, 63, 0.15);
  color: #c9601c;
  border: 1px solid rgba(239, 130, 63, 0.28);
}
.badge-navy,
.badge-info {
  background-color: rgba(32, 45, 80, 0.10);
  color: #202D50;
  border: 1px solid rgba(32, 45, 80, 0.20);
}
.badge-gold {
  background-color: rgba(210, 181, 137, 0.25);
  color: #8c6f3e;
  border: 1px solid rgba(210, 181, 137, 0.35);
}

/* 5. Tablas CCLARA Responsivas */
.table-container {
  background-color: #FFFFFF;
  border: 1px solid #D1D0CB;
  border-radius: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
  max-width: 100%;
  width: 100%;
}
.table-ccl {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  text-align: left;
}
.table-ccl thead th {
  background-color: rgba(231, 229, 223, 0.5);
  color: #202D50;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 14px;
  border-bottom: 1px solid #D1D0CB;
  white-space: nowrap;
}
.table-ccl tbody tr {
  border-bottom: 1px solid rgba(209, 208, 203, 0.6);
  transition: background-color 0.15s ease;
}
.table-ccl tbody tr:last-child {
  border-bottom: none;
}
.table-ccl tbody tr:hover {
  background-color: rgba(231, 229, 223, 0.3);
}
.table-ccl tbody td {
  padding: 12px 14px;
  font-size: 13px;
  color: #1B1C18;
  vertical-align: middle;
}
.table-ccl td.font-mono,
.table-ccl td .badge,
.table-ccl td .btn {
  white-space: nowrap;
}

/* 6. Tarjetas y Paneles (rounded-ccl 10px, p-6, bg-white border border-ccl-gray) */
.card-ccl {
  background-color: #FFFFFF;
  border: 1px solid #D1D0CB;
  border-radius: 10px;
  padding: 24px;
}
.card-kpi {
  background-color: #FFFFFF;
  border: 1px solid #D1D0CB;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* 7. Pestañas (Tabs) con Scroll Horizontal Táctil en Móviles */
.tabs-ccl {
  display: flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid #D1D0CB;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  flex-wrap: nowrap;
  max-width: 100%;
}
.tabs-ccl::-webkit-scrollbar {
  display: none;
}
.tab-item {
  position: relative;
  padding: 12px 4px;
  font-size: 13px;
  font-weight: 500;
  color: #71717A;
  text-decoration: none;
  cursor: pointer;
  transition: color 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-item:hover {
  color: #202D50;
}
.tab-item.active {
  color: #202D50;
  font-weight: 600;
}
.tab-item.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2.5px;
  background-color: #EF823F;
  border-radius: 2px 2px 0 0;
}

/* 8. Modales */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(32, 45, 80, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: none !important;
}
.modal-box, .modal-card, .modal-panel {
  background-color: #FFFFFF;
  border: 1px solid #D1D0CB;
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  padding: 24px;
  box-shadow: 0 20px 25px -5px rgba(32, 45, 80, 0.2), 0 10px 10px -5px rgba(32, 45, 80, 0.1);
  transform: translateY(0) scale(1);
  transition: transform 0.2s ease;
}

/* 9. Dropzone de Archivos */
.dropzone-ccl {
  border: 2px dashed #D1D0CB;
  border-radius: 8px;
  padding: 28px 20px;
  text-align: center;
  background-color: #FFFFFF;
  cursor: pointer;
  transition: all 0.15s ease;
}
.dropzone-ccl:hover, .dropzone-ccl.dragover {
  border-color: #202D50;
  background-color: rgba(231, 229, 223, 0.2);
}

/* 10. Toasts de Notificación */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast-ccl {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background-color: #202D50;
  color: #FFFFFF;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 16px rgba(32, 45, 80, 0.2);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast-ccl.show {
  opacity: 1;
  transform: translateY(0);
}

/* 11. Temas de la App del Trabajador — solo paleta oficial (manual, pág. 17)
   Claro (por defecto, "mixta"): fondo arena, barra y carnet en azul marino, tarjetas blancas.
   Oscuro ("azul institucional"): todo en azul marino; tarjetas en blanco con opacidad.
   Naranja = acento (pestaña activa, íconos); dorado = separadores; verde/rojo = solo estados.
   El tema se guarda en localStorage (cclara_app_theme) y lo aplica assets/app-theme.js.
   .app-theme = marco de la app (variables + fondo); .app-vars = solo variables (modales fuera del marco). */
.app-theme {
  background-color: var(--app-bg);
  color: var(--app-fg);
}
.app-theme,
.app-vars {
  --app-bg: #E7E5DF;
  --app-header: #202D50;
  --app-header-border: transparent;
  --app-surface: #FFFFFF;
  --app-border: #D1D0CB;
  --app-fg: #202D50;
  --app-fg-muted: rgba(32, 45, 80, 0.7);
  --app-fg-subtle: rgba(32, 45, 80, 0.5);
  --app-accent-fg: #202D50;
  --app-hero: #202D50;
  --app-hero-border: transparent;
  --app-nav: #FFFFFF;
  --app-nav-fg: rgba(32, 45, 80, 0.55);
  --app-nav-active: #202D50;
  --app-primary: #202D50;
  --app-primary-fg: #FFFFFF;
  --app-modal: #FFFFFF;
  --app-danger-fg: #BA0000;
  --app-danger-bg: transparent;
  --app-alert: #FDF6F7;
  --app-alert-border: #D89EA7;
  --app-alert-fg: #852235;
  --app-alert-body: rgba(45, 25, 32, 0.85);
}
html[data-app-theme="dark"] .app-theme,
html[data-app-theme="dark"] .app-vars {
  --app-bg: #202D50;
  --app-header: #202D50;
  --app-header-border: rgba(255, 255, 255, 0.12);
  --app-surface: rgba(255, 255, 255, 0.08);
  --app-border: rgba(255, 255, 255, 0.12);
  --app-fg: #FFFFFF;
  --app-fg-muted: rgba(255, 255, 255, 0.7);
  --app-fg-subtle: rgba(255, 255, 255, 0.5);
  --app-accent-fg: #EF823F;
  --app-hero: rgba(255, 255, 255, 0.08);
  --app-hero-border: rgba(255, 255, 255, 0.12);
  --app-nav: #202D50;
  --app-nav-fg: rgba(255, 255, 255, 0.6);
  --app-nav-active: #FFFFFF;
  --app-primary: #EF823F;
  --app-primary-fg: #202D50;
  --app-modal: #202D50;
  --app-danger-fg: #FFFFFF;
  --app-danger-bg: #BA0000;
  --app-alert: rgba(133, 34, 53, 0.28);
  --app-alert-border: rgba(217, 156, 166, 0.45);
  --app-alert-fg: #F3A9B5;
  --app-alert-body: rgba(255, 255, 255, 0.88);
}

/* Capturas para los PDF (?captura): sin los conmutadores de la demo */
.modo-captura #cclara-demo-switch,
.modo-captura #cclara-theme-switch {
  display: none !important;
}
.modo-captura .mobile-device-frame {
  border-radius: 0;
  box-shadow: none;
  max-height: none;
}

/* Marco Móvil para la App del Trabajador en Pantallas Grandes */
.mobile-device-frame {
  width: 390px;
  max-width: 100%;
  height: 844px;
  max-height: 94vh;
  background-color: var(--app-bg, #202D50);
  border-radius: 44px;
  box-shadow: 0 25px 60px -15px rgba(32, 45, 80, 0.4), 0 0 0 10px #202D50, 0 0 0 12px #D1D0CB;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
@media (max-width: 640px) {
  .mobile-device-frame {
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }
}

/* 12. Carnet Digital 3D Flip Card */
.carnet-perspective {
  perspective: 1200px;
}
.carnet-inner {
  position: relative;
  width: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}
.carnet-inner.flipped {
  transform: rotateY(180deg);
}
.carnet-face {
  position: relative;
  width: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
}
.carnet-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: rotateY(180deg);
}

/* 13. Reglas Globales de Responsividad (Móviles y Tablets) */
#layout-sidebar {
  flex-shrink: 0;
}

@media (max-width: 1023px) {
  #layout-sidebar {
    width: 0 !important;
    height: 0 !important;
    overflow: visible !important;
  }
}

/* Prevenir desbordamiento horizontal global en el contenedor principal */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

main,
main.flex-1 {
  overflow-x: hidden !important;
  max-width: 100vw !important;
  min-width: 0 !important;
  width: 100% !important;
}

.max-w-7xl,
.max-w-6xl {
  min-width: 0;
  max-width: 100%;
}

.card-ccl {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.table-container,
.overflow-x-auto {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tabs-ccl {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  border-bottom: 1px solid var(--ccl-gray);
  overflow-x: auto;
  flex-wrap: nowrap;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  width: 100%;
  min-width: 0;
}
.tabs-ccl::-webkit-scrollbar {
  display: none;
}
.tabs-ccl > * {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 768px) {
  /* Reducir padding excesivo de páginas en móviles */
  main.p-8,
  main.p-6,
  main[class*="p-8"],
  main[class*="p-6"] {
    padding: 16px !important;
  }

  /* Ajustar relleno interno de tarjetas */
  .card-ccl {
    padding: 16px !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  /* Modales seguros que no se cortan en pantallas angostas */
  .modal-card {
    width: 94% !important;
    max-width: 94% !important;
    padding: 18px !important;
    margin: 16px auto !important;
  }

  /* Evitar desbordes de texto en datos y fichas */
  .truncate-mobile {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 639px) {
  /* En móviles muy angostos, los grupos de acciones principales se apilan al 100% */
  .actions-header,
  .actions-responsive {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 8px !important;
  }
  .actions-header .btn,
  .actions-header a.btn,
  .actions-header button.btn,
  .actions-responsive .btn,
  .actions-responsive a.btn,
  .actions-responsive button.btn {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
  }
}

