/* Portal de Clientes — CSS independiente v5.3.0 */
@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap');

:root {
  --primary:    #106eea;
  --primary-lt: #3b8af2;
  --accent:     #f59e0b;
  --bg:         #f1f6fe;
  --surface:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --muted:      #64748b;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Open Sans', 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Topbar ────────────────────────────────────────────────── */
.portal-topbar {
  background: #0d5fd6; color: #fff; height: 60px;
  display: flex; align-items: center; padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.portal-logo { height: 30px; width: auto; object-fit: contain; }
.portal-brand { font-size: 16px; font-weight: 700; white-space: nowrap; }
.portal-brand span { color: var(--accent); }
.portal-nav { display: flex; gap: 2px; margin-left: 32px; }
.portal-nav a {
  color: #fff; text-decoration: none; font-weight: 600;
  padding: 6px 14px; border-radius: 6px; font-size: 14px; transition: all .15s;
}
.portal-nav a:hover, .portal-nav a.active {
  background: rgba(255,255,255,.18); color: #fff;
}
.portal-spacer { flex: 1; }
.portal-user { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #fff; }
.portal-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.portal-user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  background: transparent; border: 1px solid rgba(255,255,255,.5);
  color: #fff; padding: 5px 12px; border-radius: 5px;
  font-size: 12px; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-logout:hover { background: rgba(255,255,255,.18); color: #fff; }

/* ── Main ──────────────────────────────────────────────────── */
.portal-main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.portal-page-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 24px; }

/* ── Stat cards ────────────────────────────────────────────── */
.portal-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px,1fr)); gap: 16px; margin-bottom: 32px; }
.portal-stat {
  background: var(--surface); border-radius: var(--radius); padding: 20px 20px;
  box-shadow: var(--shadow); border-left: 4px solid var(--primary);
  display: flex; align-items: center; gap: 16px;
}
.portal-stat-icon { font-size: 28px; }
.portal-stat-val { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1; }
.portal-stat-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Card ──────────────────────────────────────────────────── */
.portal-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 24px; }
.portal-card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.portal-card-title { font-size: 14px; font-weight: 600; }
.portal-card-body { padding: 20px; }

/* ── Tabla ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.portal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.portal-table th {
  background: var(--primary); color: #fff; padding: 10px 14px;
  text-align: left; font-weight: 600; font-size: 12px; white-space: nowrap;
}
.portal-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.portal-table tr:last-child td { border-bottom: none; }
.portal-table tbody tr:hover td { background: #f8fafc; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-borrador  { background: #f1f5f9; color: #475569; }
.badge-enviada   { background: #dbeafe; color: #1d4ed8; }
.badge-aprobada  { background: #dcfce7; color: #15803d; }
.badge-rechazada { background: #fee2e2; color: #b91c1c; }
.badge-vencida   { background: #fee2e2; color: #b91c1c; }
.badge-pagada    { background: #dcfce7; color: #15803d; }
.badge-parcial   { background: #fef3c7; color: #92400e; }
.badge-emitida   { background: #dbeafe; color: #1d4ed8; }
.badge-anulada   { background: #f1f5f9; color: #475569; }
.badge-pendiente { background: #fef3c7; color: #92400e; }

/* ── Botones ────────────────────────────────────────────────── */
.btn-portal {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  border: none; cursor: pointer; text-decoration: none; transition: all .15s;
}
.btn-primary-portal { background: var(--primary); color: #fff; }
.btn-primary-portal:hover { background: var(--primary-lt); }
.btn-outline-portal { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline-portal:hover { background: #f0f7ff; }
.btn-sm-portal { padding: 4px 10px; font-size: 12px; }

/* ── Empty state ────────────────────────────────────────────── */
.portal-empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.portal-empty-icon { font-size: 40px; margin-bottom: 12px; }
.portal-empty p { font-size: 14px; }

/* ── Login ──────────────────────────────────────────────────── */
.portal-login-page {
  min-height: 100vh;
  background: #f1f6fe;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.portal-login-card {
  background: var(--surface); border-radius: 12px; padding: 40px;
  width: 100%; max-width: 380px;
  box-shadow: 0 4px 32px rgba(16,110,234,0.10), 0 1px 4px rgba(0,0,0,0.06);
}
.portal-login-logo { display: block; max-height: 64px; max-width: 200px; margin: 0 auto; object-fit: contain; }
.portal-login-title { text-align: center; font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.portal-login-sub   { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 28px; }
.form-group  { margin-bottom: 16px; }
.form-label  { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.form-input  {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px; color: var(--text); transition: border .15s;
}
.form-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(16,110,234,.15); }
.btn-login {
  width: 100%; padding: 11px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s; margin-top: 8px;
}
.btn-login:hover { background: var(--primary-lt); }
.btn-login:disabled { opacity: .65; cursor: not-allowed; }
.login-error {
  background: #fee2e2; color: #b91c1c; border-radius: 6px;
  padding: 10px 12px; font-size: 13px; margin-bottom: 16px; display: none;
}

/* ── Modal ──────────────────────────────────────────────────── */
.portal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 200; display: none; align-items: center; justify-content: center; padding: 16px;
}
.portal-overlay.show { display: flex; }
.portal-modal {
  background: var(--surface); border-radius: var(--radius);
  max-width: 640px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.portal-modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.portal-modal-title { font-size: 15px; font-weight: 600; }
.portal-modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.portal-modal-body  { padding: 20px; }

/* ── Filtros ────────────────────────────────────────────────── */
.portal-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.portal-filters select, .portal-filters input {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; color: var(--text); background: var(--surface);
}
.portal-filters select:focus, .portal-filters input:focus { outline: none; border-color: var(--primary); }

/* ── Alert cambio contraseña ─────────────────────────────────── */
.portal-alert-primer {
  background: #fef3c7; border: 1px solid #f59e0b; border-radius: var(--radius);
  padding: 12px 16px; font-size: 13px; color: #92400e; margin-bottom: 20px;
  display: flex; align-items: center; gap: 10px;
}

/* ── Catálogo ───────────────────────────────────────────────── */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 20px;
  padding: 20px;
}
.product-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .15s, transform .15s;
  background: var(--surface);
}
.product-card:hover { box-shadow: 0 6px 20px rgba(16,110,234,.12); transform: translateY(-2px); }
.product-card-icon { font-size: 36px; text-align: center; padding: 14px; background: var(--bg); border-radius: 8px; }
.product-card-name { font-size: 14px; font-weight: 700; color: var(--text); }
.product-card-desc { font-size: 12px; color: var(--muted); line-height: 1.55; flex: 1; }
.product-card-cat  { font-size: 11px; background: #dbeafe; color: #1d4ed8; padding: 2px 8px; border-radius: 10px; display: inline-block; }
.product-card-price { font-size: 20px; font-weight: 700; color: var(--primary); }
.product-card-iva   { font-size: 11px; color: var(--muted); }
.btn-solicitar {
  width: 100%; padding: 9px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-solicitar:hover { background: var(--primary-lt); }

/* ── Registro ───────────────────────────────────────────────── */
.portal-login-footer { text-align: center; margin-top: 16px; font-size: 13px; color: var(--muted); }
.portal-login-footer a { color: var(--primary); text-decoration: none; font-weight: 600; }
.portal-login-footer a:hover { text-decoration: underline; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-nav { display: none; }
  .portal-main { padding: 16px; }
  .portal-stats { grid-template-columns: 1fr 1fr; }
  .portal-user-name { display: none; }
}
@media (max-width: 480px) {
  .portal-stats { grid-template-columns: 1fr; }
  .portal-topbar { padding: 0 16px; }
}
