/* ============================================================
   RKOM — Dark Theme (PKOM-style)
   ============================================================ */

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

:root {
    --bg-main:        #0c1017;
    --bg-secondary:   #111822;
    --bg-card:        #151c28;
    --bg-card-hover:  #1a2332;
    --bg-input:       #1a2332;
    --bg-sidebar:     #0a0f16;

    --accent:         #10b981;
    --accent-dark:    #059669;
    --accent-light:   #34d399;
    --accent-glow:    rgba(16, 185, 129, 0.25);

    --success:        #22c55e;
    --danger:         #ef4444;
    --warning:        #eab308;
    --info:           #38bdf8;

    --text-primary:   #e2e8f0;
    --text-secondary: #8892a4;
    --text-muted:     #4a5568;

    --border:         rgba(255, 255, 255, 0.06);
    --border-accent:  rgba(16, 185, 129, 0.35);

    --shadow-card:    0 2px 12px rgba(0, 0, 0, 0.5);
    --shadow-hover:   0 6px 24px rgba(0, 0, 0, 0.6);
    --shadow-accent:  0 4px 20px rgba(16, 185, 129, 0.15);

    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;

    --transition: 0.2s ease;

    --sidebar-width: 200px;
}

body.light-theme {
    --bg-main:        #f0f2f5;
    --bg-secondary:   #ffffff;
    --bg-card:        #ffffff;
    --bg-card-hover:  #f8f9fb;
    --bg-input:       #f0f2f5;
    --bg-sidebar:     #f7f8fa;
    --border:         rgba(0, 0, 0, 0.08);
    --text-primary:   #1a202c;
    --text-secondary: #4a5568;
    --text-muted:     #a0aec0;
    --shadow-card:    0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-hover:   0 6px 24px rgba(0, 0, 0, 0.1);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Base ─────────────────────────────────────────────────── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 14px;
}

h1, h2, h3 { color: var(--text-primary); font-weight: 700; }
h1 { font-size: 1.5rem; margin-bottom: 1.25rem; }
h2 { font-size: 1.2rem; margin-bottom: 0.75rem; }
h3 { font-size: 1rem; margin-bottom: 0.5rem; }

a { color: var(--accent-light); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent); }

/* ── App Layout: sidebar + main ──────────────────────────── */
#app {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 200;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.4rem 1.25rem 1.2rem;
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    border-bottom: 1px solid var(--border);
}

.sidebar-menu {
    padding: 0.6rem 0;
    flex: 1;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 1.15rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    color: var(--text-primary);
    background: rgba(16, 185, 129, 0.05);
}

.sidebar-menu a.active {
    color: var(--text-primary);
    background: rgba(16, 185, 129, 0.08);
    border-left-color: var(--accent);
}

.sidebar-menu a .nav-icon {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 0.85rem 1.15rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-footer .ws-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.sidebar-footer .ws-indicator.connected {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
    animation: pulse-green 2s infinite;
}

/* ── Main content area ───────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.75rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    margin-right: auto;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.82rem;
    letter-spacing: 0.3px;
}

/* Theme toggle */
.theme-toggle {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition);
    line-height: 1;
}
.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent-light);
}

/* ── Container ────────────────────────────────────────────── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1.75rem;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

/* ── Auth (login / register) ─────────────────────────────── */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    margin-left: calc(-1 * var(--sidebar-width));
    width: calc(100% + var(--sidebar-width));
    background: radial-gradient(ellipse at center top, rgba(16, 185, 129, 0.04) 0%, transparent 70%);
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.4s ease;
}

.auth-card h1 {
    text-align: center;
    font-size: 1.9rem;
    margin-bottom: 0.3rem;
    color: var(--text-primary);
}

.subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 1.75rem;
    font-size: 0.88rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

/* ── Forms ────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: all var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--bg-card);
}

.form-group textarea {
    resize: vertical;
    min-height: 90px;
}

.form-group small {
    display: block;
    margin-top: 0.3rem;
    color: var(--text-muted);
    font-size: 0.76rem;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: var(--shadow-accent);
    width: 100%;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-light);
}

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; transform: translateY(-1px); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; transform: translateY(-1px); }

.btn-warning { background: var(--warning); color: #1a1a1a; }
.btn-warning:hover:not(:disabled) { background: #ca8a04; }

.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.76rem;
    width: auto;
}

/* ── Cards ────────────────────────────────────────────────── */
.account-card,
.mailing-card,
.session-card,
.campaign-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
}

.account-card:hover,
.mailing-card:hover,
.session-card:hover,
.campaign-card:hover {
    border-color: var(--border-accent);
    box-shadow: var(--shadow-hover);
    transform: translateY(-1px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.65rem;
    margin-top: 0.65rem;
}

.info-item { display: flex; flex-direction: column; gap: 0.15rem; }

.info-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.info-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.85rem;
    flex-wrap: wrap;
}

/* ── Stats grid ───────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-top: 0.85rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.15rem;
    box-shadow: var(--shadow-card);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    opacity: 0;
    transition: opacity var(--transition);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 0.45rem;
}

.stat-card .stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--accent-light);
    line-height: 1;
}

.stat-card p {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-top: 0.35rem;
}

/* ── Grid layouts ─────────────────────────────────────────── */
.accounts-grid,
.mailings-list,
.sessions-list,
.invites-list,
.autoreplies-list,
.stories-list,
.comments-list,
.inter-warming-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 0.85rem;
}

/* ── Dashboard accounts table (PKOM-style) ───────────────── */
.dashboard-table-wrap {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.dashboard-table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.15rem 1.35rem 0.85rem;
}

.dashboard-table-header h2 { margin: 0; font-size: 1.1rem; }

.active-count-badge {
    background: transparent;
    color: var(--accent-light);
    border: 1.5px solid var(--accent);
    padding: 0.28rem 0.85rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
}

/* ── Status badges ────────────────────────────────────────── */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.22rem 0.65rem;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-new      { background: #3b82f6; color: #fff; }
.status-warming  { background: #eab308; color: #1a1a1a; }
.status-ready    { background: #22c55e; color: #fff; }
.status-blocked  { background: #ef4444; color: #fff; }
.status-cooling  { background: #f97316; color: #fff; }
.status-draft    { background: #8b5cf6; color: #fff; }
.status-running  { background: #22c55e; color: #fff; }
.status-completed{ background: #10b981; color: #fff; }
.status-paused   { background: #6b7280; color: #fff; }
.status-failed   { background: #ef4444; color: #fff; }
.status-in_progress { background: #22c55e; color: #fff; }
.status-not_started { background: #6b7280; color: #fff; }

/* ── Traffic light ────────────────────────────────────────── */
.traffic-light {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.65rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.traffic-light::before {
    content: '';
    width: 7px; height: 7px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.traffic-light.green  { background: rgba(34, 197, 94, 0.12); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.25); }
.traffic-light.green::before  { background: #4ade80; box-shadow: 0 0 6px #4ade80; animation: pulse-green 2s infinite; }
.traffic-light.yellow { background: rgba(234, 179, 8, 0.12); color: #facc15; border: 1px solid rgba(234, 179, 8, 0.25); }
.traffic-light.yellow::before { background: #facc15; box-shadow: 0 0 6px #facc15; animation: pulse-yellow 2s infinite; }
.traffic-light.red    { background: rgba(239, 68, 68, 0.12); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.25); }
.traffic-light.red::before    { background: #f87171; box-shadow: 0 0 6px #f87171; animation: pulse-red 2s infinite; }

@keyframes pulse-green  { 0%,100%{ box-shadow:0 0 3px #4ade80; } 50%{ box-shadow:0 0 10px #4ade80, 0 0 16px rgba(74,222,128,.25); } }
@keyframes pulse-yellow { 0%,100%{ box-shadow:0 0 3px #facc15; } 50%{ box-shadow:0 0 10px #facc15, 0 0 16px rgba(250,204,21,.25); } }
@keyframes pulse-red    { 0%,100%{ box-shadow:0 0 3px #f87171; } 50%{ box-shadow:0 0 10px #f87171, 0 0 16px rgba(248,113,113,.25); } }

/* ── Progress bar ─────────────────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 0.35rem;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-light));
    transition: width 0.5s ease;
    min-width: 2px;
}

.progress-fill.success { background: linear-gradient(90deg, var(--success), #4ade80); }
.progress-fill.warning { background: linear-gradient(90deg, var(--warning), #facc15); }
.progress-fill.danger  { background: linear-gradient(90deg, var(--danger),  #f87171); }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 1.65rem;
    border-radius: var(--radius-lg);
    max-width: 620px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
    animation: slideUp 0.2s ease;
}

.modal-content h2 { margin-bottom: 0.85rem; font-size: 1.15rem; }

.modal-close {
    position: absolute;
    top: 0.85rem; right: 0.85rem;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    width: 26px; height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all var(--transition);
    background: transparent;
    border: none;
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-input); }

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.15rem;
    right: 1.15rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    background: var(--bg-card);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-card);
    pointer-events: auto;
    animation: toastIn 0.25s ease;
    max-width: 320px;
    word-break: break-word;
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error   { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info    { border-left: 3px solid var(--info); }
.toast-icon    { font-size: 1rem; flex-shrink: 0; }
.toast-out     { animation: toastOut 0.25s ease forwards; }

@keyframes toastIn  { from { opacity:0; transform:translateX(100%); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { from { opacity:1; transform:translateX(0); }   to { opacity:0; transform:translateX(100%); } }

/* ── Error / Success messages ─────────────────────────────── */
.error-message {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.85rem;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 0.85rem;
    animation: shake 0.4s ease;
}

.success-message {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.85rem;
    border: 1px solid rgba(34, 197, 94, 0.3);
    font-size: 0.85rem;
}

/* ── Loading ──────────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
}

.badge-accent  { background: rgba(16,185,129,0.15); color: var(--accent-light); }
.badge-success { background: rgba(34,197,94,0.15);   color: #4ade80; }
.badge-danger  { background: rgba(239,68,68,0.25);   color: #f87171; }
.badge-warning { background: rgba(234,179,8,0.15);   color: #facc15; }
.badge-muted   { background: var(--bg-input);         color: var(--text-secondary); }

.tab-buttons { display: flex; gap: 0.5rem; }
.tab-buttons .btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ── Table ────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 0.7rem 1.1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.68rem;
    letter-spacing: 0.6px;
}

td { color: var(--text-primary); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

/* ── Inter-warming account selector ──────────────────────── */
.account-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.55rem;
    margin: 0.55rem 0;
}

.account-selector-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.8rem;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
}

.account-selector-item:hover { border-color: var(--accent); background: rgba(16,185,129,0.05); }
.account-selector-item.selected { border-color: var(--accent); background: rgba(16,185,129,0.1); color: var(--accent-light); }
.account-selector-item input[type="checkbox"] { accent-color: var(--accent); width: auto; padding: 0; background: none; border: none; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn  { from { opacity:0; } to { opacity:1; } }
@keyframes shake   { 0%,100%{ transform:translateX(0); } 25%{ transform:translateX(-5px); } 75%{ transform:translateX(5px); } }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    :root { --sidebar-width: 0px; }
    .sidebar { display: none; }
    .main-content { margin-left: 0; }

    .container { padding: 1rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .card-info { grid-template-columns: 1fr; }
    .auth-card { padding: 1.75rem; }
    .modal-content { padding: 1.15rem; width: 96%; }
    .card-actions { flex-direction: column; }
    .btn-small { width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
