/* PitchPilot Shared Styles */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Grotesk:wght@400;500;600;700&display=swap');

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

:root {
    --bg: #0a0a0b;
    --surface: #141416;
    --surface-2: #1a1a1e;
    --surface-3: #202024;
    --border: #1e1e22;
    --border-hover: #2a2a30;
    --text: #e8e8ec;
    --text-dim: #8a8a96;
    --text-muted: #5a5a66;
    --accent: #22c55e;
    --accent-dim: rgba(34, 197, 94, 0.12);
    --accent-glow: rgba(34, 197, 94, 0.25);
    --accent-hover: #16a34a;
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.12);
    --info: #3b82f6;
    --info-dim: rgba(59, 130, 246, 0.12);
    --purple: #a855f7;
    --purple-dim: rgba(168, 85, 247, 0.12);
}

body {
    font-family: 'DM Sans', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==================== AUTH PAGES ==================== */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
}

.auth-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.6rem;
    color: var(--text);
    letter-spacing: -0.5px;
    text-align: center;
    margin-bottom: 8px;
    text-decoration: none;
    display: block;
}
.auth-logo span { color: var(--accent); }

.auth-subtitle {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group input::placeholder, .form-group textarea::placeholder {
    color: var(--text-muted);
}

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

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238a8a96' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

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

.btn-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }

.btn-sm { padding: 8px 16px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; border-radius: 8px; }

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--text-dim);
}
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.error-msg {
    background: var(--danger-dim);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    margin-bottom: 16px;
    display: none;
}
.error-msg.show { display: block; }

/* ==================== APP LAYOUT ==================== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--text);
    letter-spacing: -0.5px;
    padding: 0 8px 24px;
    text-decoration: none;
    display: block;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.sidebar-logo span { color: var(--accent); }

.sidebar-nav { flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    transition: all 0.15s;
    cursor: pointer;
    margin-bottom: 4px;
    border: none;
    background: none;
    width: 100%;
    font-family: inherit;
    text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-user {
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--accent-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.75rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px 40px;
    min-height: 100vh;
}

/* ==================== PAGE HEADER ==================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}
.page-header h1 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.7rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.page-header p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 4px;
}

/* ==================== STATS CARDS ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    transition: border-color 0.2s;
}
.stat-card:hover { border-color: var(--border-hover); }
.stat-card .stat-label {
    font-size: 0.78rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
    margin-bottom: 8px;
}
.stat-card .stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
}
.stat-card .stat-sub {
    font-size: 0.78rem;
    color: var(--text-dim);
    margin-top: 4px;
}
.stat-card.accent .stat-value { color: var(--accent); }
.stat-card.info .stat-value { color: var(--info); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.warning .stat-value { color: var(--warning); }

/* ==================== CARDS & TABLES ==================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
}
.card-body { padding: 20px; }
.card-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-dim);
}
.card-empty p { margin-bottom: 16px; }

table {
    width: 100%;
    border-collapse: collapse;
}
table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}
table td {
    padding: 14px 16px;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: var(--surface-2); }

/* ==================== BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-success { background: var(--accent-dim); color: var(--accent); }
.badge-info { background: var(--info-dim); color: var(--info); }
.badge-warning { background: var(--warning-dim); color: var(--warning); }
.badge-danger { background: var(--danger-dim); color: var(--danger); }
.badge-purple { background: var(--purple-dim); color: var(--purple); }
.badge-muted { background: var(--surface-3); color: var(--text-dim); }

/* ==================== MODAL ==================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.15rem;
    font-weight: 600;
}
.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.3rem;
    padding: 4px;
    line-height: 1;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* ==================== EMAIL PREVIEW ==================== */
.email-card {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 12px;
    transition: border-color 0.15s;
}
.email-card:hover { border-color: var(--border-hover); }
.email-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.email-card-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
}
.email-card-to { color: var(--text-dim); }
.email-card-seq {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 2px 8px;
    border-radius: 6px;
}
.email-card-subject {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.92rem;
}
.email-card-body {
    color: var(--text-dim);
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
}
.email-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ==================== CAMPAIGN CARD ==================== */
.campaign-list { display: grid; gap: 16px; }
.campaign-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    transition: all 0.2s;
    cursor: pointer;
}
.campaign-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.campaign-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}
.campaign-card h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
}
.campaign-card-stats {
    display: flex;
    gap: 20px;
}
.campaign-stat {
    text-align: center;
}
.campaign-stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
}
.campaign-stat-label {
    font-size: 0.72rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==================== ACTIVITY FEED ==================== */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}
.activity-icon.sent { background: var(--accent-dim); }
.activity-icon.opened { background: var(--info-dim); }
.activity-icon.replied { background: var(--purple-dim); }
.activity-content { flex: 1; min-width: 0; }
.activity-text { font-size: 0.85rem; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ==================== LOADING ==================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-dim);
    gap: 10px;
}
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== TOAST ==================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    font-size: 0.85rem;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    animation: toastIn 0.25s ease;
    max-width: 360px;
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ==================== SECTION TABS ==================== */
.tabs {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}
.tab {
    padding: 8px 18px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent-dim); color: var(--accent); }

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 20px; }
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 16px; }
}

/* Inline row form */
.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}
.inline-form .form-group { margin-bottom: 0; }

@media (max-width: 900px) {
    .inline-form { grid-template-columns: 1fr; }
}

/* Sequence bar */
.seq-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}
.seq-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    transition: all 0.2s;
    cursor: pointer;
}
.seq-dot.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }
.seq-line { flex: 1; height: 2px; background: var(--border); }
