/* ============================================================
   FollowUp Pro v2.0 — Styles
   ============================================================ */

:root {
    --bg-primary: #0c0f14;
    --bg-secondary: #13171e;
    --bg-card: #191e27;
    --bg-card-hover: #1e2430;
    --bg-input: #1a1f28;
    --border: #262d3a;
    --border-light: #2e3647;
    --text-primary: #e8ecf1;
    --text-secondary: #8892a4;
    --text-muted: #5e6a7e;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --orange: #f97316;
    --purple: #a855f7;
    --sidebar-w: 230px;
    --radius: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── LOGIN ─────────────────────────────────────────────── */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59,130,246,0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(168,85,247,0.04) 0%, transparent 50%),
        var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 48px 40px;
    width: 380px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

.login-logo .logo-icon { font-size: 40px; margin-bottom: 12px; }
.login-logo h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-logo p { color: var(--text-secondary); font-size: 14px; margin-bottom: 32px; }

.login-form input {
    width: 100%; padding: 14px 16px;
    background: var(--bg-input); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text-primary);
    font-size: 15px; font-family: inherit; margin-bottom: 16px; outline: none;
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.login-form button {
    width: 100%; padding: 14px;
    background: var(--accent); color: #fff; border: none;
    border-radius: var(--radius); font-size: 15px;
    font-weight: 600; font-family: inherit; cursor: pointer;
}
.login-form button:hover { background: var(--accent-hover); }

.login-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; }

/* ── APP LAYOUT ────────────────────────────────────────── */

.app-screen { display: flex; min-height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w); background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border);
}
.logo-icon-sm { font-size: 22px; }
.logo-text { font-size: 17px; font-weight: 700; }

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border-radius: var(--radius);
    color: var(--text-secondary); text-decoration: none;
    font-size: 14px; font-weight: 500; margin-bottom: 2px;
    transition: all 0.15s ease;
}
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }
.nav-icon { font-size: 16px; }

.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); }

.wa-status {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; background: var(--bg-card);
    border-radius: var(--radius-sm); font-size: 13px;
    color: var(--text-secondary); margin-bottom: 10px;
}

.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--text-muted); flex-shrink: 0;
}
.status-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.waiting { background: var(--yellow); animation: pulse 1.5s infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

.btn-logout {
    width: 100%; padding: 10px; background: transparent;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 13px;
    font-family: inherit; cursor: pointer;
}
.btn-logout:hover { background: var(--red-bg); border-color: var(--red); color: var(--red); }

/* ── MAIN ──────────────────────────────────────────────── */

.main-content {
    margin-left: var(--sidebar-w); flex: 1;
    min-height: 100vh; display: flex; flex-direction: column;
}

/* ── TOPBAR ────────────────────────────────────────────── */

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 28px; border-bottom: 1px solid var(--border);
    background: var(--bg-secondary); position: sticky; top: 0; z-index: 50;
}
.topbar-left h2 { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

.ist-clock {
    font-family: 'JetBrains Mono', monospace; font-size: 13px;
    color: var(--text-secondary); background: var(--bg-card);
    padding: 6px 12px; border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.hamburger {
    display: none; background: none; border: 1px solid var(--border);
    color: var(--text-primary); font-size: 20px; padding: 6px 10px;
    border-radius: var(--radius-sm); cursor: pointer; margin-right: 12px;
}

/* ── BUTTONS ───────────────────────────────────────────── */

.btn-primary {
    padding: 10px 18px; background: var(--accent); color: #fff;
    border: none; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 8px 14px; font-size: 13px; }

.btn-secondary {
    padding: 10px 18px; background: transparent;
    color: var(--text-secondary); border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 14px;
    font-weight: 500; font-family: inherit; cursor: pointer;
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* ── SECTION ───────────────────────────────────────────── */

.section { padding: 24px 28px; }

/* ── QR BANNER ─────────────────────────────────────────── */

.qr-banner {
    background: var(--bg-card); border: 1px solid var(--yellow);
    border-radius: var(--radius); padding: 28px;
    text-align: center; margin-bottom: 24px;
}
.qr-banner h3 { color: var(--yellow); margin-bottom: 16px; font-size: 16px; }
.qr-banner img { max-width: 220px; border-radius: 8px; margin-bottom: 12px; }
.qr-banner p { color: var(--text-muted); font-size: 13px; }

/* ── SUMMARY CARDS ─────────────────────────────────────── */

.summary-grid {
    display: grid; grid-template-columns: repeat(5, 1fr);
    gap: 16px; margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; text-align: center;
}
.summary-card:hover { border-color: var(--border-light); }

.card-value {
    font-size: 32px; font-weight: 700;
    font-family: 'JetBrains Mono', monospace; margin-bottom: 4px;
}
.card-label {
    font-size: 13px; color: var(--text-secondary);
    text-transform: uppercase; letter-spacing: 0.5px;
}

.card-total .card-value   { color: var(--accent); }
.card-pending .card-value { color: var(--yellow); }
.card-paused .card-value  { color: var(--purple); }
.card-done .card-value    { color: var(--green); }
.card-due .card-value     { color: var(--red); }

/* ── FILTERS ───────────────────────────────────────────── */

.filters-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.filter-group { display: flex; gap: 10px; }

.filters-bar select, .search-box input {
    padding: 10px 14px; background: var(--bg-card);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: inherit; font-size: 13px; outline: none;
}
.filters-bar select:focus, .search-box input:focus { border-color: var(--accent); }
.search-box input { min-width: 220px; }

/* ── TASK TABLE ────────────────────────────────────────── */

.table-wrap {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow-x: auto;
}

.task-table { width: 100%; border-collapse: collapse; font-size: 14px; }

.task-table thead th {
    padding: 14px 16px; text-align: left; font-size: 12px;
    font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    white-space: nowrap; background: var(--bg-secondary);
}

.task-table tbody tr {
    border-bottom: 1px solid var(--border); transition: background 0.15s;
}
.task-table tbody tr:last-child { border-bottom: none; }
.task-table tbody tr:hover { background: var(--bg-card-hover); }
.task-table tbody tr.row-overdue { background: rgba(239,68,68,0.04); }

.task-table td { padding: 14px 16px; vertical-align: middle; }

.td-name { font-weight: 600; }
.td-number { font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text-secondary); }
.td-desc { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.td-freq { font-size: 13px; color: var(--text-muted); }

.td-remaining { font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600; }
.remaining-due { color: var(--red); animation: pulse 1.5s infinite; }
.remaining-soon { color: var(--orange); }
.remaining-ok { color: var(--green); }
.remaining-na { color: var(--text-muted); }

/* ── BADGES ────────────────────────────────────────────── */

.badge {
    display: inline-block; padding: 4px 10px; border-radius: 20px;
    font-size: 12px; font-weight: 600; text-transform: capitalize;
}
.badge-pending { background: var(--yellow-bg); color: var(--yellow); }
.badge-paused  { background: rgba(168,85,247,0.1); color: var(--purple); }
.badge-done    { background: var(--green-bg); color: var(--green); }
.badge-high    { background: var(--red-bg); color: var(--red); }
.badge-medium  { background: var(--yellow-bg); color: var(--yellow); }
.badge-low     { background: rgba(59,130,246,0.1); color: var(--accent); }

/* ── ACTION BUTTONS ────────────────────────────────────── */

.actions-cell { display: flex; gap: 4px; flex-wrap: wrap; }

.btn-action {
    padding: 5px 10px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: transparent;
    color: var(--text-secondary); font-size: 12px;
    font-family: inherit; cursor: pointer; white-space: nowrap;
    transition: all 0.15s;
}
.btn-action:hover { background: var(--bg-card-hover); color: var(--text-primary); border-color: var(--border-light); }
.btn-action.send { color: var(--green); border-color: rgba(34,197,94,0.3); }
.btn-action.send:hover { background: var(--green-bg); }
.btn-action.danger { color: var(--red); border-color: rgba(239,68,68,0.3); }
.btn-action.danger:hover { background: var(--red-bg); }

/* ── EMPTY STATE ───────────────────────────────────────── */

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ── MODALS ────────────────────────────────────────────── */

.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px); display: flex;
    align-items: center; justify-content: center;
    z-index: 1000; padding: 20px;
}

.modal-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 14px; width: 100%; max-width: 480px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    max-height: 90vh; display: flex; flex-direction: column;
}
.modal-wide { max-width: 600px; }

.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 24px; cursor: pointer; padding: 0; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ── FORM ROWS ─────────────────────────────────────────── */

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.form-row input, .form-row select {
    width: 100%; padding: 11px 14px; background: var(--bg-input);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: inherit; font-size: 14px; outline: none;
}
.form-row input:focus, .form-row select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }

.form-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.form-msg.success { color: var(--green); }
.form-msg.error { color: var(--red); }

/* ── TIMELINE ──────────────────────────────────────────── */

.timeline-content { max-height: 400px; overflow-y: auto; }

.timeline-entry { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.timeline-entry:last-child { border-bottom: none; }

.timeline-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.timeline-dot.bot_automated { background: var(--accent); }
.timeline-dot.manual_send { background: var(--green); }
.timeline-dot.status_change { background: var(--yellow); }
.timeline-dot.task_created { background: var(--purple); }
.timeline-dot.task_edited { background: var(--orange); }

.timeline-info { flex: 1; }
.timeline-msg { font-size: 14px; margin-bottom: 4px; word-break: break-word; }
.timeline-meta { font-size: 12px; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; }

.timeline-type {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.timeline-type.bot_automated { background: rgba(59,130,246,0.1); color: var(--accent); }
.timeline-type.manual_send { background: var(--green-bg); color: var(--green); }
.timeline-type.status_change { background: var(--yellow-bg); color: var(--yellow); }
.timeline-type.task_created { background: rgba(168,85,247,0.1); color: var(--purple); }
.timeline-type.task_edited { background: rgba(249,115,22,0.1); color: var(--orange); }

/* ── SETTINGS ──────────────────────────────────────────── */

.settings-panel { max-width: 500px; }
.settings-panel h3 { font-size: 16px; margin-bottom: 16px; }
.settings-panel hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }
.settings-wa-row { font-size: 14px; color: var(--text-secondary); }

.sys-info {
    font-family: 'JetBrains Mono', monospace; font-size: 13px;
    color: var(--text-secondary); background: var(--bg-input);
    padding: 16px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); line-height: 1.8;
}

/* ── RESPONSIVE ────────────────────────────────────────── */

@media (max-width: 1024px) {
    .summary-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.5); }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .summary-grid { grid-template-columns: repeat(2, 1fr); }
    .section { padding: 16px; }
    .topbar { padding: 12px 16px; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filter-group { flex-wrap: wrap; }
    .search-box input { min-width: 100%; width: 100%; }
    .task-table { font-size: 13px; }
    .task-table thead th, .task-table td { padding: 10px 12px; }
    .td-desc { max-width: 120px; }
    .login-card { width: 100%; margin: 16px; padding: 32px 24px; }
}

@media (max-width: 480px) {
    .summary-grid { grid-template-columns: 1fr 1fr; }
    .card-value { font-size: 24px; }
    .summary-card { padding: 14px; }
}

/* ── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── TOAST ─────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    padding: 14px 20px; border-radius: var(--radius);
    font-size: 14px; font-weight: 500; z-index: 2000;
    animation: slideUp 0.3s ease; max-width: 360px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.toast.success { background: var(--green); color: #fff; }
.toast.error { background: var(--red); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
