/* Bulk Mailer Web — Clean Light Theme */
:root {
    --bg: #f8f9fa;
    --bg2: #ffffff;
    --bg3: #f0f1f3;
    --fg: #1a1a2e;
    --fg2: #6c757d;
    --accent: #4361ee;
    --accent-light: #eef1ff;
    --green: #2d9f5a;
    --green-light: #e8f5e9;
    --red: #dc3545;
    --red-light: #fce4ec;
    --yellow: #f0a500;
    --yellow-light: #fff8e1;
    --border: #dee2e6;
    --border-light: #e9ecef;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
    --sidebar-w: 220px;
    --transition: .15s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--fg);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Sidebar ──────────────────────────────────── */

.sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 8px;
}

.sidebar-brand h2 {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 1.5px;
    color: var(--accent);
    text-transform: uppercase;
}

.sidebar-brand small {
    font-size: 11px;
    color: var(--fg2);
    font-weight: 400;
}

.sidebar-section {
    padding: 8px 12px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--fg2);
    opacity: .7;
}

.sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--fg2);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 0 var(--radius) var(--radius) 0;
    margin-right: 8px;
    transition: all var(--transition);
}

.sidebar a:hover {
    background: var(--bg3);
    color: var(--fg);
}

.sidebar a.active {
    background: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

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

/* ── Main Content ─────────────────────────────── */

.main {
    flex: 1;
    padding: 28px 36px;
    overflow-y: auto;
    max-width: 1200px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--fg);
}

.page-header .subtitle {
    font-size: 13px;
    color: var(--fg2);
    font-weight: 400;
    margin-left: 12px;
}

/* ── Cards ────────────────────────────────────── */

.card {
    background: var(--bg2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--fg);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header .count {
    background: var(--bg3);
    color: var(--fg2);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

.card h3 {
    font-size: 15px;
    margin-bottom: 14px;
    color: var(--fg);
    font-weight: 600;
}

/* ── Tables ───────────────────────────────────── */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th, td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

th {
    background: var(--bg3);
    color: var(--fg2);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

tbody tr:hover {
    background: var(--bg3);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ── Forms ────────────────────────────────────── */

input, select, textarea {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 9px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    width: 100%;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, .12);
}

input::placeholder, textarea::placeholder {
    color: #adb5bd;
}

input[type="file"] {
    padding: 7px;
    font-size: 12px;
}

label {
    display: block;
    font-size: 12px;
    color: var(--fg2);
    font-weight: 600;
    margin-bottom: 4px;
    margin-top: 12px;
}

label:first-child { margin-top: 0; }

.form-help {
    font-size: 11px;
    color: var(--fg2);
    margin-top: 2px;
    opacity: .8;
}

/* ── Buttons ──────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition);
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #3651d4; box-shadow: var(--shadow); }

.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c82333; }

.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #248a4d; }

.btn-secondary { background: var(--bg3); color: var(--fg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border-light); }

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }

.btn-icon { padding: 5px 8px; }

.btn-group {
    display: flex;
    gap: 6px;
}

/* ── Progress ─────────────────────────────────── */

.progress {
    background: var(--bg3);
    border-radius: 4px;
    height: 22px;
    overflow: hidden;
}

.progress-bar {
    background: var(--green);
    height: 100%;
    transition: width .3s;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    line-height: 22px;
    color: #fff;
    min-width: fit-content;
    padding: 0 6px;
}

/* ── Badges ───────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.badge-running { background: var(--green-light); color: var(--green); }
.badge-paused { background: var(--yellow-light); color: var(--yellow); }
.badge-draft { background: var(--bg3); color: var(--fg2); }
.badge-finished { background: var(--accent-light); color: var(--accent); }
.badge-failed { background: var(--red-light); color: var(--red); }
.badge-info { background: var(--accent-light); color: var(--accent); }

/* ── Tabs ─────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 16px;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: none;
    color: var(--fg2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition);
    font-family: inherit;
}

.tab-btn:hover { color: var(--fg); }

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Collapsible / Details ────────────────────── */

details {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 12px;
    background: var(--bg2);
}

details summary {
    padding: 12px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--fg);
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

details summary::before {
    content: "▸";
    font-size: 12px;
    color: var(--fg2);
    transition: transform var(--transition);
}

details[open] summary::before {
    transform: rotate(90deg);
}

details .details-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border-light);
}

/* ── Grid Layouts ─────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Metrics / Stats ──────────────────────────── */

.metric {
    text-align: center;
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.metric .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--fg);
}

.metric .label {
    font-size: 11px;
    color: var(--fg2);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-top: 2px;
}

/* ── Log Viewer ───────────────────────────────── */

.log {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    max-height: 350px;
    overflow-y: auto;
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--fg);
}

/* ── Alerts ───────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #c3e6cb; }
.alert-danger { background: var(--red-light); color: var(--red); border: 1px solid #f5c6cb; }
.alert-info { background: var(--accent-light); color: var(--accent); border: 1px solid #c3d1ff; }
.alert-warning { background: var(--yellow-light); color: #856404; border: 1px solid #ffeeba; }

/* ── File List ────────────────────────────────── */

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    margin-bottom: 6px;
    font-size: 12px;
}

.file-item .file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fg);
    font-family: 'SF Mono', monospace;
}

/* ── Empty State ──────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--fg2);
}

.empty-state .icon { font-size: 32px; margin-bottom: 8px; opacity: .5; }
.empty-state p { font-size: 13px; }

/* ── Section Divider ──────────────────────────── */

.divider {
    border-top: 1px solid var(--border-light);
    margin: 16px 0;
}

/* ── Inline Form Row ──────────────────────────── */

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.form-row > * { flex: 1; }
.form-row > .shrink { flex: 0 0 auto; }

/* ── Toast ────────────────────────────────────── */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--green);
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    z-index: 1000;
    box-shadow: var(--shadow-md);
    font-size: 13px;
    font-weight: 500;
}

/* ── Responsive ───────────────────────────────── */

@media (max-width: 900px) {
    .sidebar { width: 60px; overflow: hidden; }
    .sidebar a span { display: none; }
    .sidebar-brand h2 { font-size: 10px; }
    .sidebar-brand small { display: none; }
    .sidebar-section { display: none; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main { padding: 16px; }
}
