/* ── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #0d0d0d;
  --surface:   #161616;
  --surface2:  #1f1f1f;
  --border:    #2a2a2a;
  --accent:    #4ade80;
  --accent-dim: #22c55e22;
  --text:      #e8e8e8;
  --text-muted: #666;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --info:      #3b82f6;
  --sidebar-w: 220px;
  --radius:    10px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       font-size: 14px; background: var(--bg); color: var(--text);
       display: flex; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ───────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-height: 100vh; background: var(--surface);
  border-right: 1px solid var(--border); padding: 24px 0; flex-shrink: 0;
  position: fixed; top: 0; left: 0; bottom: 0;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px 24px; border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 15px; font-weight: 700; color: var(--accent); }
.nav-links { list-style: none; padding: 16px 0; }
.nav-links li a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text-muted); transition: all .15s;
}
.nav-links li a:hover, .nav-links li a.active {
  color: var(--text); background: var(--accent-dim);
  text-decoration: none; border-right: 2px solid var(--accent);
}
.nav-links li a.active { color: var(--accent); }

/* ── Main content ──────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w); padding: 32px; flex: 1; min-height: 100vh;
  max-width: 1400px;
}

/* ── Page header ───────────────────────────────────────────────────────────── */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 28px; gap: 16px;
}
.page-header h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.subtitle { color: var(--text-muted); font-size: 13px; }
.back-link { color: var(--text-muted); font-size: 13px; display: block; margin-bottom: 6px; }
.header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px;
           display: flex; align-items: center; gap: 8px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: #22c55e; color: #000; border-color: #22c55e; }
.btn-secondary { background: var(--surface2); }
.btn-success { background: #16a34a22; color: var(--accent); border-color: #16a34a; }
.btn-success:hover { background: #16a34a; color: #000; }
.btn-danger { background: #ef444422; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ── Inputs ────────────────────────────────────────────────────────────────── */
.input {
  width: 100%; padding: 9px 12px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 6px; color: var(--text);
  font-size: 13px; font-family: inherit; transition: border-color .15s;
}
.input:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 90px; }
.select-input {
  padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 13px; cursor: pointer;
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 12px; color: var(--text-muted);
                    margin-bottom: 6px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.hint { color: var(--text-muted); font-size: 11px; display: block; margin-top: 4px; }

/* ── Alerts ────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}
.alert-success { background: #16a34a22; border: 1px solid #16a34a55; color: var(--accent); }
.alert-error   { background: #ef444422; border: 1px solid #ef444455; color: var(--danger); }
.alert-info    { background: #3b82f622; border: 1px solid #3b82f655; color: #93c5fd; }

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-active  { background: #16a34a22; color: var(--accent); }
.badge-paused  { background: #f59e0b22; color: var(--warning); }
.badge-closed  { background: #33333355; color: var(--text-muted); }
.badge-count { background: var(--surface2); border: 1px solid var(--border);
               padding: 2px 8px; border-radius: 12px; font-size: 12px; color: var(--text-muted); }

/* ── Stats row ─────────────────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; text-align: center;
}
.stat-number { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ── Data table ────────────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.clickable-row { cursor: pointer; transition: background .1s; }
.clickable-row:hover td { background: var(--surface2); }
.prospect-name { font-weight: 600; margin-bottom: 2px; }
.prospect-meta { font-size: 12px; color: var(--text-muted); }
.next-phase-date { font-size: 13px; font-weight: 500; }
.next-phase-date.overdue { color: var(--danger); }
.phase-purpose { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.phase-count { font-size: 13px; }
.objecion-cell { font-size: 12px; color: var(--text-muted); max-width: 200px; }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px !important; }
.overdue-tag { background: #ef444422; color: var(--danger); font-size: 10px;
               padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
.text-muted { color: var(--text-muted); }

/* ── Prospect detail layout ────────────────────────────────────────────────── */
.prospect-grid { display: grid; grid-template-columns: 400px 1fr; gap: 16px; align-items: start; }
.col-left, .col-right { display: flex; flex-direction: column; }
.info-row { display: flex; flex-direction: column; gap: 4px; padding: 10px 0;
            border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.objecion-tag { color: var(--warning); font-size: 13px; }
.inline-form { display: flex; flex-direction: column; gap: 8px; margin-top: 16px;
               padding-top: 16px; border-top: 1px solid var(--border); }

/* ── Payment links ─────────────────────────────────────────────────────────── */
.payment-link-row { display: flex; justify-content: space-between; align-items: center;
                    padding: 10px 0; border-bottom: 1px solid var(--border); }
.link-label { font-weight: 600; font-size: 13px; }
.link-url { font-size: 12px; color: var(--text-muted); }

/* ── Transcript ────────────────────────────────────────────────────────────── */
.transcript-box { font-size: 12px; color: var(--text-muted); white-space: pre-wrap;
                  line-height: 1.7; max-height: 400px; overflow-y: auto; }
.transcript-box.collapsed { max-height: 80px; overflow: hidden; position: relative; }
.transcript-box.collapsed::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40px;
  background: linear-gradient(transparent, var(--surface));
}

/* ── Phases ────────────────────────────────────────────────────────────────── */
.phases-list { display: flex; flex-direction: column; gap: 10px; }
.phase-item { border: 1px solid var(--border); border-radius: 8px; padding: 14px; transition: border-color .15s; }
.phase-pending { border-left: 3px solid var(--accent); }
.phase-sent    { border-left: 3px solid #333; opacity: .7; }
.phase-cancelled { border-left: 3px solid #333; opacity: .4; }
.phase-header { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.phase-num { background: var(--accent-dim); color: var(--accent); border-radius: 6px;
             padding: 3px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.phase-info { flex: 1; min-width: 0; }
.phase-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.phase-date.overdue { color: var(--danger); }
.phase-actions { display: flex; gap: 6px; flex-shrink: 0; }
.phase-message { font-size: 13px; color: var(--text); background: var(--surface2);
                 border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; line-height: 1.6; }
.phase-edit-form { margin-top: 10px; }

/* ── Responses ─────────────────────────────────────────────────────────────── */
.responses-list { display: flex; flex-direction: column; gap: 10px; }
.response-bubble { background: var(--surface2); border-radius: 8px; padding: 12px 14px;
                   border-left: 3px solid var(--info); }
.response-bubble.reoptimized { border-left-color: var(--accent); }
.response-text { font-size: 13px; margin-bottom: 6px; }
.response-meta { font-size: 11px; color: var(--text-muted); }

/* ── Training ──────────────────────────────────────────────────────────────── */
.training-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.training-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.training-header h2 { font-size: 17px; font-weight: 700; }
.training-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.materials-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.material-item { border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.material-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.material-title { font-size: 14px; }
.material-actions { display: flex; gap: 6px; }
.material-content { font-size: 12px; color: var(--text-muted); white-space: pre-wrap;
                    max-height: 100px; overflow: hidden; line-height: 1.6; }
.material-edit-form { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.add-material-form { border-top: 1px solid var(--border); padding-top: 20px;
                     display: flex; flex-direction: column; gap: 10px; }
.add-material-form h4 { font-size: 13px; color: var(--text-muted); }

/* ── Settings ──────────────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.info-box { background: var(--surface2); border-radius: 8px; padding: 12px;
            font-size: 12px; line-height: 1.8; margin-top: 16px; border: 1px solid var(--border); }
.info-box code { background: var(--surface); padding: 2px 6px; border-radius: 4px;
                 font-family: monospace; color: var(--accent); }

/* ── Animations ────────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sync progress ─────────────────────────────────────────────────────────── */
.progress-bar-wrap { background: var(--surface2); border-radius: 99px; height: 8px;
                     margin-bottom: 10px; overflow: hidden; }
.progress-bar-fill { background: var(--accent); height: 100%; border-radius: 99px;
                     transition: width .4s ease; }
.sync-status-msg   { font-size: 13px; color: var(--text-muted); margin-bottom: 10px; }
.sync-log          { display: flex; flex-direction: column; gap: 6px;
                     max-height: 260px; overflow-y: auto; }
.sync-log-row      { display: flex; align-items: baseline; gap: 8px;
                     font-size: 13px; padding: 6px 10px; border-radius: 6px; }
.sync-log-ok       { background: #16a34a11; }
.sync-log-err      { background: #ef444411; }
.sync-log-check    { font-size: 12px; flex-shrink: 0; }
.sync-log-ok .sync-log-check  { color: var(--accent); }
.sync-log-err .sync-log-check { color: var(--danger); }
.sync-log-name     { font-weight: 600; }
.sync-log-tipo     { font-size: 11px; color: var(--text-muted); }
.sync-log-obj      { font-size: 11px; color: var(--text-muted); font-style: italic;
                     white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
                     max-width: 400px; }

/* ── Estado tipo badges ────────────────────────────────────────────────────── */
.badge-pending_approval { background: #a855f722; color: #c084fc; }

.approval-banner {
  display: flex; justify-content: space-between; align-items: center;
  background: #a855f711; border: 1px solid #a855f755;
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 20px; gap: 16px;
}
.approval-banner-text { display: flex; flex-direction: column; gap: 4px; }
.approval-banner-text strong { color: #c084fc; font-size: 15px; }
.approval-banner-text span   { font-size: 13px; color: var(--text-muted); }

.badge-tipo-no_cierre { background: #ef444422; color: #f87171; }
.badge-tipo-no_show   { background: #f59e0b22; color: #fbbf24; }
.badge-tipo-reserva   { background: #3b82f622; color: #60a5fa; }
.badge-tipo-pendiente { background: #eab30822; color: #fde047; }

/* ── Payment links grid ────────────────────────────────────────────────────── */
.payment-links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
                      gap: 12px; margin-bottom: 16px; }
.payment-link-card { border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
.payment-link-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }
