/* Newsletter App v2 — Minimalist Redesign */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --sidebar-bg: #ffffff;
    --sidebar-hover: #f5f6fa;
    --sidebar-active-bg: #eef0ff;
    --sidebar-border: #e8eaf0;
    --accent: #4f46e5;
    --accent-light: #eef0ff;
    --accent-text: #ffffff;
    --text: #111827;
    --text-muted: #6b7280;
    --text-light: #9ca3af;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --danger: #ef4444;
    --success: #22c55e;
    --info: #3b82f6;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
}

html { font-size: 15px; }

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR ── */
.sidebar {
    width: 220px;
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    border-right: 1px solid var(--sidebar-border);
}

.sidebar-brand {
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 6px;
}

.sidebar-brand span {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.nav-section {
    padding: 14px 10px 6px;
    flex: 1;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-light);
    padding: 0 8px;
    margin-bottom: 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.12s;
    margin-bottom: 1px;
}

.nav-link svg {
    width: 15px;
    height: 15px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--text);
}

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

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

.admin-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-link {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.1s;
}
.logout-link:hover { color: var(--accent); }

/* ── MAIN ── */
.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 32px 36px;
    max-width: 1280px;
}

/* ── PAGE HEADER ── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: var(--text);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ── STATS GRID ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
}

.stat-card.c1::before { background: var(--accent); }
.stat-card.c2::before { background: var(--success); }
.stat-card.c3::before { background: var(--info); }
.stat-card.c4::before { background: var(--warning); }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -1px;
    color: var(--text);
    line-height: 1;
}

.stat-sub {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 6px;
}

/* ── CARD ── */
.card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.card-body { padding: 20px; }

/* ── TABLE ── */
.table-wrapper { overflow-x: auto; }

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

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

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafaf9; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.12s;
    white-space: nowrap;
    letter-spacing: -0.1px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4338ca; }

.btn-accent { background: var(--accent-light); color: var(--accent); }
.btn-accent:hover { background: #dfe3ff; }

.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg); }

.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }

.btn-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.btn-success:hover { background: #dcfce7; }

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

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 5px;
    letter-spacing: -0.1px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="time"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    color: var(--text);
    background: var(--surface);
    transition: border-color 0.12s, box-shadow 0.12s;
    outline: none;
    -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(17,17,16,0.08);
}

textarea { resize: vertical; min-height: 100px; line-height: 1.5; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── ALERTS ── */
.alert {
    padding: 11px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 18px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── BADGES ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
}
.badge-success { background: #f0fdf4; color: #16a34a; }
.badge-warning { background: #fffbeb; color: #d97706; }
.badge-info    { background: #eff6ff; color: #2563eb; }
.badge-danger  { background: #fef2f2; color: #dc2626; }
.badge-gray    { background: #f4f4f3; color: #6b7280; }
.badge-accent  { background: var(--accent); color: var(--accent-text); }

/* ── PAGINATION ── */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-top: 16px;
    justify-content: center;
}
.pagination a, .pagination span {
    padding: 6px 11px;
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    color: var(--text);
    border: 1px solid var(--border);
    background: var(--surface);
    font-weight: 500;
}
.pagination a:hover { background: var(--bg); }
.pagination .current { background: var(--text); color: #fff; border-color: var(--text); }

/* ── MODAL ── */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 200;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 24px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    border: 1px solid var(--border);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 18px; letter-spacing: -0.3px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── EDITOR ── */
.editor-toolbar {
    display: flex;
    gap: 3px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border-strong);
    border-bottom: none;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-wrap: wrap;
    align-items: center;
}

.tool-btn {
    padding: 4px 9px;
    border: 1px solid transparent;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    font-size: 12.5px;
    font-family: inherit;
    color: var(--text-muted);
    transition: all 0.1s;
    font-weight: 500;
}
.tool-btn:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.tool-separator { width: 1px; height: 18px; background: var(--border); margin: 0 3px; }

.editor-area {
    border: 1px solid var(--border-strong);
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 380px;
    padding: 16px;
    outline: none;
    font-size: 14px;
    line-height: 1.7;
    background: var(--surface);
}
.editor-area:focus { border-color: var(--text); }

/* ── SEARCH ── */
.search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}
.search-bar input { max-width: 260px; }

/* ── GRID ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── LOGIN ── */
.login-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.login-brand {
    text-align: center;
    margin-bottom: 28px;
}
.login-brand img { width: 48px; height: 48px; object-fit: contain; margin-bottom: 12px; }
.login-brand h1 { font-size: 18px; font-weight: 700; letter-spacing: -0.4px; }
.login-brand p { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── UNSUBSCRIBE ── */
.unsub-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}
.unsub-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}
.unsub-icon { font-size: 40px; margin-bottom: 16px; }
.unsub-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 10px; letter-spacing: -0.4px; }
.unsub-card p { color: var(--text-muted); font-size: 14px; line-height: 1.6; }

/* ── RSS PREVIEW ── */
.rss-preview-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.rss-preview-item:last-child { border-bottom: none; }
.rss-preview-img {
    width: 72px;
    height: 52px;
    object-fit: cover;
    border-radius: 5px;
    flex-shrink: 0;
    background: var(--bg);
}
.rss-preview-title { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.4; }
.rss-preview-date { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }

/* ── SCHEDULE TOGGLE ── */
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-label { font-size: 13.5px; font-weight: 500; }
.toggle-desc { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.toggle {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border-strong);
    border-radius: 20px;
    cursor: pointer;
    transition: 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--text); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* ── DAY SELECTOR ── */
.day-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.day-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.12s;
    font-family: inherit;
}
.day-btn.active, .day-btn:hover {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}

/* ── SOCIAL ICONS ── */
.social-links {
    display: flex;
    gap: 8px;
    align-items: center;
}
.social-link {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.12s;
}
.social-link:hover { background: var(--text); color: #fff; border-color: var(--text); }

/* ── SUBSCRIBE FORM EMBED ── */
.subscribe-embed {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.embed-code {
    background: #1a1a18;
    color: #e8ff5a;
    border-radius: var(--radius);
    padding: 16px;
    font-family: 'Monaco', monospace;
    font-size: 12px;
    overflow-x: auto;
    white-space: pre;
    margin-top: 12px;
}

/* ── RESPONSIVE ── */
@media (max-width: 960px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .main-content { padding: 20px; }
}
