/*
 * RUKAOS Design System — _ds.css  (Plan B Maestro)
 * Versión 2.0 — importar como primer stylesheet en todas las páginas.
 */

/* ═══════════════════════════════════════════════════════
   0. FUENTE — Inter (Google Fonts)
════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

/* ═══════════════════════════════════════════════════════
   1. VARIABLES — Paleta oficial RUKAOS Plan B
════════════════════════════════════════════════════════ */
:root {
  /* — Marca — */
  --rk-teal:     #00607a;   /* Azul corporativo — sidebar, headers       */
  --rk-teal-d:   #004d62;   /* Teal oscuro — hover sidebar               */
  --rk-teal-l:   #007a99;   /* Teal claro — bordes activos               */
  --rk-amber:    #D97706;   /* Cobre de acción — botones CTA, acentos    */
  --rk-amber-d:  #b45309;   /* Cobre hover                               */
  --rk-amber-l:  #fef3c7;   /* Cobre fondo suave                         */
  --rk-cyan:     #5ddef4;   /* Cyan highlights en fondos oscuros         */

  /* — Compatibilidad con nombres anteriores — */
  --rk-navy:     #0a1f2e;
  --rk-navy2:    #0f2d45;
  --rk-blue:     #00607a;   /* reemplazado por teal */
  --rk-blue2:    #D97706;   /* reemplazado por amber */
  --rk-blue3:    #007a99;

  /* — Fondos app — */
  --rk-bg:       #e7ecef;   /* Lienzo general de la app                  */
  --rk-surface:  #f8f9fa;   /* Cards, tablas, contenedores               */
  --rk-surface2: #edf0f4;   /* Inputs, tablas alternas                   */

  /* — Textos — */
  --rk-text:     #1b262c;
  --rk-text2:    #334155;
  --rk-muted:    #475569;
  --rk-dim:      #94a3b8;
  --rk-text-inv: #f0f6f8;
  --rk-muted-inv:#9ec4d0;

  /* — Bordes — */
  --rk-border:   #cbd5e1;
  --rk-border-d: rgba(0,96,122,.18);
  --rk-border-d2:rgba(0,96,122,.35);

  /* — Semánticos — */
  --rk-green:    #10b981;
  --rk-green-bg: #d1fae5;
  --rk-yellow:   #f59e0b;
  --rk-yellow-bg:#fef3c7;
  --rk-red:      #ef4444;
  --rk-red-bg:   #fee2e2;

  /* — Sombras — */
  --rk-shadow-sm: 0 4px 6px -1px rgba(0,0,0,.05), 0 2px 4px -1px rgba(0,0,0,.04);
  --rk-shadow:    0 6px 16px -2px rgba(0,0,0,.09), 0 3px 8px -2px rgba(0,0,0,.06);
  --rk-shadow-lg: 0 20px 48px -8px rgba(0,0,0,.16);
  --rk-shadow-amber: 0 4px 12px rgba(217,119,6,.3);

  /* — Radios — */
  --rk-radius:    12px;
  --rk-radius-sm: 8px;
  --rk-radius-lg: 16px;
  --rk-trans:     .15s ease;

  /* — Layout — */
  --rk-sidebar-w:  280px;
  --rk-header-h:   80px;
  --rk-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* — Trama de puntos técnicos — */
  --rk-dot-color: rgba(0,96,122,.10);
  --rk-dot-size:  30px;
  --rk-dot-app:   radial-gradient(circle, rgba(0,96,122,.15) 1.5px, transparent 1.5px);
  --rk-dot-sidebar: radial-gradient(circle, rgba(255,255,255,.08) 1.5px, transparent 1.5px);
}

/* ═══════════════════════════════════════════════════════
   2. RESET Y BASE
════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; scroll-behavior: smooth; }
body { font-family: var(--rk-font); color: var(--rk-text); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--rk-border); border-radius: 10px; }

/* ═══════════════════════════════════════════════════════
   3. FONDO DE TRABAJO — trama de puntos técnicos
════════════════════════════════════════════════════════ */
.rk-dotbg,
body.rk-app {
  background-color: var(--rk-bg);
  background-image: var(--rk-dot-app);
  background-size: var(--rk-dot-size) var(--rk-dot-size);
}

/* ═══════════════════════════════════════════════════════
   4. TIPOGRAFÍA
════════════════════════════════════════════════════════ */
/* Títulos de sección — con barra ámbar izquierda */
.rk-section-title {
  font-size: 20px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  color: var(--rk-text);
  padding-left: 14px;
  border-left: 5px solid var(--rk-amber);
  line-height: 1.2;
  letter-spacing: .3px;
}
.rk-section-title.lg { font-size: 22px; }
.rk-section-title.sm { font-size: 18px; }

.rk-h1 { font-size: 28px; font-weight: 900; }
.rk-h2 { font-size: 22px; font-weight: 800; }
.rk-h3 { font-size: 17px; font-weight: 700; }
.rk-label { font-size: 11px; font-weight: 800; color: var(--rk-muted); text-transform: uppercase; letter-spacing: .7px; }
.rk-amount { color: var(--rk-amber); font-weight: 800; }
.rk-muted-text { font-size: 13px; color: var(--rk-muted); }

/* ═══════════════════════════════════════════════════════
   5. BOTONES
════════════════════════════════════════════════════════ */
.rk-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--rk-radius-sm);
  font-size: 13px;
  font-weight: 800;
  font-family: var(--rk-font);
  text-transform: uppercase;
  letter-spacing: .4px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--rk-trans);
  line-height: 1;
}
.rk-btn svg { flex-shrink: 0; }

/* Primario — cobre ámbar */
.rk-btn--primary {
  background: var(--rk-amber);
  color: #fff;
  box-shadow: var(--rk-shadow-amber);
}
.rk-btn--primary:hover {
  background: var(--rk-amber-d);
  box-shadow: 0 6px 18px rgba(217,119,6,.4);
  transform: translateY(-1px);
}

/* CTA landing — mismo ámbar pero más grande */
.rk-btn--cta {
  background: var(--rk-amber);
  color: #fff;
  font-size: 15px;
  padding: 13px 28px;
  box-shadow: var(--rk-shadow-amber);
}
.rk-btn--cta:hover { background: var(--rk-amber-d); transform: translateY(-1px); }

/* Secundario */
.rk-btn--secondary {
  background: var(--rk-surface);
  color: var(--rk-teal);
  border: 1.5px solid var(--rk-border);
}
.rk-btn--secondary:hover { border-color: var(--rk-teal); background: #f0f8fa; }

/* Ghost */
.rk-btn--ghost {
  background: transparent;
  color: var(--rk-muted);
  border: 1.5px solid transparent;
}
.rk-btn--ghost:hover { background: var(--rk-surface2); color: var(--rk-text); }

/* Danger */
.rk-btn--danger {
  background: var(--rk-surface);
  color: var(--rk-red);
  border: 1.5px solid #fca5a5;
}
.rk-btn--danger:hover { background: var(--rk-red-bg); border-color: var(--rk-red); }

/* Tamaños */
.rk-btn--sm  { padding: 6px 12px; font-size: 11px; gap: 5px; }
.rk-btn--lg  { padding: 12px 26px; font-size: 14px; }
.rk-btn--xl  { padding: 15px 36px; font-size: 16px; }

/* Botón en topbar oscuro */
.rk-btn--topbar {
  background: rgba(255,255,255,.08);
  color: #fff;
  border: 1px solid rgba(255,255,255,.2);
  font-size: 12px;
  padding: 7px 14px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  box-shadow: none;
}
.rk-btn--topbar:hover { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.4); transform: none; }
.rk-btn--topbar-primary {
  background: var(--rk-amber);
  color: #fff;
  border: none;
  font-size: 12px;
  padding: 7px 16px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 700;
}
.rk-btn--topbar-primary:hover { background: var(--rk-amber-d); transform: none; }

/* ═══════════════════════════════════════════════════════
   6. INPUTS Y FORMULARIOS
════════════════════════════════════════════════════════ */
.rk-input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--rk-border);
  border-radius: var(--rk-radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--rk-font);
  color: var(--rk-text);
  background: var(--rk-surface);
  transition: border-color var(--rk-trans), box-shadow var(--rk-trans);
  outline: none;
}
.rk-input:focus { border-color: var(--rk-teal); box-shadow: 0 0 0 3px rgba(0,96,122,.12); }
.rk-input::placeholder { color: var(--rk-dim); }
.rk-input:disabled { background: var(--rk-surface2); color: var(--rk-muted); cursor: not-allowed; }

.rk-textarea {
  height: auto;
  min-height: 90px;
  padding: 10px 13px;
  resize: vertical;
}

.rk-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6H0z' fill='%2364748b'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-color: var(--rk-surface);
  padding-right: 32px;
}

.rk-field { display: flex; flex-direction: column; gap: 6px; }
.rk-field-label {
  font-size: 11px;
  font-weight: 800;
  color: var(--rk-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
}

/* ═══════════════════════════════════════════════════════
   7. CARDS
════════════════════════════════════════════════════════ */
.rk-card {
  background: var(--rk-surface);
  border-radius: var(--rk-radius);
  border: 1px solid var(--rk-border);
  box-shadow: var(--rk-shadow-sm);
  padding: 20px;
}
.rk-card--hover { transition: transform var(--rk-trans), box-shadow var(--rk-trans), border-color var(--rk-trans); }
.rk-card--hover:hover { transform: translateY(-2px); box-shadow: var(--rk-shadow); border-color: var(--rk-teal-l); }

/* KPI cards */
.rk-kpi {
  background: var(--rk-surface);
  border-radius: var(--rk-radius);
  border: 1px solid var(--rk-border);
  padding: 20px 22px;
  box-shadow: var(--rk-shadow-sm);
}
.rk-kpi-label { font-size: 11px; font-weight: 800; color: var(--rk-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.rk-kpi-value { font-size: 28px; font-weight: 900; color: var(--rk-text); line-height: 1; }
.rk-kpi-value.amber { color: var(--rk-amber); }
.rk-kpi-sub { font-size: 12px; color: var(--rk-muted); margin-top: 5px; }

/* ═══════════════════════════════════════════════════════
   8. BADGES / ETIQUETAS DE ESTADO
════════════════════════════════════════════════════════ */
.rk-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap;
}
.rk-badge--green  { background: var(--rk-green-bg);  color: #065f46; }
.rk-badge--yellow { background: var(--rk-yellow-bg); color: #92400e; }
.rk-badge--red    { background: var(--rk-red-bg);    color: #991b1b; }
.rk-badge--teal   { background: rgba(0,96,122,.1);   color: #004d62; border: 1px solid rgba(0,96,122,.25); }
.rk-badge--amber  { background: var(--rk-amber-l);   color: #92400e; }
.rk-badge--gray   { background: #f1f5f9; color: var(--rk-muted); }

/* ═══════════════════════════════════════════════════════
   9. SIDEBAR — con trama de puntos técnicos
════════════════════════════════════════════════════════ */
.rk-sidebar {
  width: var(--rk-sidebar-w);
  background-color: var(--rk-teal);
  background-image: var(--rk-dot-sidebar);
  background-size: var(--rk-dot-size) var(--rk-dot-size);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.rk-sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}

.rk-sidebar-nav { flex: 1; padding: 12px 0; }

.rk-sidebar-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,.75);
  cursor: pointer;
  border-left: 4px solid transparent;
  transition: all var(--rk-trans);
}
.rk-sidebar-item:hover { background: rgba(255,255,255,.1); color: #fff; }
.rk-sidebar-item.active { background: rgba(255,255,255,.14); color: #fff; border-left-color: var(--rk-amber); font-weight: 700; }
.rk-sidebar-item svg { flex-shrink: 0; opacity: .8; }
.rk-sidebar-item.active svg { opacity: 1; }

/* Bloque de usuario al final del sidebar */
.rk-sidebar-user {
  margin: 12px;
  background: var(--rk-amber);
  border-radius: var(--rk-radius-sm);
  padding: 12px 14px;
  box-shadow: var(--rk-shadow-amber);
}
.rk-sidebar-user-name { font-size: 13px; font-weight: 700; color: #fff; }
.rk-sidebar-user-role { font-size: 11px; color: rgba(255,255,255,.75); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════
   10. HEADER / TOPBAR DE PÁGINAS INTERNAS
════════════════════════════════════════════════════════ */
.rk-topbar {
  background: #fff;
  height: var(--rk-header-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 28px;
  border-bottom: 1px solid var(--rk-border);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  flex-shrink: 0;
}
.rk-topbar-title {
  font-size: 20px;
  font-weight: 900;
  font-style: italic;
  text-transform: uppercase;
  color: var(--rk-text);
  padding-left: 14px;
  border-left: 5px solid var(--rk-amber);
}
.rk-topbar-spacer { flex: 1; }

/* Topbar oscuro (presupuesto) */
.rk-topbar-dark {
  background: var(--rk-teal);
  background-image: var(--rk-dot-sidebar);
  background-size: var(--rk-dot-size) var(--rk-dot-size);
  border-bottom: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}

/* ═══════════════════════════════════════════════════════
   11. TABLAS
════════════════════════════════════════════════════════ */
.rk-table { width: 100%; border-collapse: collapse; font-size: 14px; font-weight: 500; }
.rk-table th {
  padding: 11px 16px;
  font-size: 11px; font-weight: 800;
  color: var(--rk-muted);
  text-transform: uppercase; letter-spacing: .6px;
  background: var(--rk-surface2);
  border-bottom: 1px solid var(--rk-border);
  text-align: left; white-space: nowrap;
}
.rk-table td { padding: 12px 16px; border-bottom: 1px solid var(--rk-border); vertical-align: middle; }
.rk-table tr:last-child td { border-bottom: none; }
.rk-table tr:hover td { background: #f0f8fa; }
.rk-table tr.rk-row--clickable { cursor: pointer; }

/* ═══════════════════════════════════════════════════════
   12. MODALES
════════════════════════════════════════════════════════ */
.rk-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,30,40,.5);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity var(--rk-trans);
}
.rk-modal-overlay.show { opacity: 1; pointer-events: all; }
.rk-modal {
  background: var(--rk-surface);
  border-radius: var(--rk-radius-lg);
  box-shadow: var(--rk-shadow-lg);
  padding: 28px 32px;
  width: 100%; max-width: 520px; max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--rk-border);
}
.rk-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.rk-modal-title { font-size: 17px; font-weight: 800; color: var(--rk-text); }
.rk-modal-close { background: none; border: none; font-size: 20px; color: var(--rk-muted); cursor: pointer; padding: 2px 6px; border-radius: 4px; line-height: 1; }
.rk-modal-close:hover { background: var(--rk-surface2); }
.rk-modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--rk-border); }

/* ═══════════════════════════════════════════════════════
   13. LOGO — ruKa /Os
════════════════════════════════════════════════════════ */
.rk-logo-wrap {
  font-family: var(--rk-font);
  font-weight: 900;
  letter-spacing: .5px;
  white-space: nowrap;
  line-height: 1;
  color: rgba(255,255,255,.92);
}
.rk-logo-wrap .rk-logo-os {
  color: var(--rk-amber);
  font-weight: 400;
  font-family: Georgia, serif;
  letter-spacing: 0;
}
.rk-logo-wrap.on-light { color: var(--rk-teal); }
.rk-logo-wrap.on-light .rk-logo-os { color: var(--rk-amber); }

/* ═══════════════════════════════════════════════════════
   14. UTILIDADES
════════════════════════════════════════════════════════ */
.rk-divider { height: 1px; background: var(--rk-border); margin: 16px 0; }
.rk-chip { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; background: var(--rk-surface2); color: var(--rk-muted); border: 1px solid var(--rk-border); }
.rk-flex { display: flex; align-items: center; }
.rk-flex-between { display: flex; align-items: center; justify-content: space-between; }
.rk-gap-8  { gap: 8px; }  .rk-gap-12 { gap: 12px; }  .rk-gap-16 { gap: 16px; }
.rk-mt-8   { margin-top: 8px; } .rk-mt-16 { margin-top: 16px; } .rk-mt-24 { margin-top: 24px; }
.rk-w-full { width: 100%; }
.rk-text-right { text-align: right; }
.rk-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Workspace padding */
.rk-workspace { padding: 32px; }

/* Toast */
.rk-toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: var(--rk-radius-sm);
  font-size: 13px; font-weight: 600; color: #fff;
  z-index: 9999; box-shadow: var(--rk-shadow);
  transform: translateY(12px); opacity: 0;
  transition: all .2s ease; pointer-events: none;
}
.rk-toast.show { transform: translateY(0); opacity: 1; }
.rk-toast--ok  { background: var(--rk-teal); border-left: 4px solid var(--rk-amber); }
.rk-toast--err { background: #7f1d1d; border-left: 4px solid var(--rk-red); }
