/* ============ Base Reset & Variables ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg-dark: #0a0a0f;
    --bg-card: #111118;
    --bg-card-hover: #16161f;
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --text-primary: #f0f0f5;
    --text-secondary: #8888a0;
    --text-dim: #55556a;
    --border: #1e1e2e;
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.12);
    --red: #ef4444;
    --red-dim: rgba(239, 68, 68, 0.12);
    --amber: #eab308;
    --amber-dim: rgba(234, 179, 8, 0.1);
    --blue: #3b82f6;
    --blue-dim: rgba(59, 130, 246, 0.12);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4 {
    font-family: 'Space Grotesk', sans-serif;
}

.screen { min-height: 100vh; }

/* ============ Ambient Glow ============ */
.ambient {
    position: fixed;
    top: -200px;
    left: 50%;
    transform: translateX(-50%);
    width: 800px;
    height: 600px;
    background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ============ Logo ============ */
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-primary);
    text-decoration: none;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* ============ Auth Screen ============ */
.auth-container {
    position: relative;
    z-index: 2;
    max-width: 420px;
    margin: 0 auto;
    padding: 80px 24px;
    text-align: center;
}

.auth-container .logo {
    justify-content: center;
    margin-bottom: 48px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px 32px;
    text-align: left;
}

.auth-card h2 {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.auth-sub {
    color: var(--text-secondary);
    font-size: 0.88rem;
    margin-bottom: 32px;
}

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

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

.form-group input, .select-filter {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: var(--accent);
}

.form-group input::placeholder {
    color: var(--text-dim);
}

.auth-error {
    color: var(--red);
    font-size: 0.82rem;
    margin-bottom: 12px;
    min-height: 20px;
}

.auth-toggle {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-toggle a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

/* ============ Buttons ============ */
.btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: 'Space Grotesk', sans-serif;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
    padding: 10px 20px;
    background: transparent;
    color: var(--accent);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.btn-ghost {
    padding: 8px 16px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
    color: var(--text-primary);
    border-color: var(--text-dim);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.78rem;
    border-radius: 8px;
}

/* ============ App Nav ============ */
.app-nav {
    display: flex;
    align-items: center;
    gap: 32px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.nav-tabs {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-tab {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}

.nav-tab:hover { color: var(--text-secondary); }
.nav-tab.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 36px;
    height: 36px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
}

.mobile-nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 1px;
}

/* ============ Page Container ============ */
.page-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

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

.page-header h1 {
    font-size: 1.8rem;
    letter-spacing: -0.02em;
}

.page-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

/* ============ Stats Grid ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: border-color 0.3s;
}

.stat-card:hover {
    border-color: rgba(99, 102, 241, 0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.si-blue { background: var(--blue-dim); border: 1px solid rgba(59, 130, 246, 0.2); }
.si-green { background: var(--green-dim); border: 1px solid rgba(34, 197, 94, 0.2); }
.si-purple { background: var(--accent-glow); border: 1px solid rgba(99, 102, 241, 0.2); }
.si-amber { background: var(--amber-dim); border: 1px solid rgba(234, 179, 8, 0.2); }

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-dim);
}

/* ============ Cards ============ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 24px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ============ Empty State ============ */
.empty-state {
    text-align: center;
    padding: 32px;
    color: var(--text-dim);
    font-size: 0.88rem;
}

/* ============ Intent Bars ============ */
.intent-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.intent-bar:last-child { margin-bottom: 0; }

.intent-label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    width: 120px;
    flex-shrink: 0;
    text-transform: capitalize;
}

.intent-track {
    flex: 1;
    height: 8px;
    background: var(--bg-dark);
    border-radius: 4px;
    overflow: hidden;
}

.intent-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.intent-fill.f-inquiry { background: var(--accent); }
.intent-fill.f-meeting_request { background: var(--green); }
.intent-fill.f-follow_up { background: var(--amber); }
.intent-fill.f-support { background: var(--red); }
.intent-fill.f-newsletter { background: var(--text-dim); }
.intent-fill.f-spam { background: #6b7280; }
.intent-fill.f-personal { background: var(--blue); }
.intent-fill.f-sales_pitch { background: #f97316; }
.intent-fill.f-complaint { background: #dc2626; }

.intent-count {
    font-size: 0.82rem;
    color: var(--text-dim);
    width: 30px;
    text-align: right;
    flex-shrink: 0;
}

/* ============ Activity Feed ============ */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child { border-bottom: none; }

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 7px;
    flex-shrink: 0;
}

.activity-dot.ad-sync { background: var(--blue); }
.activity-dot.ad-process { background: var(--green); }
.activity-dot.ad-reply { background: var(--accent); }
.activity-dot.ad-meeting { background: var(--amber); }
.activity-dot.ad-default { background: var(--text-dim); }

.activity-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex: 1;
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

/* ============ Onboarding ============ */
.onboarding-steps {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 28px;
}

.step {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.step-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    font-family: 'Space Grotesk', sans-serif;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.step-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.demo-notice {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
}

.demo-notice .btn-primary { width: auto; white-space: nowrap; }
.demo-text { font-size: 0.85rem; color: var(--text-secondary); }

/* ============ Email List ============ */
.email-row {
    display: grid;
    grid-template-columns: 44px 1fr auto auto;
    gap: 14px;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.email-row:hover {
    background: var(--bg-card-hover);
    border-color: rgba(99, 102, 241, 0.15);
}

.email-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.email-info {
    min-width: 0;
}

.email-from {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-subject {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-snippet {
    font-size: 0.75rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.email-tags {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    white-space: nowrap;
    text-transform: capitalize;
}

.tag-inquiry { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(99, 102, 241, 0.25); }
.tag-meeting_request { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.tag-follow_up { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(234, 179, 8, 0.2); }
.tag-support { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }
.tag-newsletter { background: rgba(107, 114, 128, 0.12); color: #9ca3af; border: 1px solid rgba(107, 114, 128, 0.2); }
.tag-spam { background: rgba(107, 114, 128, 0.12); color: #6b7280; border: 1px solid rgba(107, 114, 128, 0.2); }
.tag-personal { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.2); }
.tag-sales_pitch { background: rgba(249, 115, 22, 0.12); color: #f97316; border: 1px solid rgba(249, 115, 22, 0.2); }
.tag-complaint { background: var(--red-dim); color: #dc2626; border: 1px solid rgba(220, 38, 38, 0.2); }

.tag-high { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.2); }
.tag-normal { background: var(--blue-dim); color: var(--blue); border: 1px solid rgba(59, 130, 246, 0.2); }
.tag-low { background: rgba(107, 114, 128, 0.12); color: #9ca3af; border: 1px solid rgba(107, 114, 128, 0.2); }

.tag-draft { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(234, 179, 8, 0.2); }
.tag-approved { background: var(--green-dim); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.2); }
.tag-sent { background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(99, 102, 241, 0.25); }

.email-time {
    font-size: 0.75rem;
    color: var(--text-dim);
    flex-shrink: 0;
    white-space: nowrap;
}

/* ============ Reply Cards ============ */
.reply-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    transition: border-color 0.3s;
}

.reply-card:hover { border-color: rgba(99, 102, 241, 0.15); }

.reply-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.reply-to {
    font-size: 0.88rem;
    font-weight: 600;
}

.reply-subject {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.reply-body {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.65;
    white-space: pre-wrap;
    padding: 16px;
    background: var(--bg-dark);
    border-radius: 10px;
    margin-bottom: 12px;
}

.reply-actions {
    display: flex;
    gap: 8px;
}

/* ============ Meeting Cards ============ */
.meeting-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    gap: 16px;
    align-items: center;
}

.meeting-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--green-dim);
    border: 1px solid rgba(34, 197, 94, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.meeting-info { flex: 1; }

.meeting-title {
    font-size: 0.92rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.meeting-with {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.meeting-time {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-top: 2px;
}

.meeting-status {
    flex-shrink: 0;
}

/* ============ Settings ============ */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-row label {
    font-size: 0.88rem;
    font-weight: 500;
}

.text-secondary { color: var(--text-secondary); font-size: 0.88rem; }

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.connection-item:last-child { border-bottom: none; }

/* ============ Modal ============ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    flex: 1;
    padding-right: 16px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
    padding: 24px;
}

.modal-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-from {
    font-size: 0.88rem;
    color: var(--accent);
    font-weight: 500;
}

.modal-date {
    font-size: 0.82rem;
    color: var(--text-dim);
}

.modal-tags {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
}

.modal-email-body {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
    padding: 20px;
    background: var(--bg-dark);
    border-radius: 12px;
    margin-bottom: 24px;
}

.modal-body h4 {
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.modal-reply {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.65;
    white-space: pre-wrap;
    padding: 16px;
    background: var(--green-dim);
    border: 1px solid rgba(34, 197, 94, 0.15);
    border-radius: 10px;
    margin-bottom: 16px;
}

.modal-reply-actions {
    display: flex;
    gap: 10px;
}

.modal-reply-actions .btn-primary { width: auto; }

/* ============ Loading States ============ */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-dim);
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.88rem;
    color: var(--text-primary);
    z-index: 2000;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-success { border-color: rgba(34, 197, 94, 0.3); }
.toast.toast-error { border-color: rgba(239, 68, 68, 0.3); }

/* ============ Select Filter ============ */
.select-filter {
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 140px;
}

.select-filter option {
    background: var(--bg-card);
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
    .app-nav { flex-wrap: wrap; gap: 16px; }
    .nav-tabs { order: 3; width: 100%; overflow-x: auto; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .stats-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .page-actions { width: 100%; }
    .email-row { grid-template-columns: 36px 1fr auto; }
    .email-tags { display: none; }
    .nav-right { display: none; }
    .mobile-nav-toggle { display: flex; }
    .app-nav { padding: 16px; }
    .nav-tabs { display: none; }
    .nav-tabs.open { display: flex; flex-direction: column; }
    .demo-notice { flex-direction: column; text-align: center; }
}
