/* =====================================================================
   APAFANET — app.css
   ===================================================================== */

/* ── Variables ──────────────────────────────────────────────────── */
:root {
  --header-h:       62px;
  --sidebar-w:      250px;
  --sidebar-bg:     #fff;
  --sidebar-hover:  #f1f5f9;
  --accent:         #3a7cf5;
  --accent-light:   #ebf3ff;
  --border:         #e5e7eb;
  --muted:          #6b7280;
  --card-shadow:    0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
  --ease:           .22s ease;
}

/* ── Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  background: #f1f5f9;
  color: #1e293b;
  margin: 0;
}

/* =====================================================================
   HEADER — barra superior completa
   ===================================================================== */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  z-index: 1030;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
}

/* Lado izquierdo: logo + nombre (mismo fondo que sidebar) */
.header-brand {
  min-width: var(--sidebar-w);
  width: auto;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: 0 1rem;
}
.brand-apafa {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex-shrink: 0;
}
.header-divider {
  width: 1px;
  height: 28px;
  background: #e5e7eb;
  margin: 0 .25rem;
  flex-shrink: 0;
}
.brand-ie {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-width: 0; /* permite truncado */
  flex-shrink: 1;
}
.ie-logo-img { height: 32px; width: auto; object-fit: contain; }
.ie-name { 
  font-size: .88rem; 
  font-weight: 600; 
  color: var(--accent); 
  letter-spacing: .01em;
  max-width: 250px;
}

.header-brand .toggle-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 1.1rem;
  padding: .3rem .45rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  transition: background var(--ease), color var(--ease);
}
.header-brand .toggle-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.header-logo-img { height: 44px; width: auto; object-fit: contain; flex-shrink: 0; }
.header-brand-text { line-height: 1.25; }
.header-brand-text .name { font-size: .95rem; font-weight: 700; color: #1c2b41; letter-spacing: .02em; }
.header-brand-text .sub  { font-size: .68rem; color: #6b7280; }

/* Lado derecho */
.header-right {
  flex: 1;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  padding: 0 1.25rem;
}

/* ── Indicador de periodo activo ──────────────────────────── */
.header-periodo {
  display: flex;
  align-items: center;
  gap: .55rem;
  background: #f0fdf4;
  border: 1.5px solid #16a34a;
  border-radius: 8px;
  padding: .35rem .75rem;
  text-decoration: none;
  transition: background var(--ease), box-shadow var(--ease);
  flex-shrink: 0;
}
.header-periodo:hover {
  background: #dcfce7;
  box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}
.header-periodo-sin {
  background: #fef9f0;
  border-color: #d97706;
}
.header-periodo-sin:hover {
  background: #fef3c7;
  box-shadow: 0 0 0 3px rgba(217,119,6,.15);
}
.header-periodo-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #16a34a;
  box-shadow: 0 0 0 3px rgba(22,163,74,.25);
  animation: pulse-green 2s infinite;
  flex-shrink: 0;
}
.header-periodo-dot-off {
  background: #d97706;
  box-shadow: 0 0 0 3px rgba(217,119,6,.25);
  animation: pulse-amber 2s infinite;
}
@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 0 3px rgba(22,163,74,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(22,163,74,.1); }
}
@keyframes pulse-amber {
  0%, 100% { box-shadow: 0 0 0 3px rgba(217,119,6,.25); }
  50%       { box-shadow: 0 0 0 5px rgba(217,119,6,.1); }
}
.header-periodo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.header-periodo-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: #16a34a;
  text-transform: uppercase;
}
.header-periodo-sin .header-periodo-label { color: #d97706; }
.header-periodo-name {
  font-size: .8rem;
  font-weight: 600;
  color: #1e293b;
}

/* ── User dropdown ──────────────────────────────────────────── */
.user-dropdown { position: relative; }

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: .6rem;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  padding: .35rem .75rem .35rem .45rem;
  cursor: pointer;
  background: #fff;
  transition: border-color var(--ease), box-shadow var(--ease);
  user-select: none;
}
.user-dropdown-toggle:hover,
.user-dropdown.open .user-dropdown-toggle {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58,124,245,.1);
}

.header-avatar {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .88rem; font-weight: 700;
  flex-shrink: 0;
}
.btn-xs { padding: .15rem .4rem; font-size: .75rem; line-height: 1.4; }
.avatar-circle-lg {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.header-user-text { line-height: 1.2; }
.header-user-text .urole { font-size: .65rem; color: #6b7280; font-weight: 600; letter-spacing: .04em; }
.header-user-text .uname { font-size: .82rem; font-weight: 600; color: #1c2b41; white-space: nowrap; }

.user-chevron {
  font-size: .65rem;
  color: #9ca3af;
  margin-left: .15rem;
  transition: transform var(--ease);
  flex-shrink: 0;
}
.user-dropdown.open .user-chevron { transform: rotate(180deg); }

/* Dropdown menu */
.user-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1031;
  min-width: 190px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: .4rem;
}
.user-dropdown.open .user-dropdown-menu { display: block; }

.user-dd-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .85rem;
  border-radius: 8px;
  font-size: .85rem;
  color: #374151;
  text-decoration: none;
  transition: background var(--ease);
}
.user-dd-item:hover { background: #f3f4f6; color: #111827; }
.user-dd-item i { width: 16px; text-align: center; color: #6b7280; }

.user-dd-logout       { color: #dc2626 !important; }
.user-dd-logout i     { color: #dc2626 !important; }
.user-dd-logout:hover { background: #fff1f2 !important; }

/* =====================================================================
   APP BODY — sidebar + contenido
   ===================================================================== */
.app-body {
  display: flex;
  min-height: 100vh;
  padding-top: var(--header-h);
}

/* =====================================================================
   SIDEBAR
   ===================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  position: fixed;
  top: var(--header-h); left: 0; bottom: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--ease);
}
.sidebar::-webkit-scrollbar       { width: 3px; }
.sidebar::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* Nav general */
.sidebar-nav { padding: .5rem 0; margin: 0; list-style: none; flex: 1; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .62rem 1rem;
  color: #374151;
  text-decoration: none;
  font-size: .86rem;
  border-left: 3px solid transparent;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #1c2b41;
  border-left-color: rgba(58,124,245,.5);
}

/* Items padre */
.sidebar-nav > .nav-item > .nav-link {
  color: #1c2b41;
  font-weight: 600;
  font-size: .82rem;
  border-bottom: 1px solid #e5e7eb;
}
.sidebar-nav > .nav-item > .nav-link:hover,
.sidebar-nav > .nav-item.active > .nav-link {
  background: var(--sidebar-hover);
  color: #1c2b41;
  border-left-color: var(--accent);
}

/* Submenú */
.sub-menu { background: #f8fafc; list-style: none; margin: 0; padding: 0; }
.sub-menu .nav-link {
  padding: .55rem 1rem .55rem 2.6rem;
  font-size: .83rem;
  color: #6b7280;
  border-left: 3px solid transparent;
}
.sub-menu .nav-link:hover {
  background: #f1f5f9;
  color: #1c2b41;
  border-left-color: rgba(58,124,245,.5);
}
.sub-menu .nav-link.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Iconos y flecha */
.nav-icon  { width: 17px; text-align: center; font-size: .87rem; flex-shrink: 0; }
.nav-arrow { font-size: .62rem; margin-left: auto !important; transition: transform var(--ease); }
.nav-link:not(.collapsed) .nav-arrow { transform: rotate(90deg); }

/* =====================================================================
   MAIN WRAPPER
   ===================================================================== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
  transition: margin var(--ease);
}
.main-wrapper.collapsed { margin-left: 0; }

/* Breadcrumb bar */
.breadcrumb-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: .5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.breadcrumb        { font-size: .8rem; margin: 0; }
.breadcrumb-item a { color: var(--accent); text-decoration: none; }
.text-date {
  font-size: .75rem;
  font-weight: 600;
  color: #fff;
  background: var(--sidebar-bg);
  padding: .25rem .65rem;
  border-radius: 20px;
}

/* Content area */
.content-area { padding: 1.5rem; flex: 1; }

/* =====================================================================
   CARDS
   ===================================================================== */
.card {
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: var(--card-shadow) !important;
  background: #fff;
}
.card-header {
  background: #fff !important;
  border-bottom: 1px solid var(--border) !important;
  padding: .9rem 1.25rem !important;
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600;
  font-size: .875rem;
}

/* =====================================================================
   STAT CARDS
   ===================================================================== */
.stat-card {
  border-radius: 12px;
  padding: 1.25rem;
  color: #fff;
  position: relative;
  overflow: hidden;
  border: none !important;
  box-shadow: 0 4px 20px rgba(0,0,0,.12) !important;
}
.stat-card::after {
  content: '';
  position: absolute;
  right: -16px; top: -16px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.stat-card .stat-icon  { font-size: 1.9rem; opacity: .8; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; opacity: .85; }

.stat-blue   { background: linear-gradient(135deg,#3a7cf5,#1a5dd9); }
.stat-green  { background: linear-gradient(135deg,#10b981,#059669); }
.stat-red    { background: linear-gradient(135deg,#ef4444,#dc2626); }
.stat-orange { background: linear-gradient(135deg,#f59e0b,#d97706); }
.stat-purple { background: linear-gradient(135deg,#8b5cf6,#7c3aed); }
.stat-teal   { background: linear-gradient(135deg,#0891b2,#0e7490); }

/* =====================================================================
   TABLAS
   ===================================================================== */
.table { font-size: .86rem; }
.table thead th {
  background: #f8fafc;
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-top: none;
  padding: .7rem 1rem;
}
.table tbody td        { padding: .7rem 1rem; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f0f5ff; }

/* =====================================================================
   BOTONES
   ===================================================================== */
.btn           { border-radius: 8px; font-weight: 500; }
.btn-primary   { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #2563eb; border-color: #2563eb; }
.btn-sm        { padding: .3rem .65rem; font-size: .8rem; }

/* =====================================================================
   FORMULARIOS
   ===================================================================== */
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: .87rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58,124,245,.12);
}
.form-label { font-weight: 500; font-size: .84rem; }

/* =====================================================================
   PAGE HEADER (título de página)
   ===================================================================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title    { font-size: 1.35rem; font-weight: 700; color: #0f172a; margin: 0; }
.page-subtitle { color: var(--muted); font-size: .84rem; margin: 0; }

/* Badges */
.badge { font-size: .74rem; font-weight: 500; padding: .3em .65em; }

/* =====================================================================
   UTILIDADES
   ===================================================================== */
.fs-xs { font-size: .7rem; }
.fs-sm { font-size: .82rem; }

/* =====================================================================
   TICKET / RECIBO
   ===================================================================== */
.ticket-page {
  background: #fff;
  max-width: 400px;
  margin: 2rem auto;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  font-size: .85rem;
}
.ticket-header { text-align: center; border-bottom: 2px dashed #ddd; padding-bottom: 1rem; margin-bottom: 1rem; }
.ticket-row    { display: flex; justify-content: space-between; padding: .2rem 0; }
.ticket-total  { border-top: 2px solid #333; font-weight: 700; font-size: 1.1rem; margin-top: .5rem; padding-top: .5rem; }

/* =====================================================================
   DEMO BANNER
   ===================================================================== */
.demo-banner {
  width: 100%;
  background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
  color: #1c1917;
  font-size: .82rem;
  padding: .45rem 1.2rem;
  text-align: center;
  position: relative;
  z-index: 1100;
  box-shadow: 0 2px 6px rgba(245,158,11,.3);
}
.demo-banner-link {
  color: #1c1917;
  font-weight: 700;
  text-decoration: underline;
}
.demo-banner-link:hover { color: #000; }

/* =====================================================================
   LOGIN PAGE
   ===================================================================== */
.login-body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100vw !important;
  min-height: 100vh !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: linear-gradient(135deg, #dce8ff 0%, #eaf4ff 50%, #d6eaff 100%) !important;
}
.login-wrapper {
  display: flex !important;
  width: 900px !important;
  max-width: 96vw !important;
  min-height: 560px !important;
  background: #fff !important;
  border-radius: 20px !important;
  overflow: hidden !important;
  box-shadow: 0 20px 60px rgba(58,124,245,.18) !important;
}

/* Lado imagen */
.login-side-img {
  flex: 1.1;
  background: url('../img/img_index.png') no-repeat center center;
  background-size: cover;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 2.5rem;
  color: #fff;
}
.login-side-img::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(15,23,42,.02) 0%, rgba(15,23,42,.62) 100%);
  z-index: 1;
}
.login-side-content          { position: relative; z-index: 2; }
.login-side-content h3       { font-size: 1.55rem; font-weight: 800; line-height: 1.3; margin-bottom: .6rem; }
.login-side-content p        { font-size: .88rem; opacity: .88; line-height: 1.55; }
.login-support-badge {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  background: rgba(0,0,0,.32);
  backdrop-filter: blur(8px);
  padding: .4rem 1rem;
  border-radius: 50px;
  border: 1px solid rgba(255,255,255,.15);
  margin-top: 1.2rem;
  font-size: .8rem;
}

/* Lado formulario */
.login-form-side {
  flex: 0 0 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 2.5rem;
  background: #fff;
}

/* Logo */
.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
}
.login-logo-wrap img {
  width: 140px;
  height: 140px;
  object-fit: contain;
  background: #fff;
  border-radius: 50%;
  border: 1.5px solid #e8edf5;
  box-shadow: 0 4px 16px rgba(58,124,245,.12);
  padding: 10px;
}

/* Subtitle */
.login-subtitle {
  text-align: center;
  color: #3a7cf5;
  font-size: .88rem;
  font-weight: 500;
  margin-bottom: 1.4rem;
}

/* Label */
.apf-label {
  display: block;
  font-weight: 700;
  font-size: .82rem;
  color: #1e293b;
  margin-bottom: .35rem;
  letter-spacing: .01em;
}

/* Input con icono flotante */
.apf-input-wrap {
  position: relative;
}
.apf-icon {
  position: absolute;
  left: .95rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: .9rem;
  z-index: 2;
  transition: color .2s;
}
.apf-input {
  width: 100%;
  padding: .72rem 1rem .72rem 2.6rem;
  border-radius: 12px;
  border: 1.5px solid #dde3ed;
  background: #f4f7fb;
  font-size: .93rem;
  color: #1e293b;
  outline: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.apf-input-wrap:hover .apf-input {
  border-color: #3a7cf5;
  background: #fff;
}
.apf-input-wrap:hover .apf-icon {
  color: #3a7cf5;
}
.apf-input:focus {
  border-color: #3a7cf5;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(58,124,245,.14);
}
.apf-input:focus ~ .apf-icon,
.apf-input-wrap:focus-within .apf-icon {
  color: #3a7cf5;
}

/* Botón */
.btn-login {
  background: linear-gradient(90deg, #3a7cf5 0%, #2563eb 100%);
  border: none;
  color: #fff;
  padding: .82rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .5px;
  box-shadow: 0 6px 18px rgba(58,124,245,.35);
  transition: all .3s ease;
  width: 100%;
}
.btn-login:hover {
  background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(58,124,245,.45);
  color: #fff;
}
.btn-login:active { transform: translateY(0); }

/* ── Hamburger button ───────────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  color: #374151;
  font-size: 1.2rem;
  padding: .3rem .45rem;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  transition: background var(--ease);
}
.hamburger-btn:hover { background: var(--sidebar-hover); }

/* ── Sidebar overlay (móvil) ────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 900px) {
  .login-wrapper { min-height: auto !important; flex-direction: column; }
  .login-side-img { min-height: 220px; flex: none; }
  .login-form-side { flex: none; width: 100%; padding: 2rem 2rem; }
}
@media (max-width: 480px) {
  .login-side-img { display: none !important; }
  .login-logo-wrap img { width: 110px; height: 110px; }
}
@media (max-width: 768px) {
  .hamburger-btn                { display: inline-flex; align-items: center; }
  .sidebar                      { transform: translateX(-100%); z-index: 1050; }
  .sidebar.open                 { transform: translateX(0); }
  .main-wrapper                 { margin-left: 0; overflow-x: hidden; }
  .content-area                 { padding: 1rem .75rem; }

  /* Header: brand compacto */
  .header-brand                 { width: auto; flex: 0 0 auto; gap: .4rem; padding: 0 .5rem 0 .75rem; }
  .header-brand-text .sub       { display: none; }
  .header-logo-img              { height: 34px; }

  /* Header: derecha */
  .header-right                 { padding: 0 .75rem 0 0; flex: 1; gap: .5rem; }
  .header-periodo-text          { display: none; }
  .header-periodo               { padding: .35rem .5rem; }

  /* Dropdown usuario compacto */
  .header-user-text             { display: none; }
  .user-chevron                 { display: none; }
  .user-dropdown-toggle         { border: 1.5px solid #d1d5db; padding: .3rem .45rem; gap: 0; }
  .user-dropdown-menu           { right: 0; min-width: 175px; }
}
