/* ============================================================
   UniSoft — Solicitudes de Compra
   Paleta: azul primario #2B4EC8, blanco, grises suaves
   Sin bordes duros. Sombras suaves. Bordes redondeados.
   ============================================================ */

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

:root {
  --primary:     #2B4EC8;
  --primary-dark:#1a3499;
  --primary-light:#e8eeff;
  --sidebar-bg:  #ffffff;
  --sidebar-w:   230px;
  --topbar-h:    0px;
  --body-bg:     #f4f6fb;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --border:      #e2e8f0;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07);
  --shadow-md:   0 4px 16px rgba(0,0,0,.08);
  --radius:      12px;
  --radius-sm:   8px;

  /* semáforo */
  --dot-green:   #22c55e;
  --dot-yellow:  #f59e0b;
  --dot-red:     #ef4444;
  --dot-empty:   #cbd5e1;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--body-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar__logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar__logo img {
  height: 36px;
  object-fit: contain;
}

.sidebar__nav {
  padding: 16px 12px;
  flex: 1;
}

.sidebar__section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 8px 4px;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}

.nav-link:hover,
.nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-link svg { flex-shrink: 0; }

/* ── Módulos del sidebar ─────────────────────────────────── */

.sidebar__module { margin-bottom: 2px; }

.sidebar__module-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  text-align: left;
}

.sidebar__module-btn:hover { background: var(--primary-light); color: var(--primary); }
.sidebar__module-btn--active { color: var(--primary); }
.sidebar__module-btn--disabled { color: var(--text-muted); cursor: default; opacity: .6; }
.sidebar__module-btn--disabled:hover { background: none; color: var(--text-muted); }

.sidebar__module-icon { display: flex; align-items: center; flex-shrink: 0; }

.sidebar__chevron { margin-left: auto; flex-shrink: 0; transition: transform .2s; }

.sidebar__module-items {
  display: none;
  padding-left: 12px;
  margin-top: 2px;
}
.sidebar__module-items--open { display: block; }

.nav-link--sub {
  font-size: 13px;
  padding: 7px 12px;
}

.sidebar__badge-soon {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  background: #f1f5f9;
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: .03em;
}

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.sidebar__user-info { flex: 1; overflow: hidden; }
.sidebar__user-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar__user-info span  { font-size: 11px; color: var(--text-muted); }

.sidebar__logout {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}
.sidebar__logout:hover { color: var(--dot-red); }

/* ── Main content ────────────────────────────────────────── */

.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 28px 32px;
}

/* ── Page header ─────────────────────────────────────────── */

.page-header { margin-bottom: 24px; }
.page-category { font-size: 12px; font-weight: 600; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; }
.page-title { font-size: 24px; font-weight: 700; margin: 2px 0 4px; }
.page-subtitle { color: var(--text-muted); font-size: 13px; }

/* ── Card ────────────────────────────────────────────────── */

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

/* ── Search bar ──────────────────────────────────────────── */

.search-bar {
  position: relative;
  max-width: 380px;
}

.search-bar input {
  width: 100%;
  padding: 9px 16px 9px 38px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,78,200,.12);
}

.search-bar__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ── Table ───────────────────────────────────────────────── */

.table-wrapper {
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  cursor: pointer;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8faff; }

tbody td {
  padding: 11px 14px;
  vertical-align: middle;
}

/* ── Semáforo dots ───────────────────────────────────────── */

.dot {
  display: inline-block;
  width: 11px; height: 11px;
  border-radius: 50%;
}
.dot--green  { background: var(--dot-green); }
.dot--yellow { background: var(--dot-yellow); }
.dot--red    { background: var(--dot-red); }
.dot--empty  { border: 2px solid var(--dot-empty); background: transparent; }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity .15s, box-shadow .15s;
}
.btn:hover { opacity: .88; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(43,78,200,.25);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}

.btn-danger {
  background: #fff0f0;
  color: var(--dot-red);
  border: 1.5px solid #fecaca;
}

.btn-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1.5px solid #bbf7d0;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-fab {
  position: fixed;
  bottom: 28px;
  right: 32px;
  z-index: 200;
  padding: 14px 22px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 6px 24px rgba(43,78,200,.35);
}

/* ── Badge / estado ──────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-pending  { background: #fffbeb; color: #b45309; }
.badge-approved { background: #f0fdf4; color: #15803d; }
.badge-rejected { background: #fff1f2; color: #b91c1c; }
.badge-warning  { background: #fffbeb; color: #b45309; }
.badge-info     { background: #eff6ff; color: #1d4ed8; }

/* ── Forms ───────────────────────────────────────────────── */

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
  display: block;
}

.form-control, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  font-family: inherit;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43,78,200,.10);
}

.form-control-sm, .form-select-sm {
  padding: 6px 9px;
  font-size: 12.5px;
}

textarea.form-control { resize: vertical; }

.form-group { margin-bottom: 16px; }

/* ── Items table (formset) ───────────────────────────────── */

.items-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items-table th {
  padding: 8px 6px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.items-table td { padding: 6px 4px; vertical-align: middle; }
.items-table tr.item-row:hover { background: #f8faff; }

.btn-remove-item {
  background: none;
  border: none;
  color: var(--dot-red);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background .15s;
}
.btn-remove-item:hover { background: #fff1f2; }

.btn-add-item {
  background: var(--primary-light);
  color: var(--primary);
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: background .15s;
}
.btn-add-item:hover { background: #dce6ff; }

/* ── Dropzone anexos ─────────────────────────────────────── */

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.dropzone p { margin: 8px 0 0; font-size: 12px; }

/* ── Alerts ──────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.alert-success { background: #f0fdf4; color: #15803d; border-left: 3px solid var(--dot-green); }
.alert-error   { background: #fff1f2; color: #b91c1c; border-left: 3px solid var(--dot-red); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid var(--dot-yellow); }

/* ── Login page ──────────────────────────────────────────── */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 100%);
}

.login-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(43,78,200,.15);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}

.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { height: 52px; }
.login-tagline { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* ── Modal ───────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  backdrop-filter: blur(2px);
}

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  padding: 28px;
  width: 90vw;
  max-width: 440px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* ── Dropdown autocomplete ───────────────────────────────── */

.autocomplete-list {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 260px;
  overflow-y: auto;
  z-index: 300;
  /* No debe quedar más angosto que el campo, pero tampoco tan estrecho que obligue
     a hacer scroll horizontal para leer nombres de proveedor largos. */
  width: max(100%, 320px);
  max-width: min(480px, 90vw);
  top: 100%;
  left: 0;
}

.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: background .1s;
}
.autocomplete-item:hover { background: var(--primary-light); color: var(--primary); }

.autocomplete-item .prov-name { display: block; font-weight: 500; }
.autocomplete-item .prov-code { display: block; font-size: 11px; color: var(--text-muted); }
.autocomplete-item:hover .prov-code { color: var(--primary); opacity: .75; }

.autocomplete-loading,
.autocomplete-empty {
  color: var(--text-muted);
  font-style: italic;
  cursor: default;
}
.autocomplete-loading:hover,
.autocomplete-empty:hover { background: none; color: var(--text-muted); }

/* ── Misc ────────────────────────────────────────────────── */

.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }

.fw-bold { font-weight: 700; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.w-100 { width: 100%; }
.hidden { display: none !important; }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.detail-field label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); display: block; margin-bottom: 2px; }
.detail-field span  { font-size: 14px; font-weight: 500; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 16px; }
  .btn-fab { bottom: 16px; right: 16px; }
}
