/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body, #app { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; background: #f0f2f5; color: #1a1a2e; }

/* ── Login ────────────────────────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%); }
.login-box { background: #fff; border-radius: 12px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.login-logo { font-size: 2.5rem; text-align: center; margin-bottom: 8px; }
.login-box h2 { text-align: center; font-size: 1.5rem; color: #1a1a2e; margin-bottom: 4px; }
.login-sub { text-align: center; color: #666; margin-bottom: 24px; font-size: .85rem; }
.login-error { background: #fff0f0; border: 1px solid #ffb3b3; color: #c0392b; border-radius: 6px; padding: 10px 14px; margin-bottom: 14px; font-size: .85rem; }

/* ── Layout ───────────────────────────────────────────────────────── */
#view-main { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 240px; min-width: 240px; background: #1a1a2e; color: #e0e0e0; display: flex; flex-direction: column; overflow-y: auto; }
.main-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar-header { display: flex; align-items: center; gap: 12px; padding: 20px 16px; border-bottom: 1px solid #2a2a4a; }
.sidebar-icon { font-size: 1.8rem; }
.sidebar-title { font-weight: 700; font-size: 1rem; color: #fff; }
.sidebar-user { font-size: .75rem; color: #8888aa; margin-top: 2px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-nav { list-style: none; flex: 1; padding: 8px 0; }
.sidebar-nav li { }
.sidebar-group-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #5566aa; padding: 12px 16px 4px; }
.sidebar-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 16px; background: none; border: none; color: #ccd; cursor: pointer; text-align: left; font-size: .88rem; border-left: 3px solid transparent; transition: background .15s, color .15s; }
.sidebar-link:hover { background: #24244a; color: #fff; }
.sidebar-link.active { background: #0f3460; color: #fff; border-left-color: #4a90d9; font-weight: 600; }
.sidebar-footer { border-top: 1px solid #2a2a4a; padding: 8px 0 12px; }

/* ── Forms ────────────────────────────────────────────────────────── */
.form-input { width: 100%; padding: 10px 12px; border: 1px solid #d0d5e0; border-radius: 8px; font-size: .9rem; outline: none; transition: border-color .2s; margin-bottom: 12px; }
.form-input:focus { border-color: #4a90d9; }
.form-row { display: grid; gap: 12px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: .8rem; font-weight: 600; color: #555; }
.form-group .form-input { margin-bottom: 0; }
select.form-input { background: #fff; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border: none; border-radius: 8px; font-size: .88rem; font-weight: 500; cursor: pointer; transition: opacity .15s, box-shadow .15s; }
.btn:hover { opacity: .88; }
.btn:active { opacity: .75; }
.btn-primary { background: #4a90d9; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-danger  { background: #e74c3c; color: #fff; }
.btn-secondary { background: #dde3ef; color: #333; }
.btn-outline { background: transparent; border: 1.5px solid #4a90d9; color: #4a90d9; }
.btn-sm { padding: 5px 10px; font-size: .8rem; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 1rem; }
.btn-icon { padding: 6px 10px; }

/* ── Cards & pages ────────────────────────────────────────────────── */
.page-title { font-size: 1.25rem; font-weight: 700; color: #1a1a2e; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.page-subtitle { font-size: .82rem; color: #666; margin-top: 2px; }
.card { background: #fff; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.07); padding: 20px; margin-bottom: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 1rem; font-weight: 600; color: #1a1a2e; }
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }

/* ── Tables ───────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead tr { background: #f0f2f5; }
th { padding: 10px 12px; text-align: left; font-weight: 600; color: #444; border-bottom: 2px solid #e0e4ec; white-space: nowrap; }
td { padding: 9px 12px; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f7f9fc; }
.td-actions { display: flex; gap: 6px; }

/* ── Badges ───────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: .75rem; font-weight: 600; }
.badge-green  { background: #e8f8ee; color: #1e8449; }
.badge-red    { background: #fdecea; color: #c0392b; }
.badge-blue   { background: #e8f0fb; color: #2874a6; }
.badge-gray   { background: #f0f2f5; color: #666; }
.badge-yellow { background: #fef9e7; color: #b7770d; }

/* ── Toggle kg/tambos ─────────────────────────────────────────────── */
.toggle-unit { display: flex; border: 1.5px solid #4a90d9; border-radius: 8px; overflow: hidden; }
.toggle-unit button { padding: 6px 14px; border: none; background: transparent; color: #4a90d9; font-size: .82rem; font-weight: 600; cursor: pointer; transition: background .15s, color .15s; }
.toggle-unit button.active { background: #4a90d9; color: #fff; }

/* ── Alertas de stock ─────────────────────────────────────────────── */
.stock-ok    { background: #e8f8ee; }
.stock-low   { background: #fff3cd; }
.stock-empty { background: #fdecea; }
.stock-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.stock-dot.ok    { background: #27ae60; }
.stock-dot.low   { background: #f39c12; }
.stock-dot.empty { background: #e74c3c; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 600px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,.25); }
.modal-box.modal-lg { max-width: 800px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e8ecf4; }
.modal-title { font-size: 1rem; font-weight: 700; color: #1a1a2e; }
.modal-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #999; }
.modal-close:hover { color: #333; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #e8ecf4; display: flex; justify-content: flex-end; gap: 10px; }

/* ── Tabs ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #e0e4ec; margin-bottom: 20px; }
.tab-btn { padding: 9px 18px; border: none; background: none; cursor: pointer; font-size: .88rem; color: #666; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.tab-btn.active { color: #4a90d9; border-bottom-color: #4a90d9; font-weight: 600; }
.tab-btn:hover:not(.active) { color: #333; }

/* ── Semáforo comprador ───────────────────────────────────────────── */
.semaforo-bar { height: 6px; border-radius: 3px; }
.semaforo-bar.ok   { background: #27ae60; }
.semaforo-bar.low  { background: #f39c12; }
.semaforo-bar.zero { background: #e74c3c; }

/* ── Misc ─────────────────────────────────────────────────────────── */
.empty-msg { text-align: center; color: #999; padding: 40px 20px; }
.page-loading { text-align: center; color: #999; padding: 60px 20px; font-size: 1rem; }
.text-right { text-align: right; }
.text-muted { color: #999; }
.divider { border: none; border-top: 1px solid #e8ecf4; margin: 16px 0; }
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .88rem; }
.alert-info  { background: #e8f0fb; color: #2874a6; border: 1px solid #c5d9f5; }
.alert-warn  { background: #fef9e7; color: #b7770d; border: 1px solid #f9e4a1; }
.alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5b7b1; }

/* ── Print ────────────────────────────────────────────────────────── */
.print-header { display: none; }
@media print {
  .sidebar, .toolbar, .btn, .modal-overlay, #btn-logout, #btn-change-pass { display: none !important; }
  .main-content { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
  .print-header {
    display: block !important;
    text-align: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #1d4ed8;
  }
  .page-title { display: none; }
}
