/* ====================================================
   styles.css — WhatsApp Bot Panel (Camino 3)
   Dark Mode Premium Design System
   ==================================================== */

/* ── Variables ── */
:root {
    --bg-base:      #0a0f1e;
    --bg-card:      #1e293b;
    --bg-hover:     #263347;
    --bg-input:     #0f172a;
    --primary:      #6366f1;
    --primary-h:    #4f46e5;
    --accent:       #8b5cf6;
    --success:      #10b981;
    --warning:      #f59e0b;
    --danger:       #ef4444;
    --text-main:    #f1f5f9;
    --text-muted:   #64748b;
    --text-dim:     #94a3b8;
    --border:       rgba(255,255,255,.08);
    --shadow:       0 4px 24px rgba(0,0,0,.4);
    --sidebar-w:    260px;
    --radius:       12px;
    --radius-sm:    8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background: var(--bg-base); color: var(--text-main); height: 100vh; overflow: hidden; }
button, input, select, textarea { font-family: 'Inter', sans-serif; }
a { color: var(--primary); text-decoration: none; }
textarea, .input-styled { width: 100%; margin-top: 4px; }
textarea {
    padding: 12px 14px; background: var(--bg-input); border: 1px solid #334155;
    border-radius: var(--radius-sm); color: var(--text-main); font-size: .9rem;
    resize: vertical; transition: border-color .2s;
}
textarea:focus, input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.15); }
input, .input-styled {
    width: 100%; padding: 10px 14px; background: var(--bg-input);
    border: 1px solid #334155; border-radius: var(--radius-sm);
    color: var(--text-main); font-size: .9rem; margin-top: 4px;
    transition: border-color .2s;
}
.input-styled { cursor: pointer; }
label { display: block; font-size: .8rem; color: var(--text-dim); font-weight: 500; margin-top: 14px; }

/* ── Layout ── */
.app-container { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: var(--bg-card); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 0;
    overflow-y: auto;
}
.sidebar-header { padding: 20px 16px 12px; border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.brand-icon { font-size: 1.8rem; }
.brand h2 { font-size: 1rem; font-weight: 700; color: var(--text-main); line-height: 1.2; }
.brand-badge { font-size: .68rem; color: var(--primary); background: rgba(99,102,241,.15); padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.user-info { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: .82rem; color: var(--text-dim); }
.user-name { flex: 1; font-weight: 500; }
.logout-link { color: var(--danger); font-size: 1rem; cursor: pointer; transition: opacity .2s; }
.logout-link:hover { opacity: .7; }
.wa-status-badge {
    display: flex; align-items: center; gap: 8px;
    background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.2);
    border-radius: 20px; padding: 5px 12px; font-size: .72rem; color: var(--success);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.pulse-green { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(16,185,129,.4)} 50%{box-shadow:0 0 0 8px rgba(16,185,129,0)} }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 14px 10px; flex: 1; }
.nav-btn {
    background: transparent; border: none; border-radius: var(--radius-sm);
    padding: 11px 14px; text-align: left; cursor: pointer;
    font-size: .875rem; color: var(--text-muted); font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text-main); }
.nav-btn.active { background: var(--primary); color: white; }

/* ── Main ── */
.main-area { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.app-section { display: none; flex-direction: column; height: 100%; padding: 28px 32px; overflow-y: auto; }
.app-section.active { display: flex; }
.section-header { margin-bottom: 24px; }
.section-header h1 { font-size: 1.4rem; font-weight: 700; }
.section-header .section-sub { font-size: .82rem; color: var(--text-muted); }

/* ── Buttons ── */
.btn-primary {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 20px; background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white; border: none; border-radius: var(--radius-sm);
    font-size: .875rem; font-weight: 600; cursor: pointer;
    transition: opacity .2s, transform .1s; white-space: nowrap;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:active { transform: scale(.98); }

/* ── Loading ── */
.loading-block { color: var(--text-muted); font-size: .9rem; padding: 20px; text-align: center; }

/* ── Kanban ── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; height: 100%; padding-bottom: 16px; }
.kanban-col {
    min-width: 240px; background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); display: flex; flex-direction: column; max-height: 100%;
}
.kanban-col-header {
    padding: 14px 16px; border-radius: var(--radius) var(--radius) 0 0;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.kanban-col-title { font-size: .85rem; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kanban-count {
    background: rgba(255,255,255,.1); color: var(--text-dim);
    border-radius: 20px; padding: 2px 8px; font-size: .72rem; font-weight: 600;
}
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.kanban-card {
    background: var(--bg-hover); border-radius: var(--radius-sm);
    padding: 12px; cursor: pointer;
    border: 1px solid transparent;
    transition: border-color .15s, transform .15s;
}
.kanban-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.card-name { font-size: .85rem; font-weight: 600; margin-bottom: 4px; }
.card-phone { font-size: .75rem; color: var(--text-muted); margin-bottom: 6px; }
.card-msg { font-size: .75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.card-assignee { font-size: .7rem; color: var(--text-muted); }
.card-time { font-size: .68rem; color: var(--text-muted); }

/* ── Stats ── */
.stats-container { display: flex; flex-direction: column; gap: 20px; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; }
.kpi-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; text-align: center;
}
.kpi-icon { font-size: 1.8rem; margin-bottom: 8px; }
.kpi-value { font-size: 1.8rem; font-weight: 700; color: var(--text-main); }
.kpi-label { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
.stages-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stage-bar-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.stage-bar-label { font-size: .78rem; color: var(--text-dim); margin-bottom: 6px; }
.stage-bar-val { font-size: 1.2rem; font-weight: 700; }
.chart-placeholder { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-title { font-size: .9rem; font-weight: 600; margin-bottom: 14px; }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 80px; }
.mini-bar { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; transition: height .3s; }
.mini-bar:hover { background: var(--accent); }

/* ── Chats ── */
.chats-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }
.contacts-list {
    width: 280px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow-y: auto; flex-shrink: 0;
}
.contact-item { padding: 14px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background .15s; }
.contact-item:hover { background: var(--bg-hover); }
.contact-item.active { background: rgba(99,102,241,.15); border-left: 3px solid var(--primary); }
.contact-name { font-size: .875rem; font-weight: 600; }
.contact-preview { font-size: .75rem; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-window {
    flex: 1; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0;
}
.chat-placeholder { color: var(--text-muted); margin: auto; font-size: .9rem; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble-wrap { display: flex; flex-direction: column; max-width: 70%; }
.msg-bubble-wrap.enviado { align-self: flex-end; }
.msg-bubble-wrap.recibido { align-self: flex-start; }
.bubble {
    padding: 10px 14px; border-radius: var(--radius); font-size: .875rem; line-height: 1.5;
}
.recibido .bubble { background: var(--bg-hover); border-bottom-left-radius: 4px; }
.enviado .bubble { background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.enviado.humano .bubble { background: var(--accent); }
.bubble-meta { font-size: .68rem; color: var(--text-muted); margin-top: 4px; }
.enviado .bubble-meta { text-align: right; }
.chat-header-bar { padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: .9rem; }

/* ── Config ── */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.config-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.config-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.config-hint { font-size: .8rem; color: var(--text-muted); margin-bottom: 12px; }
.api-key-status { font-size: .78rem; margin-top: 6px; padding: 6px 10px; border-radius: 6px; display: none; }
.api-key-status.set { background: rgba(16,185,129,.12); color: var(--success); display: block; }
.api-key-status.unset { background: rgba(239,68,68,.1); color: #fca5a5; display: block; }
.knowledge-add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.knowledge-add-row input { flex: 1; }
.knowledge-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.knowledge-item { display: flex; justify-content: space-between; align-items: center; background: var(--bg-hover); border-radius: var(--radius-sm); padding: 10px 12px; }
.knowledge-title { font-size: .82rem; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-tipo { font-size: .68rem; background: rgba(99,102,241,.2); color: var(--primary); padding: 2px 8px; border-radius: 20px; margin: 0 8px; flex-shrink: 0; }
.knowledge-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: .9rem; flex-shrink: 0; }

/* ── Team ── */
.team-layout { display: flex; gap: 20px; }
.team-layout .config-card:first-child { flex: 1; }
.users-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.users-table th { text-align: left; color: var(--text-muted); padding: 8px; border-bottom: 1px solid var(--border); font-weight: 500; }
.users-table td { padding: 10px 8px; border-bottom: 1px solid var(--border); }
.badge-rol { padding: 2px 8px; border-radius: 20px; font-size: .7rem; font-weight: 600; }
.badge-admin { background: rgba(99,102,241,.2); color: var(--primary); }
.badge-asesor { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-activo { background: rgba(16,185,129,.15); color: var(--success); }
.badge-inactivo { background: rgba(239,68,68,.1); color: var(--danger); }

/* ── Drawer lateral (contacto CRM) ──────────────────────────── */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000; backdrop-filter: blur(3px);
    opacity: 0; transition: opacity .25s;
    pointer-events: none;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(520px, 100vw);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    box-shadow: -8px 0 40px rgba(0,0,0,.4);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.drawer-header h2 { flex: 1; font-size: 1rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.2rem; cursor: pointer; padding: 4px 8px;
    border-radius: 6px; transition: background .15s, color .15s;
}
.drawer-close:hover { background: var(--bg-hover); color: var(--text-main); }

.drawer-body {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 0;
}

/* Secciones internas del drawer */
.drawer-section { margin-bottom: 24px; }
.drawer-section-title {
    font-size: .72rem; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--text-muted);
    margin-bottom: 12px; padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

/* Chat dentro del drawer */
.drawer-chat {
    background: var(--bg-input); border-radius: var(--radius-sm);
    padding: 12px; display: flex; flex-direction: column;
    gap: 8px; max-height: 320px; overflow-y: auto;
    min-height: 80px;
}
.load-more-btn {
    width: 100%; background: var(--bg-hover); border: 1px solid var(--border);
    color: var(--text-dim); font-size: .78rem; border-radius: var(--radius-sm);
    padding: 8px; cursor: pointer; transition: background .15s;
    margin-bottom: 10px;
}
.load-more-btn:hover { background: rgba(99,102,241,.15); color: var(--primary); }

/* Botones de acción del drawer */
.drawer-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0; background: var(--bg-card);
}
.drawer-actions .btn-primary { flex: 1; min-width: 90px; justify-content: center; }
.btn-danger  { background: rgba(239,68,68,.15) !important; color: #fca5a5 !important; border: 1px solid rgba(239,68,68,.25) !important; }
.btn-danger:hover  { background: var(--danger) !important; color: white !important; }
.btn-archive { background: rgba(245,158,11,.12) !important; color: var(--warning) !important; border: 1px solid rgba(245,158,11,.2) !important; }
.btn-archive:hover { background: var(--warning) !important; color: #0a0f1e !important; }

/* Activity list */
.drawer-activity { display: flex; flex-direction: column; gap: 8px; }
.activity-item { background: var(--bg-hover); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .8rem; }
.activity-meta { font-size: .7rem; color: var(--text-muted); margin-top: 4px; }

/* ── Msg Box ─────────────────────────────────────────────── */
.msg-box { margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: .85rem; }
.msg-box.success { background: rgba(16,185,129,.12); color: var(--success); border: 1px solid rgba(16,185,129,.3); }
.msg-box.error   { background: rgba(239,68,68,.1); color: #fca5a5; border: 1px solid rgba(239,68,68,.2); }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

