/* ============================================
   AI Sensy Clone — Design System
   Palette inspired by WhatsApp's signal-green + late-night ops console
   ============================================ */
:root {
    --bg: #0e1613;
    --bg-panel: #141f1b;
    --bg-card: #182621;
    --border: #25362f;
    --text: #eaf2ee;
    --text-dim: #8fa39a;
    --text-faint: #5d7268;
    --signal: #25d366;       /* WhatsApp green, used sparingly */
    --signal-dim: #1a9c4a;
    --amber: #e8b04b;
    --red: #e8654b;
    --font-display: 'Fraunces', Georgia, serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14.5px;
    line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::selection { background: var(--signal-dim); color: #fff; }

/* ---- Auth pages ---- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 20% 20%, rgba(37,211,102,0.08), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(37,211,102,0.05), transparent 40%),
        var(--bg);
    padding: 20px;
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
}
.auth-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}
.auth-brand .dot { color: var(--signal); font-size: 28px; line-height: 1; }
.auth-brand h1 { font-family: var(--font-display); font-size: 22px; font-weight: 600; }
.auth-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
    margin-bottom: 6px;
}
.field input, .field select, .field textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--signal-dim);
}
.field textarea { resize: vertical; min-height: 80px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--signal);
    color: #06120c;
    border: none;
    border-radius: 7px;
    padding: 10px 18px;
    font-weight: 600;
    font-size: 14px;
    transition: transform .1s, background .15s;
}
.btn:hover { background: #2ee579; }
.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--signal-dim); background: rgba(37,211,102,0.06); }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.auth-foot { margin-top: 20px; text-align: center; font-size: 13px; color: var(--text-dim); }
.auth-foot a { color: var(--signal); font-weight: 600; }

.error-msg {
    background: rgba(232,101,75,0.12);
    border: 1px solid rgba(232,101,75,0.3);
    color: #ff9a82;
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}
.success-msg {
    background: rgba(37,211,102,0.12);
    border: 1px solid rgba(37,211,102,0.3);
    color: var(--signal);
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* ---- App Shell ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 24px;
}
.sidebar-brand .dot { color: var(--signal); font-size: 22px; }
.sidebar-brand span { font-family: var(--font-display); font-size: 17px; font-weight: 600; }

.nav-group { margin-bottom: 18px; }
.nav-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    padding: 0 10px 6px;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 7px;
    color: var(--text-dim);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .12s, color .12s;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { background: rgba(37,211,102,0.1); color: var(--signal); }
.nav-link .icon { width: 16px; text-align: center; font-size: 14px; }

.sidebar-foot {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.user-chip {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px;
    border-radius: 7px;
}
.user-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--signal-dim);
    color: #06120c;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-info .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .plan { font-size: 11px; color: var(--text-faint); }
.logout-link { font-size: 12px; color: var(--text-faint); margin-top: 6px; display: block; padding: 4px 8px; }
.logout-link:hover { color: var(--red); }

.main {
    flex: 1;
    min-width: 0;
    padding: 28px 36px;
}
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { font-family: var(--font-display); font-size: 24px; font-weight: 600; }
.page-header p { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

/* ---- Cards / Stats ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.stat-card .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin-bottom: 8px; }
.stat-card .value { font-family: var(--font-display); font-size: 30px; font-weight: 600; }
.stat-card .sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
}
.card h3 { font-family: var(--font-display); font-size: 16px; font-weight: 600; margin-bottom: 14px; }

/* ---- Table ---- */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); }
td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
}
.badge-sent, .badge-active, .badge-success, .badge-completed { background: rgba(37,211,102,0.15); color: var(--signal); }
.badge-failed, .badge-suspended { background: rgba(232,101,75,0.15); color: var(--red); }
.badge-pending, .badge-running, .badge-draft { background: rgba(232,176,75,0.15); color: var(--amber); }

/* ---- Toolbar / Filters ---- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.toolbar input, .toolbar select { background: var(--bg-card); border: 1px solid var(--border); border-radius: 7px; padding: 8px 12px; color: var(--text); font-size: 13px; }
.toolbar .spacer { flex: 1; }

/* ---- Inbox layout ---- */
.inbox-layout { display: grid; grid-template-columns: 300px 1fr; gap: 0; height: calc(100vh - 130px); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.conv-list { background: var(--bg-panel); border-right: 1px solid var(--border); overflow-y: auto; }
.conv-item { padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.conv-item:hover, .conv-item.active { background: var(--bg-card); }
.conv-item .name { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.conv-item .preview { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pane { display: flex; flex-direction: column; background: var(--bg); }
.chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--bg-panel); font-weight: 600; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.msg-bubble { max-width: 65%; padding: 9px 13px; border-radius: 12px; font-size: 13.5px; line-height: 1.4; }
.msg-out { align-self: flex-end; background: var(--signal-dim); color: #fff; border-bottom-right-radius: 3px; }
.msg-in { align-self: flex-start; background: var(--bg-card); border: 1px solid var(--border); border-bottom-left-radius: 3px; }
.msg-time { font-size: 10px; opacity: 0.6; margin-top: 4px; }
.chat-input { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); background: var(--bg-panel); }
.chat-input input { flex: 1; background: var(--bg-card); border: 1px solid var(--border); border-radius: 7px; padding: 10px 14px; color: var(--text); }

/* ---- Plans ---- */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.plan-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.plan-card.current { border-color: var(--signal-dim); box-shadow: 0 0 0 1px var(--signal-dim); }
.plan-card .name { font-family: var(--font-display); font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.plan-card .price { font-size: 26px; font-weight: 700; margin: 10px 0; }
.plan-card .price span { font-size: 12px; color: var(--text-faint); font-weight: 400; }
.plan-card ul { list-style: none; margin: 14px 0; font-size: 12.5px; color: var(--text-dim); }
.plan-card li { padding: 4px 0; }
.plan-card li::before { content: "✓ "; color: var(--signal); }

/* ---- Misc ---- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-faint); }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.modal-box h3 { font-family: var(--font-display); margin-bottom: 16px; }
.modal-close-row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

@media (max-width: 880px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; }
    .main { padding: 18px; }
    .inbox-layout { grid-template-columns: 1fr; height: auto; }
}
