/* ============================================
   newsletterexample — Design System
   Palette: Deep navy + warm white + electric indigo accent
   Font: Inter (utility) + Fraunces (display)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,700;1,9..144,300&display=swap');

/* ── Reset & Tokens ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --c-bg:         #0d0f14;
    --c-surface:    #13161e;
    --c-surface-2:  #1a1e29;
    --c-surface-3:  #212636;
    --c-border:     #252b3b;
    --c-border-2:   #2e3549;

    --c-accent:     #6366f1;   /* indigo */
    --c-accent-dim: #4f46e5;
    --c-accent-glow:#6366f120;
    --c-green:      #22c55e;
    --c-amber:      #f59e0b;
    --c-red:        #ef4444;

    --c-text:       #e8eaf0;
    --c-text-2:     #8b92a8;
    --c-text-3:     #565e7a;

    --f-ui:         'Inter', system-ui, sans-serif;
    --f-display:    'Fraunces', Georgia, serif;

    --r-sm:  6px;
    --r-md:  10px;
    --r-lg:  16px;
    --r-xl:  24px;

    --shadow-card: 0 1px 3px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --shadow-panel: 0 8px 32px rgba(0,0,0,.5);
    --transition: 150ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--f-ui);
    background: var(--c-bg);
    color: var(--c-text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--f-ui); border: none; background: none; }
input, select, textarea { font-family: var(--f-ui); }
img { max-width: 100%; }

/* ── Auth Pages (login / register) ─────────── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-bg);
    position: relative;
    overflow: hidden;
}
.auth-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, #6366f118 0%, transparent 70%);
    top: -200px; right: -200px;
    pointer-events: none;
}
.auth-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, #4f46e510 0%, transparent 70%);
    bottom: -100px; left: -100px;
    pointer-events: none;
}
.auth-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-xl);
    padding: 48px 44px;
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    box-shadow: var(--shadow-panel);
}
.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo .logo-icon {
    width: 48px; height: 48px;
    background: var(--c-accent);
    border-radius: var(--r-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 12px;
    font-size: 22px;
}
.auth-logo h1 {
    font-family: var(--f-display);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--c-text);
}
.auth-logo p {
    font-size: 13px;
    color: var(--c-text-2);
    margin-top: 4px;
}
.auth-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 6px;
}
.auth-subtitle {
    font-size: 13px;
    color: var(--c-text-2);
    margin-bottom: 28px;
}
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--c-text-2);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-input {
    width: 100%;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    padding: 11px 14px;
    font-size: 14px;
    color: var(--c-text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px var(--c-accent-glow);
}
.form-input::placeholder { color: var(--c-text-3); }
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    border: none;
}
.btn-primary {
    background: var(--c-accent);
    color: #fff;
    width: 100%;
}
.btn-primary:hover { background: var(--c-accent-dim); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: var(--c-surface-3);
    color: var(--c-text);
    border: 1px solid var(--c-border);
}
.btn-secondary:hover { background: var(--c-surface-2); border-color: var(--c-border-2); }
.btn-ghost {
    background: transparent;
    color: var(--c-text-2);
    padding: 8px 12px;
}
.btn-ghost:hover { background: var(--c-surface-3); color: var(--c-text); }
.btn-icon {
    padding: 8px;
    border-radius: var(--r-sm);
    background: var(--c-surface-3);
    color: var(--c-text-2);
    transition: all var(--transition);
}
.btn-icon:hover { background: var(--c-surface-2); color: var(--c-text); }
.btn-icon.active { color: var(--c-amber); }
.btn-danger { background: var(--c-red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.auth-switch {
    text-align: center;
    font-size: 13px;
    color: var(--c-text-2);
    margin-top: 20px;
}
.auth-switch a { color: var(--c-accent); font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }
.alert {
    padding: 11px 14px;
    border-radius: var(--r-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}
.alert-error { background: #ef444418; border: 1px solid #ef444440; color: #fca5a5; }
.alert-success { background: #22c55e18; border: 1px solid #22c55e40; color: #86efac; }
.alert.show { display: block; }

/* ── Dashboard Layout ───────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--c-surface);
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition);
}
.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--c-border);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo .logo-icon {
    width: 32px; height: 32px;
    background: var(--c-accent);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}
.sidebar-logo span {
    font-family: var(--f-display);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}
.nav-section-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 8px 8px 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--r-sm);
    font-size: 13.5px;
    color: var(--c-text-2);
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 1px;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.nav-item:hover { background: var(--c-surface-3); color: var(--c-text); }
.nav-item.active { background: var(--c-accent-glow); color: var(--c-accent); }
.nav-item .nav-icon { font-size: 16px; flex-shrink: 0; }
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--c-accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 99px;
    min-width: 18px;
    text-align: center;
}
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--c-border);
}
.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: background var(--transition);
}
.user-card:hover { background: var(--c-surface-3); }
.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--c-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.user-info { flex: 1; overflow: hidden; }
.user-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.user-role {
    font-size: 11px;
    color: var(--c-text-3);
}

/* Main content */
.main-content {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Top bar */
.topbar {
    height: 56px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title {
    font-size: 15px;
    font-weight: 600;
    flex: 1;
}
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    padding: 7px 12px;
    flex: 1;
    max-width: 400px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-bar:focus-within {
    border-color: var(--c-accent);
    box-shadow: 0 0 0 3px var(--c-accent-glow);
}
.search-bar .search-icon { color: var(--c-text-3); font-size: 14px; }
.search-bar input {
    background: none;
    border: none;
    outline: none;
    color: var(--c-text);
    font-size: 13.5px;
    width: 100%;
}
.search-bar input::placeholder { color: var(--c-text-3); }

/* Page content area */
.page-content {
    flex: 1;
    padding: 24px;
}

/* ── Email Layout (split view) ──────────────── */
.email-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 56px);
    overflow: hidden;
}
.email-list-panel {
    width: 380px;
    min-width: 320px;
    border-right: 1px solid var(--c-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-list-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.email-list-header h2 {
    font-size: 14px;
    font-weight: 600;
    flex: 1;
}
.filter-bar {
    padding: 10px 12px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--c-border);
    color: var(--c-text-2);
    background: transparent;
    transition: all var(--transition);
    white-space: nowrap;
}
.filter-chip:hover { border-color: var(--c-accent); color: var(--c-accent); }
.filter-chip.active { background: var(--c-accent-glow); border-color: var(--c-accent); color: var(--c-accent); }
.email-list {
    flex: 1;
    overflow-y: auto;
}
.email-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--c-border);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}
.email-item:hover { background: var(--c-surface-2); }
.email-item.selected { background: var(--c-accent-glow); border-left: 3px solid var(--c-accent); }
.email-item.unread .email-subject { font-weight: 600; }
.email-item.unread::after {
    content: '';
    width: 7px; height: 7px;
    background: var(--c-accent);
    border-radius: 50%;
    position: absolute;
    top: 14px; left: 6px;
}
.email-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--c-surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text-2);
    flex-shrink: 0;
    overflow: hidden;
}
.email-avatar img { width: 100%; height: 100%; object-fit: cover; }
.email-item-body { flex: 1; overflow: hidden; }
.email-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 3px;
}
.email-sender {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.email-date {
    font-size: 11px;
    color: var(--c-text-3);
    white-space: nowrap;
    flex-shrink: 0;
}
.email-subject {
    font-size: 13px;
    color: var(--c-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}
.email-preview {
    font-size: 12px;
    color: var(--c-text-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.email-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity var(--transition);
}
.email-item:hover .email-item-actions { opacity: 1; }
.fav-btn {
    background: none;
    border: none;
    color: var(--c-text-3);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: color var(--transition);
}
.fav-btn:hover, .fav-btn.active { color: var(--c-amber); }

/* Email viewer */
.email-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-viewer-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--c-border);
}
.email-viewer-subject {
    font-family: var(--f-display);
    font-size: 22px;
    font-weight: 300;
    line-height: 1.3;
    margin-bottom: 14px;
}
.email-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}
.email-meta-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--c-surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--c-text-2);
    flex-shrink: 0;
    overflow: hidden;
}
.email-meta-avatar img { width: 100%; height: 100%; object-fit: cover; }
.email-meta-info { flex: 1; }
.email-meta-from {
    font-size: 14px;
    font-weight: 500;
}
.email-meta-from span { color: var(--c-text-2); font-weight: 400; font-size: 13px; }
.email-meta-date { font-size: 12px; color: var(--c-text-3); }
.email-meta-actions { display: flex; gap: 6px; }
.email-viewer-body {
    flex: 1;
    overflow-y: auto;
    background: #fff;
}
.email-viewer-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
.email-viewer-body .text-body {
    padding: 32px;
    font-size: 14px;
    line-height: 1.7;
    color: #1a1a2e;
    white-space: pre-wrap;
}
.empty-viewer {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--c-text-3);
    gap: 12px;
}
.empty-viewer .icon { font-size: 48px; opacity: 0.3; }
.empty-viewer p { font-size: 14px; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border-top: 1px solid var(--c-border);
}
.page-btn {
    width: 28px; height: 28px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--c-border);
    background: var(--c-surface-2);
    color: var(--c-text-2);
    transition: all var(--transition);
}
.page-btn:hover { border-color: var(--c-accent); color: var(--c-accent); }
.page-btn.active { background: var(--c-accent); color: #fff; border-color: var(--c-accent); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Stats cards ────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--c-border-2); }
.stat-icon {
    width: 40px; height: 40px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.stat-icon.indigo { background: #6366f120; }
.stat-icon.green  { background: #22c55e20; }
.stat-icon.amber  { background: #f59e0b20; }
.stat-icon.blue   { background: #3b82f620; }
.stat-body { flex: 1; }
.stat-label {
    font-size: 11px;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 500;
    margin-bottom: 4px;
}
.stat-value {
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* ── Admin table ────────────────────────────── */
.panel {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--r-lg);
    overflow: hidden;
    margin-bottom: 20px;
}
.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-title { font-size: 14px; font-weight: 600; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--c-text-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--c-border);
    background: var(--c-surface-2);
}
.data-table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--c-border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--c-surface-2); }
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 500;
}
.badge-green { background: #22c55e20; color: #86efac; }
.badge-red   { background: #ef444420; color: #fca5a5; }
.badge-blue  { background: #3b82f620; color: #93c5fd; }
.badge-amber { background: #f59e0b20; color: #fcd34d; }

/* ── Loading spinner ────────────────────────── */
.spinner {
    width: 24px; height: 24px;
    border: 2px solid var(--c-border);
    border-top-color: var(--c-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: auto;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
}

/* ── Toast ──────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--c-surface-2);
    border: 1px solid var(--c-border);
    border-radius: var(--r-md);
    padding: 12px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 260px;
    box-shadow: var(--shadow-panel);
    animation: slideIn 0.2s ease;
}
.toast.success { border-color: #22c55e40; }
.toast.error   { border-color: #ef444440; }
@keyframes slideIn {
    from { transform: translateX(40px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

/* ── Utilities ──────────────────────────────── */
.text-accent  { color: var(--c-accent); }
.text-muted   { color: var(--c-text-2); }
.text-dimmed  { color: var(--c-text-3); }
.text-sm      { font-size: 13px; }
.text-xs      { font-size: 12px; }
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mt-4         { margin-top: 4px; }
.mt-8         { margin-top: 8px; }
.ml-auto      { margin-left: auto; }
.divider      { height: 1px; background: var(--c-border); margin: 20px 0; }

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-text-3); }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .email-list-panel { width: 100%; border-right: none; }
    .email-viewer { display: none; }
    .email-viewer.visible { display: flex; position: fixed; inset: 0; z-index: 200; background: var(--c-bg); }
}
