/* ════════════════════════════════════════════════════════════
   CorpVoice Design System — cv-shell.css
   Shared design tokens, layout shell, components
   ════════════════════════════════════════════════════════════ */

/* ── Fonts ── */
@font-face{font-family:'Satoshi';src:url('/fonts/Satoshi-Regular.otf') format('opentype');font-weight:400;font-style:normal}
@font-face{font-family:'Satoshi';src:url('/fonts/Satoshi-Medium.otf') format('opentype');font-weight:500;font-style:normal}
@font-face{font-family:'Satoshi';src:url('/fonts/Satoshi-Bold.otf') format('opentype');font-weight:700;font-style:normal}
@font-face{font-family:'Satoshi';src:url('/fonts/Satoshi-Black.otf') format('opentype');font-weight:900;font-style:normal}

/* ── Tokens ── */
:root {
  --bg:          #0A0E1A;
  --surface:     #111827;
  --surface-2:   #161D2E;
  --surface-3:   #1C2640;
  --border:      #1E2A3E;
  --border-2:    #263347;
  --navy:        #000040;
  --blue:        #004FFF;
  --cyan:        #00CFFF;
  --text-1:      #F1F5F9;
  --text-2:      #94A3B8;
  --text-3:      #64748B;
  --text-4:      #374151;
  --green:       #22D3A0;
  --amber:       #F59E0B;
  --red:         #F87171;
  --purple:      #A78BFA;
  --nav-w:       220px;
  --header-h:    52px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.2);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
}

/* ── Reset ── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{height:100%}
body{font-family:'Satoshi',system-ui,-apple-system,sans-serif;color:var(--text-1);background:var(--bg);line-height:1.6;-webkit-font-smoothing:antialiased}
a{text-decoration:none;color:inherit}

/* ════════════════════════════════════════════════════════════
   SHELL LAYOUT
   Pages that use sidebar: add class "cv-shell" to body
   ════════════════════════════════════════════════════════════ */

/* Sidebar */
#cv-nav {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--nav-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .22s cubic-bezier(.4,0,.2,1);
}
#cv-nav .nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#cv-nav .nav-logo img { height: 22px; }
#cv-nav .nav-logo-text {
  font-family: 'Satoshi', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.2px;
}
#cv-nav .nav-logo-text span { color: var(--cyan); }

#cv-nav .nav-items {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: none;
}
#cv-nav .nav-items::-webkit-scrollbar { display: none; }

#cv-nav .nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-4);
  padding: 6px 8px 4px;
  margin-top: 8px;
}

#cv-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .12s, color .12s;
  border: 1px solid transparent;
  user-select: none;
  text-decoration: none;
}
#cv-nav .nav-item:hover {
  background: var(--surface-2);
  color: var(--text-1);
}
#cv-nav .nav-item.active {
  background: rgba(0,79,255,0.12);
  border-color: rgba(0,79,255,0.2);
  color: #fff;
}
#cv-nav .nav-item.active .nav-icon { color: var(--cyan); }

#cv-nav .nav-icon {
  font-size: 16px;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-3);
  transition: color .12s;
}

/* Badge de pendientes */
.nav-pending-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}

.nav-historial-badge {
  display: none;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #f59e0b;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  margin-left: auto;
  flex-shrink: 0;
}

#cv-nav .nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 8px;
}

#cv-nav .nav-bottom {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#cv-nav .nav-bottom .nav-item { color: var(--text-3); }
#cv-nav .nav-bottom .nav-item:hover { color: var(--red); background: rgba(248,113,113,0.06); }

/* Hamburger */
#cv-hamburger {
  display: none;
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 300;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--text-2);
  font-size: 18px;
  transition: background .12s;
}
#cv-hamburger:hover { background: var(--surface-2); }

#cv-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 190;
  backdrop-filter: blur(2px);
}

/* Header */
#cv-header {
  position: fixed;
  top: 0;
  left: var(--nav-w);
  right: 0;
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
}
#cv-header .header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
#cv-header .header-tenant {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
}
#cv-header .header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
#cv-header .header-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  border: 1px solid var(--border-2);
  flex-shrink: 0;
}
#cv-header .header-avatar:hover { border-color: var(--cyan); }

/* Main content area (pages with sidebar) */
.cv-main {
  margin-left: var(--nav-w);
  padding-top: var(--header-h);
  min-height: 100vh;
}
.cv-main-inner {
  padding: 32px 28px 64px;
  max-width: 1100px;
}
.cv-main-inner.narrow { max-width: 700px; }
.cv-main-inner.wide { max-width: 1200px; }

/* ── Page header ── */
.cv-page-header { margin-bottom: 24px; }
.cv-page-header h1 {
  font-family: 'Satoshi', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-1);
  margin-bottom: 4px;
}
.cv-page-header p {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── Cards ── */
.cv-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.cv-card-body { padding: 20px 24px; }
.cv-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.cv-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-1);
}
.cv-card-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 1px;
}

/* ── Buttons ── */
.cv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-size: 13px;
  padding: 8px 16px;
  line-height: 1.4;
}
.cv-btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.cv-btn-primary {
  background: linear-gradient(135deg, #001a80, var(--blue));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0,79,255,0.3);
}
.cv-btn-primary:hover:not(:disabled) { filter: brightness(1.1); box-shadow: 0 4px 14px rgba(0,79,255,0.45); }

.cv-btn-secondary {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.cv-btn-secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--text-1); }

.cv-btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: none;
}
.cv-btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text-1); }

.cv-btn-danger {
  background: rgba(248,113,113,0.08);
  color: var(--red);
  border: 1px solid rgba(248,113,113,0.2);
}
.cv-btn-danger:hover:not(:disabled) { background: rgba(248,113,113,0.14); }

.cv-btn-sm { font-size: 12px; padding: 6px 12px; }
.cv-btn-lg { font-size: 14px; padding: 11px 22px; }

/* ── Form elements ── */
.cv-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}
.cv-input, .cv-select, .cv-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 10px 13px;
  color: var(--text-1);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.cv-input::placeholder, .cv-textarea::placeholder { color: var(--text-4); }
.cv-input:focus, .cv-select:focus, .cv-textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,79,255,0.12);
}
.cv-input.error, .cv-textarea.error { border-color: var(--red); }
.cv-select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}
.cv-textarea { resize: vertical; }
.cv-field { margin-bottom: 16px; }
.cv-helper { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.cv-err { font-size: 12px; color: var(--red); margin-top: 4px; }

/* ── Badges ── */
.cv-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.cv-badge-blue   { background: rgba(0,79,255,0.12);  color: #6B9FFF; border: 1px solid rgba(0,79,255,0.2); }
.cv-badge-cyan   { background: rgba(0,207,255,0.1);  color: var(--cyan); border: 1px solid rgba(0,207,255,0.2); }
.cv-badge-green  { background: rgba(34,211,160,0.1); color: var(--green); border: 1px solid rgba(34,211,160,0.2); }
.cv-badge-amber  { background: rgba(245,158,11,0.1); color: var(--amber); border: 1px solid rgba(245,158,11,0.2); }
.cv-badge-red    { background: rgba(248,113,113,0.1);color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
.cv-badge-purple { background: rgba(167,139,250,0.1);color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.cv-badge-gray   { background: rgba(255,255,255,0.06);color: var(--text-3); border: 1px solid var(--border); }

/* ── Skeleton loaders ── */
@keyframes cv-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.cv-skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
  background-size: 800px 100%;
  animation: cv-shimmer 1.4s ease-in-out infinite;
  border-radius: 4px;
}
.cv-skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.cv-skeleton-text.wide { width: 80%; }
.cv-skeleton-text.mid { width: 55%; }
.cv-skeleton-text.short { width: 35%; }
.cv-skeleton-block { border-radius: var(--radius); }

/* ── Toasts ── */
#cv-toasts {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.cv-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-1);
  pointer-events: all;
  animation: cv-toast-in .22s cubic-bezier(.4,0,.2,1);
  max-width: 360px;
}
.cv-toast.out { animation: cv-toast-out .18s forwards; }
.cv-toast-icon { font-size: 15px; flex-shrink: 0; }
.cv-toast.success { border-left: 3px solid var(--green); }
.cv-toast.error   { border-left: 3px solid var(--red); }
.cv-toast.info    { border-left: 3px solid var(--cyan); }
.cv-toast.warning { border-left: 3px solid var(--amber); }
@keyframes cv-toast-in {
  from { opacity:0; transform: translateX(20px); }
  to   { opacity:1; transform: translateX(0); }
}
@keyframes cv-toast-out {
  to { opacity:0; transform: translateX(20px); }
}

/* ── Dividers ── */
.cv-divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Alert / banner ── */
.cv-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.cv-alert-warning { background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.25); color: var(--amber); }
.cv-alert-info    { background: rgba(0,207,255,0.06);  border: 1px solid rgba(0,207,255,0.2); color: var(--cyan); }
.cv-alert-error   { background: rgba(248,113,113,0.08);border: 1px solid rgba(248,113,113,0.2);color: var(--red); }

/* ── Table ── */
.cv-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cv-table thead tr { border-bottom: 1px solid var(--border); }
.cv-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
}
.cv-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.cv-table tbody tr:last-child { border-bottom: none; }
.cv-table tbody tr:hover { background: rgba(255,255,255,0.015); }
.cv-table tbody td { padding: 14px 16px; vertical-align: middle; }

/* ── Modal ── */
.cv-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  overflow-y: auto;
}
.cv-modal-backdrop.visible { display: flex; }
.cv-modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: cv-modal-in .18s cubic-bezier(.4,0,.2,1);
}
@keyframes cv-modal-in {
  from { opacity:0; transform:scale(.97) translateY(8px); }
  to   { opacity:1; transform:scale(1) translateY(0); }
}
.cv-modal h2 {
  font-family: 'Satoshi', sans-serif;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}
.cv-modal .modal-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 20px;
  line-height: 1.6;
}
.cv-modal .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Info rows ── */
.cv-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cv-info-row:last-child { border-bottom: none; }
.cv-info-label { color: var(--text-3); font-size: 12px; font-weight: 500; }
.cv-info-value { color: var(--text-1); font-weight: 500; }

/* ── Empty state ── */
.cv-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-3);
}
.cv-empty-icon { font-size: 36px; margin-bottom: 12px; opacity: .5; }
.cv-empty h3 { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.cv-empty p { font-size: 13px; line-height: 1.6; }

/* ── Responsive ── */
@media (max-width: 768px) {
  #cv-nav { transform: translateX(-100%); }
  #cv-nav.open { transform: translateX(0); }
  #cv-nav-overlay.open { display: block; }
  #cv-hamburger { display: flex; width: 44px; height: 44px; font-size: 20px; }
  #cv-header { left: 0; padding-left: 60px; }
  .cv-main { margin-left: 0; }
  .cv-main-inner { padding: 20px 16px 48px; }
  /* Nav items: bigger tap targets */
  #cv-nav .nav-item { min-height: 44px; }
  /* Buttons: minimum tap target */
  .cv-btn { min-height: 44px; }
  /* Toasts: anchor to bottom */
  #cv-toasts { top: auto; bottom: 0; right: 0; left: 0; padding: 0 16px calc(16px + env(safe-area-inset-bottom)); align-items: stretch; }
  .cv-toast { max-width: 100%; animation-name: cv-toast-in-mb; }
  .cv-toast.out { animation-name: cv-toast-out-mb; }
  /* Modal: bottom sheet */
  .cv-modal-backdrop { align-items: flex-end; padding: 0; }
  .cv-modal { border-radius: 20px 20px 0 0; max-width: 100%; max-height: 90dvh; padding: 24px 20px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); animation-name: cv-sheet-in; }
  /* Form inputs: prevent iOS auto-zoom (requires ≥16px) */
  .cv-input, .cv-select, .cv-textarea { font-size: 16px; }
  /* Table: ensure horizontal scroll works */
  .cv-card { overflow-x: auto; }
}
/* Mobile animation keyframes */
@keyframes cv-toast-in-mb {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes cv-toast-out-mb {
  to { opacity: 0; transform: translateY(10px); }
}
@keyframes cv-sheet-in {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
