/* =============================================
   KARDEX QALI WARMA - ESTILOS
   ============================================= */

:root {
  --red: #d32f2f;
  --red-dark: #b71c1c;
  --red-light: #ffcdd2;
  --gold: #f9a825;
  --green: #2e7d32;
  --green-light: #e8f5e9;
  --blue: #1565c0;
  --bg: #f5f5f5;
  --white: #ffffff;
  --gray: #9e9e9e;
  --gray-light: #eeeeee;
  --text: #212121;
  --text-light: #757575;
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --radius: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }
.section { display: none; }
.section.active { display: block; }

/* ===== BOTONES ===== */
.btn { display: inline-flex;align-items:center;gap:6px; padding: 10px 20px; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; transition: .2s; text-decoration: none; }
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dark); }
.btn-outline { background: transparent; border: 2px solid var(--white); color: var(--white); }
.btn-outline:hover { background: rgba(255,255,255,.15); }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-success { background: var(--green); color: var(--white); }
.btn-danger { background: #c62828; color: var(--white); }

/* ===== INPUTS ===== */
.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text-light); margin-bottom: 4px; }
.input-group input, .input-group textarea, .input-group select { width: 100%; padding: 10px 14px; border: 2px solid var(--gray-light); border-radius: var(--radius); font-size: 14px; transition: .2s; }
.input-group input:focus, .input-group select:focus, .input-group textarea:focus { outline: none; border-color: var(--red); }
.select-full { width: 100%; padding: 10px 14px; border: 2px solid var(--gray-light); border-radius: var(--radius); font-size: 14px; }
.input-filter { padding: 10px 14px; border: 2px solid var(--gray-light); border-radius: var(--radius); font-size: 14px; width: 250px; }
.select-filter { padding: 8px 12px; border: 2px solid var(--gray-light); border-radius: var(--radius); font-size: 13px; }

/* ===== LOGIN ===== */
.login-container { max-width: 400px; margin: 0 auto; padding: 60px 20px; }
.login-logo { text-align: center; margin-bottom: 40px; }
.logo-circle { width: 80px; height: 80px; background: var(--red); color: var(--white); font-size: 28px; font-weight: 800; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-logo h1 { font-size: 22px; color: var(--red-dark); }
.login-logo p { color: var(--text-light); font-size: 14px; }
.login-form { background: var(--white); padding: 30px; border-radius: 16px; box-shadow: var(--shadow); }
.error-msg { color: #c62828; font-size: 13px; margin-top: 10px; text-align: center; }
.install-banner { margin-top: 24px; text-align: center; background: var(--white); padding: 16px; border-radius: 12px; box-shadow: var(--shadow); }
.install-banner p { margin-bottom: 10px; font-size: 14px; }
.install-banner .btn-outline { border-color: var(--red); color: var(--red); }

/* ===== NAVBAR ===== */
.navbar { background: var(--red); color: var(--white); padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 100; }
.navbar-desktop { padding: 0 24px; height: 56px; }
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.logo-sm { background: rgba(255,255,255,.2); padding: 4px 8px; border-radius: 6px; font-weight: 800; font-size: 13px; }
.nav-links { display: flex; gap: 0; height: 56px; }
.nav-link { color: rgba(255,255,255,.7); text-decoration: none; padding: 0 16px; font-size: 14px; font-weight: 500; display: flex; align-items: center; height: 100%; border-bottom: 3px solid transparent; transition: .2s; }
.nav-link:hover, .nav-link.active { color: var(--white); border-bottom-color: var(--gold); }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.navbar-pwa { padding: 10px 16px; }

/* Hamburger button */
.hamburger { display: none; background: none; border: none; color: var(--white); font-size: 22px; cursor: pointer; padding: 4px 8px; border-radius: 6px; line-height: 1; }
.hamburger:hover { background: rgba(255,255,255,.15); }

/* ===== CONTAINERS ===== */
.container { max-width: 800px; margin: 0 auto; padding: 20px; }
.container-desktop { max-width: 1200px; margin: 0 auto; padding: 24px; }

/* ===== STATS ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 20px; }
.stat-card { background: var(--white); padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow); text-align: center; }
.stat-num { font-size: 36px; font-weight: 800; color: var(--red); }
.stat-label { color: var(--text-light); font-size: 14px; margin-top: 4px; }

/* ===== TABLES ===== */
.table-container { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
thead { background: var(--red); color: var(--white); }
th { padding: 12px 16px; text-align: left; font-size: 13px; font-weight: 600; white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--gray-light); font-size: 13px; }
tr:hover { background: #fafafa; }
td input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ===== SECTION HEADER ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.section-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ===== ASIGNAR PANEL ===== */
.asignar-panel { background: var(--gold); padding: 12px 20px; border-radius: var(--radius); display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.asignar-panel span { font-weight: 600; font-size: 14px; }
.asignar-panel select { padding: 6px 12px; border-radius: 6px; border: 1px solid #ccc; }

/* ===== MODAL ===== */
.modal { display: none; position: fixed; z-index: 200; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,.5); align-items: center; justify-content: center; }
.modal.active { display: flex; }
.modal-content { background: var(--white); border-radius: 16px; padding: 24px; width: 90%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-header h3 { font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--gray); }

/* ===== CARDS (responsive supervisor) ===== */
.card-list { display: grid; gap: 12px; margin-top: 16px; }
.card { background: var(--white); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card-clickable { cursor: pointer; transition: .2s; border: 2px solid transparent; }
.card-clickable:hover, .card-clickable:active { border-color: var(--red-light); transform: translateY(-1px); }
.card-title { font-weight: 700; font-size: 15px; color: var(--red-dark); }
.card-sub { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* Distribución de productos */
.modal-lg { max-width: 600px; max-height: 85vh; overflow-y: auto; }
.dist-list { display: flex; flex-direction: column; gap: 8px; }
.dist-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: var(--bg); border-radius: 10px; border-left: 4px solid var(--gray-light); transition: .2s; }
.dist-row.has-qty { border-left-color: var(--green); background: var(--green-light); }
.dist-prod-info { flex: 1; min-width: 0; }
.dist-prod-nombre { font-size: 13px; font-weight: 700; }
.dist-prod-detalle { font-size: 11px; color: var(--text-light); }
.dist-prod-qty { flex-shrink: 0; }
.dist-qty-input { width: 65px; padding: 8px; border: 2px solid var(--gray-light); border-radius: 8px; text-align: center; font-size: 16px; font-weight: 700; }
.dist-qty-input:focus { border-color: var(--red); outline: none; }
.card-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-primary { background: var(--red-light); color: var(--red-dark); }
.badge-success { background: var(--green-light); color: var(--green); }

/* ===== TABS (responsive) ===== */
.tabs-responsive { display: flex; background: var(--white); border-bottom: 2px solid var(--gray-light); overflow-x: auto; position: sticky; top: 48px; z-index: 99; }
.tab { flex: 1; padding: 12px; text-align: center; border: none; background: none; font-size: 13px; font-weight: 600; color: var(--text-light); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.active { color: var(--red); border-bottom-color: var(--red); }

/* ===== PWA (Encargado) ===== */
.pwa-selector { padding: 12px 16px; background: var(--white); border-bottom: 1px solid var(--gray-light); }
.pwa-kardex { padding: 16px; padding-bottom: 140px; }

/* Selector de día */
.dia-selector { display: flex; gap: 6px; background: var(--gray-light); border-radius: 14px; padding: 4px; margin-bottom: 12px; }
.dia-btn { flex: 1; border: none; border-radius: 12px; padding: 12px 0; font-size: 16px; font-weight: 800; cursor: pointer; background: transparent; color: var(--text-light); transition: .2s; }
.dia-btn.active { background: var(--red); color: var(--white); box-shadow: var(--shadow); }
.dia-btn.filled { background: var(--green-light); color: var(--green); }
.dia-btn.filled.active { background: var(--red); color: var(--white); }

.dia-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dia-nombre { font-size: 20px; font-weight: 800; color: var(--red-dark); }
.dia-semana { font-size: 12px; color: var(--text-light); background: var(--gray-light); padding: 4px 12px; border-radius: 20px; }

/* Producto card PWA */
.productos-lista { display: flex; flex-direction: column; gap: 10px; }
.prod-card { background: var(--white); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: space-between; gap: 12px; border-left: 4px solid var(--gray-light); transition: .2s; }
.prod-card.has-value { border-left-color: var(--green); background: #f1f8e9; }
.prod-left { flex: 1; min-width: 0; }
.prod-nombre { font-size: 14px; font-weight: 700; color: var(--text); line-height: 1.3; }
.prod-stock { font-size: 12px; color: var(--text-light); margin-top: 3px; }
.prod-stock span { font-weight: 700; color: var(--green); }
.prod-stock span.low { color: #e65100; }
.prod-stock span.out { color: #c62828; }
.prod-qty { width: 64px; padding: 10px 4px; border: 2px solid var(--gray-light); border-radius: 12px; font-size: 20px; font-weight: 800; text-align: center; color: var(--text); appearance: auto; background: var(--white); cursor: pointer; }
.prod-qty:focus { border-color: var(--red); outline: none; }
.prod-qty.selected { border-color: var(--green); background: var(--green-light); color: var(--green); }

/* Pie del kardex */
.kardex-pie { background: var(--white); border-radius: 14px; padding: 16px; margin-top: 16px; box-shadow: var(--shadow); }

/* Botón grande */
.btn-lg { padding: 14px 24px; font-size: 16px; border-radius: 12px; }

/* Online/Offline indicator */
.nav-status { display: flex; align-items: center; gap: 8px; }
.conn-indicator { font-size: 12px; transition: .3s; }
.conn-indicator.online { color: var(--green); }
.conn-indicator.offline { color: #c62828; }
.sync-badge { background: #e65100; color: var(--white); font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; min-width: 20px; animation: pulse-badge 2s infinite; }
@keyframes pulse-badge { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }
body.is-offline .conn-indicator { color: #c62828; }
body.is-offline .conn-indicator::after { content: ' Sin internet'; font-size: 10px; }

/* Reporte visual */
.reporte-semana { background: var(--white); border-radius: 12px; padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.reporte-semana-title { font-size: 15px; font-weight: 700; color: var(--red-dark); margin-bottom: 4px; }
.reporte-semana-fechas { font-size: 12px; color: var(--text-light); margin-bottom: 12px; }
.reporte-producto { margin-bottom: 14px; }
.reporte-prod-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.reporte-prod-nombre { font-size: 13px; font-weight: 600; }
.reporte-prod-nums { font-size: 12px; color: var(--text-light); }
.reporte-barra { height: 24px; background: var(--gray-light); border-radius: 12px; overflow: hidden; position: relative; }
.reporte-barra-fill { height: 100%; border-radius: 12px; transition: width .5s ease; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; }
.reporte-barra-fill.green { background: linear-gradient(90deg, #66bb6a, #2e7d32); }
.reporte-barra-fill.orange { background: linear-gradient(90deg, #ffa726, #e65100); }
.reporte-barra-fill.red { background: linear-gradient(90deg, #ef5350, #c62828); }
.reporte-barra-text { font-size: 11px; font-weight: 700; color: var(--white); }
.reporte-dias { display: flex; gap: 4px; margin-top: 6px; }
.reporte-dia-chip { flex: 1; text-align: center; padding: 4px 0; border-radius: 6px; font-size: 11px; font-weight: 600; }
.reporte-dia-chip.used { background: #fff3e0; color: #e65100; }
.reporte-dia-chip.empty { background: var(--gray-light); color: var(--gray); }
.reporte-resumen { display: flex; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-light); }
.resumen-item { flex: 1; text-align: center; padding: 8px; border-radius: 8px; background: var(--bg); }
.resumen-item .num { font-size: 18px; font-weight: 700; }
.resumen-item .label { font-size: 10px; color: var(--text-light); text-transform: uppercase; }

.pwa-bottom-bar { position: fixed; bottom: 0; left: 0; width: 100%; display: flex; background: var(--white); border-top: 2px solid var(--gray-light); z-index: 100; }
.pwa-tab { flex: 1; padding: 12px; border: none; background: none; font-size: 14px; font-weight: 600; color: var(--text-light); cursor: pointer; }
.pwa-tab.active { color: var(--red); }
.pwa-reporte { padding: 16px; padding-bottom: 80px; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%) translateY(100px); background: #323232; color: var(--white); padding: 12px 24px; border-radius: var(--radius); font-size: 14px; z-index: 300; transition: .3s; opacity: 0; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  /* Admin navbar: hamburger + dropdown */
  .hamburger { display: block; }
  .navbar-desktop { height: auto; min-height: 48px; padding: 8px 16px; flex-wrap: wrap; }
  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    height: auto;
    background: var(--red-dark);
    border-radius: 0 0 var(--radius) var(--radius);
    overflow: hidden;
    order: 10;
  }
  .nav-links.open { display: flex; }
  .nav-links .nav-link {
    padding: 14px 20px;
    height: auto;
    border-bottom: none;
    border-left: 4px solid transparent;
    font-size: 15px;
  }
  .nav-links .nav-link.active { border-left-color: var(--gold); background: rgba(255,255,255,.08); }
  .brand-text { display: none; }
  .nav-user span { display: none; }

  /* Admin containers */
  .container-desktop { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .section-header { flex-direction: column; align-items: flex-start; }
  .section-header .btn { width: 100%; justify-content: center; }
  .section-actions { width: 100%; }
  .input-filter { width: 100%; }
  .select-filter { width: 100%; }
  .asignar-panel { flex-direction: column; align-items: stretch; }
  .asignar-panel select { width: 100%; }
  .asignar-panel .btn { width: 100%; justify-content: center; }

  /* Admin tables: card view on mobile */
  .table-container table { font-size: 12px; }
  .table-container { border-radius: var(--radius); }
  th, td { padding: 8px 10px; font-size: 12px; }

  /* Modal full-width on mobile */
  .modal-content { width: 95%; padding: 20px 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 16px; }
  .stat-num { font-size: 28px; }
}
