/* ================================================================
   SUBPATH APP — Design System
   Archivo: assets/app.css
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,500;12..96,600;12..96,700;12..96,800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

/* ── TOKENS ────────────────────────────────────────────────────── */
:root {
  --bg:            #0A0A0F;
  --bg-2:          #111118;
  --bg-3:          #18181f;
  --bg-4:          #1E1E28;
  --border:        rgba(255,255,255,0.08);
  --border-med:    rgba(255,255,255,0.12);
  --border-hover:  rgba(249,115,22,0.35);
  --orange:        #F97316;
  --orange-dim:    #EA6C0E;
  --orange-glow:   rgba(249,115,22,0.12);
  --orange-soft:   rgba(249,115,22,0.08);
  --text:          #F0EEE8;
  --text-2:        #A09E98;
  --text-3:        #6B6966;
  --white:         #FFFFFF;
  --green:         #4ADE80;
  --green-soft:    rgba(74,222,128,0.1);
  --yellow:        #FACC15;
  --yellow-soft:   rgba(250,204,21,0.1);
  --red:           #F87171;
  --red-soft:      rgba(248,113,113,0.1);
  --blue:          #67E8F9;
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;
  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 40px rgba(0,0,0,0.5);
  --font-head:     'Bricolage Grotesque', sans-serif;
  --font-body:     'DM Sans', sans-serif;
  --font-mono:     'DM Mono', monospace;
  --nav-h:         60px;
  --sidebar-w:     240px;
  --content-max:   760px;
}

/* ── RESET ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
input, textarea, select { font-family: var(--font-body); }

/* ── NOISE TEXTURE ──────────────────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

/* ── TYPOGRAPHY ─────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: var(--font-head); letter-spacing: -0.02em; line-height: 1.15; color: var(--white); }
h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
h4 { font-size: 15px; font-weight: 600; }
p  { color: var(--text-2); line-height: 1.65; }
code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--orange);
  background: var(--orange-soft);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── LAYOUT ─────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}
.app-content {
  flex: 1;
  min-width: 0;
  padding: 36px 40px;
  max-width: calc(100vw - var(--sidebar-w));
}
.page-header {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { margin-bottom: 6px; }
.page-header p  { font-size: 14px; }

/* ── NAV ────────────────────────────────────────────────────────── */
.app-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 200;
  background: rgba(10,10,15,0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  justify-content: space-between;
}
.nav-logo {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-logo-icon {
  width: 26px; height: 26px;
  background: var(--orange);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #000; font-weight: 800;
}
.nav-logo span { color: var(--orange); }
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-avatar {
  width: 32px; height: 32px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.15s;
}
.nav-avatar:hover { border-color: var(--border-hover); }
.nav-email { font-size: 13px; color: var(--text-3); }

/* ── SIDEBAR ─────────────────────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: var(--nav-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg);
  padding: 24px 0;
  z-index: 100;
}
.app-sidebar::-webkit-scrollbar { width: 4px; }
.app-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.sidebar-section { margin-bottom: 24px; }
.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  padding: 0 16px 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text-2);
  border-left: 2px solid transparent;
  transition: all 0.15s;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-right: 8px;
}
.sidebar-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.04);
}
.sidebar-link.active {
  color: var(--orange);
  border-left-color: var(--orange);
  background: var(--orange-soft);
  font-weight: 500;
}
.sidebar-icon { font-size: 15px; flex-shrink: 0; }
.sidebar-bottom {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* ── CONTENT OFFSET ────────────────────────────────────────────── */
.app-main {
  margin-top: var(--nav-h);
  margin-left: var(--sidebar-w);
  padding: 36px 40px;
  min-height: calc(100vh - var(--nav-h));
  position: relative;
  z-index: 1;
}

/* ── CARDS ──────────────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s;
  position: relative;
  overflow: hidden;
}
.card:hover { border-color: var(--border-med); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-family: var(--font-head); font-size: 16px; font-weight: 700; color: var(--white); }
.card-sub { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ── GRID ───────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── STAT CARDS ─────────────────────────────────────────────────── */
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); margin-bottom: 8px; }
.stat-value { font-family: var(--font-head); font-size: 30px; font-weight: 800; color: var(--white); letter-spacing: -0.03em; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--orange);
  color: #000;
  font-weight: 600;
}
.btn-primary:hover:not(:disabled) {
  background: var(--orange-dim);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(249,115,22,0.28);
}
.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-med);
  background: var(--bg-4);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-3);
  color: var(--text);
}
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
.btn-danger:hover:not(:disabled) {
  background: rgba(248,113,113,0.18);
}
.btn-sm { font-size: 13px; padding: 6px 13px; }
.btn-lg { font-size: 15px; padding: 12px 24px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }
.btn-loading { pointer-events: none; opacity: 0.7; }

/* ── FORMS ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 7px;
}
.form-label span { color: var(--text-3); font-weight: 400; }
.form-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(249,115,22,0.1);
}
.form-input::placeholder { color: var(--text-3); }
.form-input.error { border-color: var(--red); }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 5px; display: none; }
.form-error.show { display: block; }
.input-prefix-group { display: flex; }
.input-prefix {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: var(--radius) 0 0 var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text-3);
  white-space: nowrap;
  display: flex;
  align-items: center;
}
.input-prefix + .form-input { border-radius: 0 var(--radius) var(--radius) 0; }

/* ── BADGES / STATUS ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 9px;
  border-radius: 100px;
}
.badge::before { content: '●'; font-size: 7px; }
.badge-active   { background: var(--green-soft);  color: var(--green);  border: 1px solid rgba(74,222,128,0.2); }
.badge-pending  { background: var(--yellow-soft); color: var(--yellow); border: 1px solid rgba(250,204,21,0.2); }
.badge-error    { background: var(--red-soft);    color: var(--red);    border: 1px solid rgba(248,113,113,0.2); }
.badge-inactive { background: var(--bg-3);        color: var(--text-3); border: 1px solid var(--border); }
.badge-pro      { background: var(--orange-glow); color: var(--orange); border: 1px solid rgba(249,115,22,0.2); }

/* ── TABLE ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-2); border-bottom: 1px solid var(--border); }
thead th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  text-align: left;
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }
tbody td { padding: 13px 16px; font-size: 14px; color: var(--text-2); vertical-align: middle; }
.td-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text); }

/* ── ALERTS ─────────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.alert-icon { font-size: 15px; flex-shrink: 0; }
.alert-body { line-height: 1.55; }
.alert-info    { background: rgba(103,232,249,0.07); border: 1px solid rgba(103,232,249,0.2); color: #A5F3FC; }
.alert-warn    { background: rgba(249,115,22,0.08);  border: 1px solid rgba(249,115,22,0.2);  color: #FDBA74; }
.alert-success { background: var(--green-soft);      border: 1px solid rgba(74,222,128,0.2);  color: #86EFAC; }
.alert-error   { background: var(--red-soft);        border: 1px solid rgba(248,113,113,0.2); color: #FCA5A5; }
.alert { display: none; }
.alert.show { display: flex; }

/* ── MODAL ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(8px);
  transition: transform 0.2s;
  position: relative;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header { margin-bottom: 24px; }
.modal-header h3 { font-size: 20px; margin-bottom: 6px; }
.modal-header p  { font-size: 14px; color: var(--text-3); }
.modal-close {
  position: absolute;
  top: 20px; right: 20px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  cursor: pointer;
  font-size: 16px;
  transition: all 0.15s;
}
.modal-close:hover { color: var(--text); border-color: var(--border-med); }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── EMPTY STATE ─────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}
.empty-icon { font-size: 40px; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p  { font-size: 14px; color: var(--text-3); max-width: 340px; margin: 0 auto 24px; }

/* ── DIVIDERS ────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.section-gap { margin-bottom: 32px; }

/* ── TOAST ──────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  min-width: 280px;
  max-width: 380px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--orange); }
@keyframes toast-in { from { opacity:0; transform: translateX(16px); } to { opacity:1; transform: translateX(0); } }

/* ── SPINNER ────────────────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── COPY BLOCK ────────────────────────────────────────────────── */
.copy-block {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}
.copy-block code {
  background: none;
  padding: 0;
  font-size: 13px;
  color: var(--text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  background: var(--bg-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  font-family: var(--font-body);
}
.copy-btn:hover { color: var(--text); border-color: var(--border-med); }

/* ── RESPONSIVE ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); transition: transform 0.3s; }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; padding: 24px 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
