/* ============================================================
   Mercado Público Alertas — Design System
   ============================================================ */

/* Variables */
:root {
  --azul:        #1E4E79;
  --azul-medio:  #2E75B6;
  --azul-claro:  #D6E4F0;
  --azul-pale:   #EBF3FB;
  --gris-dark:   #1a1a1a;
  --gris:        #595959;
  --gris-light:  #f4f6f9;
  --gris-border: #dde3ec;
  --verde:       #375623;
  --verde-claro: #e2efda;
  --rojo:        #c0392b;
  --rojo-claro:  #fdecea;
  --naranja:     #e67e22;
  --naranja-claro: #fef3e2;
  --blanco:      #ffffff;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.08);
  --shadow-md:   0 4px 12px rgba(0,0,0,.10);
  --radius:      6px;
  --transition:  .18s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
       font-size: 14px; color: var(--gris-dark); background: var(--gris-light);
       line-height: 1.6; }
a { color: var(--azul-medio); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px; min-height: 100vh; background: var(--azul);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; z-index: 100;
  transition: transform var(--transition);
}
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar-logo h1 { color: #fff; font-size: 15px; font-weight: 700; line-height: 1.3; }
.sidebar-logo span { color: #aac8e8; font-size: 11px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: #aac8e8; font-size: 13px; font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar-nav a.active { background: rgba(255,255,255,.12); color: #fff; border-left-color: #fff; }
.sidebar-nav .icon { width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-footer .user-email { color: #aac8e8; font-size: 12px; white-space: nowrap;
                               overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.sidebar-footer .btn-logout {
  margin-top: 8px; width: 100%; background: rgba(255,255,255,.1); color: #fff;
  border: 1px solid rgba(255,255,255,.2); border-radius: var(--radius);
  padding: 6px 12px; font-size: 12px; transition: background var(--transition);
}
.sidebar-footer .btn-logout:hover { background: rgba(255,255,255,.2); }

/* Main content */
.main-content { margin-left: 220px; flex: 1; min-height: 100vh; padding: 28px 32px; }
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--azul); }
.page-header p { color: var(--gris); font-size: 13px; margin-top: 4px; }

/* ── Auth layout ── */
.auth-layout {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; background: var(--gris-light);
}
.auth-card {
  background: var(--blanco); border-radius: 10px;
  box-shadow: var(--shadow-md); padding: 40px;
  width: 100%; max-width: 420px;
}
.auth-card .logo { text-align: center; margin-bottom: 28px; }
.auth-card .logo h1 { color: var(--azul); font-size: 20px; font-weight: 700; }
.auth-card .logo p { color: var(--gris); font-size: 12px; margin-top: 4px; }

/* ── Cards y panels ── */
.card {
  background: var(--blanco); border: 1px solid var(--gris-border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-header {
  padding: 14px 20px; border-bottom: 1px solid var(--gris-border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 14px; font-weight: 600; color: var(--azul); }
.card-body { padding: 20px; }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--blanco); border: 1px solid var(--gris-border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--azul); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: var(--gris); margin-top: 6px; }
.stat-card .stat-icon { font-size: 24px; margin-bottom: 8px; }

/* ── Formularios ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600;
                    color: var(--gris-dark); margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--gris-border);
  border-radius: var(--radius); font-size: 14px; color: var(--gris-dark);
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--blanco);
}
.form-control:focus {
  outline: none; border-color: var(--azul-medio);
  box-shadow: 0 0 0 3px rgba(46,117,182,.15);
}
.form-control.error { border-color: var(--rojo); }
.form-hint { font-size: 11px; color: var(--gris); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--rojo); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Tags/chips input */
.tags-input {
  min-height: 42px; padding: 6px 8px; border: 1px solid var(--gris-border);
  border-radius: var(--radius); display: flex; flex-wrap: wrap; gap: 4px;
  cursor: text; background: var(--blanco);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.tags-input:focus-within { border-color: var(--azul-medio); box-shadow: 0 0 0 3px rgba(46,117,182,.15); }
.tag-chip {
  background: var(--azul-pale); color: var(--azul-medio); border: 1px solid var(--azul-claro);
  border-radius: 3px; padding: 2px 6px; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; gap: 4px;
}
.tag-chip .remove { cursor: pointer; color: var(--azul); font-weight: 700; line-height: 1; }
.tag-chip .remove:hover { color: var(--rojo); }
.tags-input input { border: none; outline: none; font-size: 13px; flex: 1; min-width: 100px; background: transparent; }

/* ── Botones ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--radius); font-size: 13px;
  font-weight: 600; border: none; transition: all var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--azul-medio); color: #fff; }
.btn-primary:hover { background: var(--azul); }
.btn-secondary { background: var(--blanco); color: var(--azul-medio); border: 1px solid var(--azul-claro); }
.btn-secondary:hover { background: var(--azul-pale); }
.btn-danger { background: var(--rojo-claro); color: var(--rojo); border: 1px solid #f5c6c2; }
.btn-danger:hover { background: var(--rojo); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ── Tabla ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
  background: var(--azul-pale); color: var(--azul); font-size: 11px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 10px 14px; text-align: left; border-bottom: 2px solid var(--azul-claro);
}
table td { padding: 11px 14px; border-bottom: 1px solid var(--gris-border); font-size: 13px; }
table tr:hover td { background: var(--azul-pale); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--gris); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }
.empty-state p { font-size: 13px; }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 600; }
.badge-blue   { background: var(--azul-pale);    color: var(--azul-medio); }
.badge-green  { background: var(--verde-claro);  color: var(--verde); }
.badge-orange { background: var(--naranja-claro); color: var(--naranja); }
.badge-red    { background: var(--rojo-claro);   color: var(--rojo); }

/* ── Alertas ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-error   { background: var(--rojo-claro);    color: var(--rojo);    border-left: 3px solid var(--rojo); }
.alert-success { background: var(--verde-claro);   color: var(--verde);   border-left: 3px solid var(--verde); }
.alert-info    { background: var(--azul-pale);     color: var(--azul);    border-left: 3px solid var(--azul-medio); }
.alert-warning { background: var(--naranja-claro); color: var(--naranja); border-left: 3px solid var(--naranja); }

/* ── Search filters ── */
.search-bar {
  display: flex; gap: 8px; align-items: flex-end;
  background: var(--blanco); border: 1px solid var(--gris-border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px;
  flex-wrap: wrap;
}
.search-bar .form-group { margin-bottom: 0; flex: 1; min-width: 180px; }

/* Licitacion card */
.lic-card {
  background: var(--blanco); border: 1px solid var(--gris-border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.lic-card:hover { box-shadow: var(--shadow-md); border-color: var(--azul-claro); }
.lic-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.lic-card-title { font-size: 14px; font-weight: 600; color: var(--gris-dark); flex: 1; }
.lic-card-codigo { font-size: 11px; color: var(--azul-medio); font-weight: 700; letter-spacing: .4px; white-space: nowrap; }
.lic-card-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.lic-card-row { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--gris); }
.lic-card-row strong { color: var(--gris-dark); }
.lic-card-actions { margin-top: 12px; display: flex; gap: 8px; }

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 20px; justify-content: center; }
.pagination button {
  width: 34px; height: 34px; border: 1px solid var(--gris-border);
  border-radius: var(--radius); background: var(--blanco);
  font-size: 13px; color: var(--gris-dark);
  transition: all var(--transition);
}
.pagination button.active { background: var(--azul-medio); color: #fff; border-color: var(--azul-medio); }
.pagination button:hover:not(.active):not(:disabled) { background: var(--azul-pale); border-color: var(--azul-claro); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: var(--gris); padding: 0 8px; }

/* Profile card */
.profile-card {
  background: var(--blanco); border: 1px solid var(--gris-border);
  border-radius: var(--radius); padding: 0; overflow: hidden;
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}
.profile-card:hover { box-shadow: var(--shadow-md); }
.profile-card-header {
  padding: 14px 18px; background: var(--azul-pale);
  border-bottom: 1px solid var(--azul-claro);
  display: flex; justify-content: space-between; align-items: center;
}
.profile-card-header h4 { font-size: 14px; font-weight: 700; color: var(--azul); }
.profile-card-body { padding: 14px 18px; }
.profile-criteria { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.profile-actions { display: flex; gap: 6px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--blanco); border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
  width: 100%; max-width: 560px; max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 18px 24px; border-bottom: 1px solid var(--gris-border);
  display: flex; justify-content: space-between; align-items: center;
  position: sticky; top: 0; background: var(--blanco); z-index: 1;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--azul); }
.modal-close { background: none; border: none; font-size: 20px; color: var(--gris);
               cursor: pointer; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--rojo); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gris-border);
                display: flex; justify-content: flex-end; gap: 8px; }

/* Loading */
.spinner {
  width: 20px; height: 20px; border: 2px solid var(--azul-claro);
  border-top-color: var(--azul-medio); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-state { text-align: center; padding: 40px; color: var(--gris); }

/* Toggle switch */
.toggle-group { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 42px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--gris-border);
  border-radius: 22px; cursor: pointer;
  transition: background var(--transition);
}
.toggle-slider::before {
  content: ""; position: absolute; width: 16px; height: 16px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-slider { background: var(--azul-medio); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Planes ── */
.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 8px;
}
.plan-card {
  background: var(--blanco); border: 2px solid var(--gris-border);
  border-radius: 10px; padding: 28px 24px; position: relative;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.plan-card:hover { box-shadow: var(--shadow-md); border-color: var(--azul-claro); }
.plan-card--featured { border-color: var(--azul-medio); box-shadow: 0 4px 20px rgba(46,117,182,.15); }
.plan-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--azul-medio); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 14px; border-radius: 20px;
  white-space: nowrap;
}
.plan-header { margin-bottom: 20px; }
.plan-header h3 { font-size: 18px; font-weight: 700; color: var(--azul); margin-bottom: 10px; }
.plan-price { display: flex; align-items: baseline; gap: 4px; margin-bottom: 4px; }
.plan-features { list-style: none; margin: 0 0 24px; padding: 0; }
.plan-features li {
  font-size: 13px; color: var(--gris-dark); padding: 5px 0;
  border-bottom: 1px solid var(--gris-light);
}
.plan-features li:last-child { border-bottom: none; }
