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

* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #4A4DE7;
    --primary-dark: #3D3FC7;
    --primary-light: #6C6FF1;
    --primary-bg: #EEEDFD;
    --blue: #4A90E2;
    --green: #2ECC71;
    --cyan: #00C9E0;
    --amber: #F5A623;
    --red: #E74C3C;
    --bg-main: #F0F2F5;
    --bg-white: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --text-dark: #1A1D2E;
    --text-medium: #5A607F;
    --text-light: #8B92A5;
    --border: #E4E7EC;
    --border-light: #F0F1F3;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-w: 260px;
}
html { font-size: 14px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-main);
    color: var(--text-dark);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD2DE; border-radius: 3px; }

/* ─── Top Header ─── */
.top-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 56px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(74,77,231,0.3);
}
.top-header .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}
.logo-text { font-size: 1.4rem; }
.top-header .user-area {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
}
.top-header .avatar {
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.menu-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background 0.2s;
}
.menu-btn:hover { background: rgba(255,255,255,0.15); }
.logout-link {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}
.logout-link:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ─── Backdrop ─── */
.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* ─── Sidebar ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    z-index: 95;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding-top: 70px;
    box-shadow: var(--shadow-lg);
}
.sidebar.open { transform: translateX(0); }
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}
.sidebar-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-medium);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 2px;
}
.sidebar-menu a:hover {
    background: var(--primary-bg);
    color: var(--primary);
}
.sidebar-menu a.active {
    background: var(--primary-bg);
    color: var(--primary);
    font-weight: 600;
}
.menu-icon { font-size: 1.1rem; width: 24px; text-align: center; }
.menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 12px 8px;
}
.menu-section {
    padding: 8px 14px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.5px;
}
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-light);
    text-align: center;
}
.version {
    font-size: 0.75rem;
    color: var(--text-light);
}

/* ─── Main Content ─── */
.main-content {
    margin-top: 56px;
    padding: 24px;
    min-height: calc(100vh - 56px);
    transition: margin-left 0.3s;
}

/* ─── Auth Pages ─── */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4A4DE7 0%, #6C6FF1 50%, #8B8FF5 100%);
    padding: 20px;
    margin: -24px;
    margin-top: -56px;
    padding-top: 76px;
}
.auth-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.auth-logo {
    width: 56px; height: 56px;
    border-radius: 14px;
    margin: 0 auto 16px;
    display: block;
    font-size: 2.5rem;
    text-align: center;
}
.auth-title {
    text-align: center;
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 4px;
}
.auth-subtitle {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 32px;
}

/* ─── Forms ─── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-medium);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-white);
    color: var(--text-dark);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(74,77,231,0.1);
}
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control[multiple] { min-height: 100px; }
.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.form-row .form-group { flex: 1; min-width: 200px; }
.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin: 16px 0;
}
.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(74,77,231,0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,77,231,0.4); }
.btn-secondary {
    background: var(--bg-white);
    color: var(--text-medium);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); }
.btn-success { background: var(--green); color: #fff; }
.btn-warning { background: var(--amber); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-block { width: 100%; }

/* ─── Page Header ─── */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
}

/* ─── Cards ─── */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
    font-weight: 600;
    color: var(--text-dark);
}

/* ─── Stats Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}
.stat-card.blue { border-left-color: var(--blue); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.cyan { border-left-color: var(--cyan); }
.stat-card.purple { border-left-color: var(--primary); }
.stat-card.amber { border-left-color: var(--amber); }
.stat-card.red { border-left-color: var(--red); }
.stat-card .label { font-size: 0.75rem; color: var(--text-light); font-weight: 500; }
.stat-card .value { font-size: 1.6rem; font-weight: 700; color: var(--text-dark); }
.stat-card .icon-area { font-size: 2rem; opacity: 0.3; }

/* ─── Data Tables ─── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left;
    padding: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px;
    font-size: 0.85rem;
    color: var(--text-medium);
    border-bottom: 1px solid var(--border-light);
}
.data-table tr:hover td { background: var(--bg-main); }
.data-table a { color: var(--primary); text-decoration: none; font-weight: 500; }
.data-table .actions { display: flex; gap: 6px; }

/* ─── Badges ─── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-draft { background: #E8E8E8; color: #666; }
.badge-running { background: #D4EDDA; color: #155724; }
.badge-paused { background: #FFF3CD; color: #856404; }
.badge-completed { background: #D1ECF1; color: #0C5460; }
.badge-sent, .badge-opened, .badge-clicked { background: #D4EDDA; color: #155724; }
.badge-landed { background: #CCE5FF; color: #004085; }
.badge-submitted { background: #F8D7DA; color: #721C24; }
.badge-hot { background: #F8D7DA; color: #721C24; }
.badge-warm { background: #FFF3CD; color: #856404; }
.badge-cold { background: #D1ECF1; color: #0C5460; }
.badge-microsoft { background: #00A4EF; color: #fff; }
.badge-google { background: #4285F4; color: #fff; }
.badge-apple { background: #555; color: #fff; }
.badge-amazon { background: #FF9900; color: #fff; }
.badge-bank { background: #1B4D3E; color: #fff; }
.badge-crypto { background: #F7931A; color: #fff; }
.badge-generic { background: var(--border); color: var(--text-medium); }

/* ─── Alerts ─── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 0.85rem; }
.alert-success { background: #D4EDDA; color: #155724; border: 1px solid #C3E6CB; }
.alert-error, .alert-danger { background: #F8D7DA; color: #721C24; border: 1px solid #F5C6CB; }
.alert-info { background: #D1ECF1; color: #0C5460; border: 1px solid #BEE5EB; }
.alert-warning { background: #FFF3CD; color: #856404; border: 1px solid #FFEEBA; }

/* ─── Template Grid ─── */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.template-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
}
.template-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.template-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.template-subject { font-size: 0.8rem; color: var(--text-light); margin-bottom: 16px; }
.template-actions { display: flex; gap: 8px; }

/* ─── Editor ─── */
.editor-card { padding: 0; overflow: hidden; }
.editor-card form { padding: 20px; }
.editor-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}
.editor-pane {
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}
.editor-pane label, .preview-pane label {
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
}
.editor-textarea {
    border: none;
    border-radius: 0;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    flex: 1;
    min-height: 400px;
}
.preview-iframe {
    width: 100%;
    height: 100%;
    min-height: 400px;
    border: none;
    background: var(--bg-white);
}

/* ─── Tools Grid ─── */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}
.tool-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}
.tool-card h3 { font-size: 1rem; margin-bottom: 12px; }
.tool-card .form-control { margin-bottom: 8px; }
.tool-result { margin-top: 12px; }
.tool-result pre {
    background: var(--bg-main);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    overflow-x: auto;
}
.loading { color: var(--text-light); font-style: italic; }

/* ─── Row Layouts ─── */
.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ─── Engagement Bars ─── */
.engagement-bars { padding: 12px 0; }
.eng-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.eng-bar span:first-child { width: 80px; font-size: 0.8rem; font-weight: 600; }
.eng-bar .bar {
    flex: 1;
    height: 8px;
    background: var(--border-light);
    border-radius: 4px;
    overflow: hidden;
}
.eng-bar .bar .fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.eng-bar.hot .fill { background: var(--red); }
.eng-bar.warm .fill { background: var(--amber); }
.eng-bar.cold .fill { background: var(--blue); }

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-size: 0.9rem;
}
.empty-state a { color: var(--primary); font-weight: 600; }

/* ─── Verify Results ─── */
.verify-result { margin-top: 16px; }
.verify-result pre {
    background: var(--bg-main);
    padding: 16px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    overflow-x: auto;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    :root { --sidebar-w: 280px; }
    .main-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .row-2 { grid-template-columns: 1fr; }
    .editor-split { grid-template-columns: 1fr; }
    .editor-pane { border-right: none; border-bottom: 1px solid var(--border); }
    .tools-grid { grid-template-columns: 1fr; }
    .template-grid { grid-template-columns: 1fr; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .top-header .brand span:last-child { display: none; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .data-table { display: block; overflow-x: auto; }
}

/* Toast notification animation */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
