/* ── HercabRuteo UI — Custom Styles ─────────────────────────────────── */
:root {
  --sidebar-w: 258px;
  --topbar-h: 58px;
  /* Paleta HERCAB Medical Solutions */
  --sidebar-bg: #0c2340;          /* navy del texto HERCAB */
  --sidebar-border: #1a3a5c;
  --sidebar-text: #a8c5dd;
  --sidebar-text-active: #ffffff;
  --sidebar-item-active: #2589c4; /* azul medio brand */
  --sidebar-item-hover: #15324d;
  --primary: #1f7ab8;             /* azul medio brand */
  --primary-dark: #155a8a;
  --primary-light: #d6ecf9;
  --accent-teal: #3fc1d4;         /* turquesa de las curvas */
  --bg-app: #f1f7fb;              /* fondo azul muy claro */
  --card-radius: 10px;
  --card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
}

/* ── Reset / Base ───────────────────────────────────────────────────── */
html, body { height: 100%; margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
#app { height: 100%; }
* { box-sizing: border-box; }

/* ── App Shell ─────────────────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; background: var(--bg-app); }
.app-body  { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .25s ease;
  z-index: 1040;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.1rem .9rem;
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
}
.sidebar-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
/* Logo enmascarado: blanco donde había color, transparente donde había blanco */
.sidebar-logo-mask {
  display: block;
  width: 100%;
  max-width: 200px;
  height: 80px;
  background: #ffffff;
  -webkit-mask: url('../images/logo.png') no-repeat center / contain;
          mask: url('../images/logo.png') no-repeat center / contain;
  -webkit-mask-mode: luminance;
          mask-mode: luminance;
}
.sidebar-title  { color: #fff; font-weight: 700; font-size: .9rem; line-height: 1.2; }
.sidebar-subtitle { color: var(--sidebar-text); font-size: .7rem; }

.sidebar-section {
  padding: .9rem .75rem .3rem;
  font-size: .66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sidebar-text);
  opacity: .55;
}

.sidebar-menu { list-style: none; margin: 0; padding: .2rem .65rem; }
.sidebar-menu li a {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .7rem;
  border-radius: 7px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .845rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sidebar-menu li a i { font-size: .95rem; width: 18px; text-align: center; }
.sidebar-menu li a:hover { background: var(--sidebar-item-hover); color: var(--sidebar-text-active); }
.sidebar-menu li a.active { background: var(--sidebar-item-active); color: #fff; }

.sidebar-footer {
  margin-top: auto;
  padding: .9rem 1rem;
  border-top: 1px solid var(--sidebar-border);
}
.sidebar-user {
  display: flex; align-items: center; gap: .6rem; margin-bottom: .65rem;
}
.sidebar-avatar {
  width: 32px; height: 32px;
  background: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.sidebar-user-name  { color: #fff; font-size: .83rem; font-weight: 600; line-height: 1.2; }
.sidebar-user-role  { color: var(--sidebar-text); font-size: .7rem; }
.btn-logout {
  width: 100%; background: transparent; border: 1px solid var(--sidebar-border);
  color: var(--sidebar-text); border-radius: 7px; padding: .35rem .75rem;
  font-size: .8rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: .4rem;
  transition: background .15s, color .15s;
}
.btn-logout:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

/* ── Topbar ────────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: .75rem;
  flex-shrink: 0;
}
.topbar-toggle {
  background: none; border: none; padding: .25rem;
  font-size: 1.2rem; color: #6b7280; cursor: pointer; border-radius: 6px;
  display: none;
}
.topbar-toggle:hover { background: #f3f4f6; }
.topbar-title { font-weight: 700; font-size: 1rem; color: #111827; margin: 0; flex: 1; }
.topbar-badge {
  background: var(--primary-light); color: var(--primary);
  font-size: .72rem; font-weight: 600; border-radius: 20px; padding: .15rem .6rem;
}

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

/* ── Page header ───────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.3rem; font-weight: 700; color: #111827; margin: 0; }
.page-header p  { font-size: .83rem; color: #6b7280; margin: .2rem 0 0; }

/* ── Cards ─────────────────────────────────────────────────────────── */
.card { border: 1px solid #e5e7eb; border-radius: var(--card-radius); box-shadow: var(--card-shadow); }
.card-header {
  background: #fff; border-bottom: 1px solid #e5e7eb;
  padding: .9rem 1.25rem; border-radius: var(--card-radius) var(--card-radius) 0 0;
  display: flex; align-items: center; gap: .5rem;
}
.card-header h5 { margin: 0; font-size: .95rem; font-weight: 700; }

/* ── KPI Cards ─────────────────────────────────────────────────────── */
.kpi-card {
  border-radius: 12px; padding: 1.1rem 1.25rem;
  color: #fff; border: none; position: relative; overflow: hidden;
}
.kpi-icon { font-size: 2.4rem; opacity: .2; position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); }
.kpi-value { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.kpi-label { font-size: .75rem; opacity: .88; margin-top: .25rem; font-weight: 500; }
.kpi-green   { background: linear-gradient(135deg,#16a34a,#22c55e); }
.kpi-blue    { background: linear-gradient(135deg,#2563eb,#3b82f6); }
.kpi-orange  { background: linear-gradient(135deg,#ea580c,#f97316); }
.kpi-red     { background: linear-gradient(135deg,#dc2626,#ef4444); }
.kpi-teal    { background: linear-gradient(135deg,#0d9488,#14b8a6); }
.kpi-purple  { background: linear-gradient(135deg,#7c3aed,#8b5cf6); }
.kpi-slate   { background: linear-gradient(135deg,#475569,#64748b); }
.kpi-emerald { background: linear-gradient(135deg,#059669,#10b981); }

/* ── Tables ────────────────────────────────────────────────────────── */
.table thead th {
  font-size: .78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #6b7280; background: #f9fafb;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
.table tbody td { font-size: .86rem; vertical-align: middle; }
.table-hover tbody tr:hover { background-color: #e8f4fb; }

/* ── Badges / Status ───────────────────────────────────────────────── */
.badge { font-size: .72rem; font-weight: 600; letter-spacing: .02em; padding: .3em .6em; border-radius: 5px; }
.status-draft     { background:#e5e7eb; color:#374151; }
.status-sent      { background:#dbeafe; color:#1d4ed8; }
.status-accepted  { background:#dcfce7; color:#15803d; }
.status-rejected  { background:#fce7f3; color:#9d174d; }
.status-expired   { background:#ffedd5; color:#c2410c; }
.status-superseded{ background:#ede9fe; color:#6d28d9; }
.status-converted { background:#ccfbf1; color:#0f766e; }
.status-pending   { background:#fef9c3; color:#a16207; }
.status-processing{ background:#dbeafe; color:#1d4ed8; }
.status-shipped   { background:#e0f2fe; color:#0369a1; }
.status-completed { background:#dcfce7; color:#15803d; }
.status-cancelled { background:#fee2e2; color:#b91c1c; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-label { font-size: .8rem; font-weight: 600; color: #374151; margin-bottom: .3rem; }
.form-control, .form-select {
  font-size: .875rem; border-radius: 7px;
  border: 1px solid #d1d5db; padding: .45rem .75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31,122,184,.18);
}
.form-text { font-size: .75rem; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn { border-radius: 7px; font-size: .85rem; font-weight: 600; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); }
.btn-sm { font-size: .78rem; padding: .25rem .6rem; }

/* ── Login ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(145deg, #061a2c 0%, #0c2340 35%, #1f7ab8 75%, #3fc1d4 100%);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%; max-width: 410px;
  background: #fff; border-radius: 16px;
  padding: 2.5rem; box-shadow: 0 24px 80px rgba(0,0,0,.35);
}
.login-logo-img {
  display: block;
  max-width: 220px; max-height: 100px;
  margin: 0 auto 1.25rem;
  object-fit: contain;
}
.login-title { font-size: 1.5rem; font-weight: 800; color: #111827; text-align: center; margin-bottom: .25rem; }
.login-sub   { font-size: .83rem; color: #6b7280; text-align: center; margin-bottom: 1.75rem; }

/* ── Timeline (historial) ──────────────────────────────────────────── */
.timeline { position: relative; padding-left: 1.4rem; }
.timeline::before { content:''; position:absolute; left:.45rem; top:0; bottom:0; width:2px; background:#e5e7eb; }
.timeline-item { position: relative; padding-bottom: 1rem; }
.timeline-item::before {
  content:''; position:absolute; left:-1.25rem; top:.3rem;
  width:10px; height:10px; border-radius:50%;
  background: var(--primary); border:2px solid #fff;
  box-shadow:0 0 0 2px var(--primary);
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-time    { font-size: .72rem; color: #6b7280; }
.timeline-content { font-size: .84rem; color: #374151; }

/* ── Items Table (cotización) ──────────────────────────────────────── */
.items-tbl th, .items-tbl td { padding: .4rem .65rem; font-size: .82rem; }
.items-tbl input[type=number],
.items-tbl input[type=text],
.items-tbl select { font-size:.82rem; padding:.2rem .45rem; min-width:70px; }

/* ── Detail info grid ──────────────────────────────────────────────── */
.info-label { font-size:.7rem; text-transform:uppercase; letter-spacing:.05em; color:#9ca3af; font-weight:700; }
.info-value { font-size:.9rem; color:#111827; font-weight:500; }

/* ── Section divider ───────────────────────────────────────────────── */
.section-title {
  font-size:.78rem; text-transform:uppercase; letter-spacing:.06em;
  color:#6b7280; font-weight:700; margin-bottom:.75rem;
  padding-bottom:.5rem; border-bottom:1px solid #e5e7eb;
}

/* ── Document download buttons ─────────────────────────────────────── */
.doc-btn { border-radius:8px; padding:.45rem 1rem; font-size:.82rem; font-weight:600; }

/* ── Loading skeleton ──────────────────────────────────────────────── */
.loading-box { display:flex; align-items:center; justify-content:center; padding:3rem; }

/* ── Mobile overlay ────────────────────────────────────────────────── */
.sidebar-overlay {
  display:none; position:fixed; inset:0;
  background:rgba(0,0,0,.5); z-index:1039;
}
.sidebar-overlay.show { display:block; }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 991px) {
  .sidebar {
    position: fixed; left: calc(-1 * var(--sidebar-w));
    top: 0; bottom: 0;
    transition: left .25s ease;
  }
  .sidebar.open { left: 0; }
  .topbar-toggle { display: flex; }
  .content-area { padding: 1rem; }
}

/* ── Resaltado sutil de columnas clave en tablas ───────────────────── */
.col-resalte { background: #f1f7fb !important; }

/* ── Font weight utilities (Bootstrap doesn't include fw-600/700/800) ─ */
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
