/* ===================================
   BetuBot — Design System
   =================================== */

:root {
  /* Sidebar */
  --sidebar-bg:          #1e2433;
  --sidebar-hover-bg:    #2d3a50;
  --sidebar-active-bg:   rgba(251,192,45,0.14);
  --sidebar-active-text: #fbc02d;
  --sidebar-text:        #c9d1d9;
  --sidebar-muted:       #7f8ea3;
  --sidebar-w:           230px;

  /* Brand */
  --accent:              #fbc02d;
  --accent-hover:        #f0ad00;
  --accent-subtle:       #fff9d0;

  /* Layout */
  --bg:                  #f1f3f8;
  --card-bg:             #ffffff;
  --border:              #e5e7eb;
  --radius:              10px;
  --radius-sm:           6px;
  --shadow-card:         0 1px 8px rgba(0,0,0,0.07);
  --shadow-sm:           0 1px 3px rgba(0,0,0,0.08);

  /* Typography */
  --text:                #1a1a2e;
  --text-muted:          #6b7280;
  --text-light:          #9ca3af;
}

/* === RESET / BASE ============================================ */
*, *::before, *::after { box-sizing: border-box; }

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

h1, h2, h3 { color: var(--text); margin: 0 0 12px; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }

a { color: var(--accent-hover); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === TOP HEADER ============================================= */
.header-moderno {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.logo-nombre {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-link img { height: 36px; }

.nombre-app {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
}

.zona-derecha-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.tipo-cambio-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* Dropdown user menu */
.menu-container { position: relative; }

.menu-boton,
.btn-panel {
  background: var(--bg);
  color: var(--text);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border);
  transition: background 0.2s;
  white-space: nowrap;
}

.menu-boton:hover,
.btn-panel:hover {
  background: #eaeaea;
}

.dropdown {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.10);
  z-index: 200;
  min-width: 180px;
  flex-direction: column;
  overflow: hidden;
}

.dropdown.show { display: flex; }

.dropdown a {
  padding: 11px 16px;
  text-decoration: none;
  color: var(--text);
  display: block;
  font-size: 14px;
  transition: background 0.15s;
}

.dropdown a:hover { background: var(--bg); }

/* === MODAL (proveedores popup) ============================== */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 999;
}

.modal-content {
  background: var(--card-bg);
  padding: 24px;
  border-radius: var(--radius);
  max-height: 80vh;
  overflow-y: auto;
  width: 90%;
  max-width: 700px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.proveedor-grid-header,
.proveedor-grid-row {
  display: grid;
  grid-template-columns: 1fr 1fr 80px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}

.proveedor-grid-header {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg);
  margin-bottom: 4px;
}

.proveedor-grid-row div:nth-child(3) { text-align: center; }

.verde   { background: #d4edda; }
.amarillo { background: #fff3cd; }
.rojo   { background: #f8d7da; }

/* === PANEL DE USUARIO — SIDEBAR LAYOUT ===================== */
.app-shell {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* Dark sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  flex-shrink: 0;
  padding: 20px 12px 32px;
  overflow-y: auto;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
}

.sidebar-group {
  margin-bottom: 22px;
}

.sidebar-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 700;
}

/* Main content area */
.app-main {
  flex: 1;
  min-width: 0;
  padding: 28px 28px 48px;
  overflow-x: auto;
}

/* Card wrapper used inside app-main */
.panel-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 24px;
  border: 1px solid var(--border);
}

.panel-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* === BUSCADOR =============================================== */
.buscador-wrap {
  display: flex;
  justify-content: center;
  padding: 28px 16px 0;
}

.buscador-card {
  width: 100%;
  max-width: 720px;
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 24px 28px 18px;
  border: 1px solid var(--border);
}

.buscador-titulo {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 16px;
}

.buscador-form {
  display: flex;
  gap: 10px;
}

.buscador-input {
  flex: 1;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fafafa;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.buscador-btn {
  padding: 11px 22px;
  background: var(--accent);
  color: #333;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.buscador-btn:hover { background: var(--accent-hover); }

/* Focus ring */
input[name="q"]:focus,
.buscador-input:focus {
  outline: none;
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(251,192,45,0.22);
}

/* === OPERATOR CHIPS ========================================= */
.op-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-light);
}

.op-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Courier New', monospace;
  font-weight: 700;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}

.op-chip:hover {
  background: var(--accent);
  border-color: var(--accent-hover);
  color: #333;
}

kbd {
  background: #f0f0f0;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: inherit;
}

/* === SEARCH SPINNER ========================================= */
#search-spinner {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 10px;
}

#search-spinner.visible { display: flex; }

.spinner-ring {
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === FILTER BAR ============================================= */
.filtros-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-bottom: 16px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.filtros-panel label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 13px;
  margin: 0;
  color: var(--text-muted);
}

.filtros-panel select {
  font-size: 13px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

.filtros-panel input[type="checkbox"] {
  accent-color: var(--accent);
}

.filtros-panel .grupo-filtros {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-right: 1px solid var(--border);
  padding-right: 20px;
}

.filtros-panel .grupo-filtros:last-of-type {
  border-right: none;
  padding-right: 0;
}

/* === RESULT TABLE =========================================== */
.tabla-wrapper {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  margin-top: 4px;
}

.tabla-resultados {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tabla-resultados thead th {
  background: #f8f9fb;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.tabla-resultados thead th a {
  color: inherit;
  text-decoration: none;
}

.tabla-resultados thead th a:hover {
  text-decoration: underline;
  color: var(--text);
}

.tabla-resultados tbody td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: middle;
  white-space: nowrap;
}

.tabla-resultados tbody tr:last-child td { border-bottom: none; }
.tabla-resultados tbody tr:hover td { filter: brightness(0.94); }

/* Also style generic tables inside panels */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

th, td {
  padding: 9px 12px;
  border: 1px solid var(--border);
  text-align: left;
  font-size: 13px;
}

th {
  background: #f8f9fb;
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Badge result count */
.badge-resultados {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--accent-subtle);
  border: 1px solid #f0d800;
  color: #555;
  font-size: 13px;
  padding: 5px 14px;
  border-radius: 20px;
  margin-bottom: 12px;
}

.badge-resultados strong { font-size: 15px; color: var(--text); }

/* Link "Ver" in table */
.btn-ver {
  display: inline-block;
  background: #e8f0fe;
  color: #1558c0;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-ver:hover { background: #c5d8fc; }

/* Empty state */
.sin-resultados {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.sin-resultados .icono-vacio {
  font-size: 42px;
  margin-bottom: 10px;
}

.sin-resultados p {
  font-size: 15px;
  margin: 0;
  color: var(--text-muted);
}

/* === QUICK-SEARCH SIDEBAR =================================== */
.layout-cols {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 24px 20px 30px;
}

.layout-sidebar-col {
  width: 270px;
  flex-shrink: 0;
}

.layout-main-col {
  flex: 1;
  min-width: 0;
}

.quicksearch-panel ul {
  list-style: none;
  padding: 0; margin: 0;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.quicksearch-panel li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.15s;
}

.quicksearch-panel li:last-child { border-bottom: none; }
.quicksearch-panel li:hover { background: #fffde8; }

.quicksearch-panel li div a {
  margin-left: 4px;
  font-size: 14px;
  text-decoration: none;
  opacity: 0.65;
  transition: opacity 0.15s;
}

.quicksearch-panel li div a:hover { opacity: 1; }

form.quicksearch-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

form.quicksearch-form input[type="text"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg);
  font-family: inherit;
}

form.quicksearch-form button[type="submit"] {
  background: var(--accent);
  color: #333;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}

form.quicksearch-form button[type="submit"]:hover {
  background: var(--accent-hover);
}

/* === BUTTONS ================================================ */
.btn,
input[type="submit"],
button[type="submit"] {
  padding: 7px 14px;
  background: var(--accent);
  color: #333;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  transition: background 0.2s;
  font-family: inherit;
}

.btn:hover,
input[type="submit"]:hover,
button[type="submit"]:hover {
  background: var(--accent-hover);
}

.btn-agregar { background: var(--accent);       color: #333; }
.btn-agregar:hover { background: var(--accent-hover); }

.btn-editar  { background: #e0f0ff;              color: #004488; }
.btn-editar:hover  { background: #cde8ff; }

.btn-eliminar { background: #ffe0e0;             color: #990000; }
.btn-eliminar:hover { background: #ffcccc; }

.btn-subir  { background: #e8ffe8;               color: #226600; }
.btn-subir:hover  { background: #d2f8d2; }

/* === FORMS ================================================== */
input, select, textarea {
  padding: 8px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(251,192,45,0.18);
}

/* === FLASH MESSAGES ========================================= */
.success, .alert-success { color: #166534; font-weight: 600; }
.error, .alert-error     { color: #991b1b; font-weight: 600; }

.msg-ok {
  background: #d4edda; color: #155724;
  padding: 10px 16px;
  border: 1px solid #c3e6cb;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.msg-err {
  background: #f8d7da; color: #721c24;
  padding: 10px 16px;
  border: 1px solid #f5c6cb;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

/* === FOOTER ================================================= */
.site-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
}

/* === LEGACY COMPATIBILITY =================================== */
/* Some included sub-pages still use these classes */
.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 20px;
}

.campos { /* used by estadisticas */ }

details {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 8px;
}

details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
}

/* === MEDIA QUERIES ========================================== */
@media (max-width: 1024px) {
  .app-sidebar { width: 200px; }
  :root { --sidebar-w: 200px; }
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }

  .app-sidebar {
    width: 100%;
    height: auto;
    position: static;
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .sidebar-group { margin-bottom: 0; }

  .sidebar-link {
    padding: 6px 10px;
    font-size: 12px;
  }

  .app-main { padding: 16px; }

  .layout-cols {
    flex-direction: column;
    padding: 16px 12px 24px;
    gap: 16px;
  }

  .layout-sidebar-col { width: 100%; }

  .buscador-card { padding: 16px 14px; }

  .buscador-form { flex-direction: column; }
  .buscador-btn  { width: 100%; }

  .filtros-panel { flex-direction: column; gap: 10px; }

  .filtros-panel .grupo-filtros {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 10px;
  }

  .filtros-panel .grupo-filtros:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
  }

  .header-moderno { padding: 0 12px; }
  .zona-derecha-header { gap: 8px; flex-wrap: wrap; }
  .tipo-cambio-header { font-size: 12px; }
}
