/* ==========================================================
   Inboxprofi | Clean Light Theme
   ========================================================== */

/* === Variables & Theme === */
:root {
    --bg-base: #f5f7fa;
    --bg-surface: #ffffff;
    --bg-surface-solid: #ffffff;
    --bg-panel: #f0f2f5;
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.15);
    --trend-colors: linear-gradient(90deg, #fbbf24 0%, #f97316 40%, #ef4444 70%, #a855f7 100%);
    --success: #16a34a;
    --success-glow: rgba(22, 163, 74, 0.15);
    --warning: #d97706;
    --error: #dc2626;
    --text-primary: #1e293b;
    --text-sec: #64748b;
    --text-muted: #94a3b8;
    --border-light: #e2e8f0;
    --border-hover: #cbd5e1;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* === Utilities === */
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.text-gradient { color: transparent; background: var(--trend-colors); -webkit-background-clip: text; background-clip: text; }
.text-accent { color: transparent; background: linear-gradient(90deg, #fbbf24 0%, #ef4444 50%, #a855f7 100%); -webkit-background-clip: text; background-clip: text; padding-left: 2px; }
.container { max-width: 900px; margin: 0 auto; padding: 0 24px; }

/* === Background Glows === */
.app-background { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.glow-orb { position: absolute; width: 600px; height: 600px; border-radius: 50%; filter: blur(150px); opacity: 0.07; }
.orb-1 { top: -200px; left: -100px; background: var(--accent); }
.orb-2 { bottom: -100px; right: -200px; background: var(--success); }

/* === Cards === */
.glass-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

/* === Navbar === */
.navbar {
    position: sticky; top: 0; z-index: 100;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-light);
}

.navbar-inner { display: flex; align-items: center; justify-content: space-between; height: 72px; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
    width: 38px; height: 38px;
    background: var(--bg-panel);
    border-radius: 10px; padding: 6px;
    border: 1px solid var(--border-light);
    transition: transform var(--transition);
}
.brand:hover .brand-icon { transform: scale(1.08) rotate(-3deg); border-color: var(--accent); }
.brand-text { font-family: 'Outfit', sans-serif; font-size: 28px; font-weight: 800; letter-spacing: -1.5px; color: var(--text-primary); text-transform: lowercase; display: flex; align-items: center; }

.nav-links { display: flex; gap: 8px; }
.nav-item { font-size: 14px; font-weight: 600; color: var(--text-sec); padding: 8px 16px; border-radius: 20px; transition: all var(--transition); display: flex; align-items: center; gap: 8px; }
.nav-item:hover { color: var(--text-primary); background: var(--bg-panel); }
.nav-item.active { color: var(--text-primary); background: var(--bg-panel); border: 1px solid var(--border-light); }

.user-profile { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 30px; background: var(--bg-panel); border: 1px solid var(--border-light); cursor: pointer; transition: border-color var(--transition); }
.user-profile:hover { border-color: var(--border-hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; }
.user-name { font-size: 14px; font-weight: 600; padding-right: 8px; }

/* === Main Layout === */
.main-content { padding-top: 40px; padding-bottom: 80px; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 32px; }
.page-title { font-size: 32px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.page-subtitle { font-size: 15px; color: var(--text-sec); }

/* === Buttons === */
.btn-primary {
    background: linear-gradient(90deg, #f97316 0%, #ef4444 100%);
    color: white; padding: 14px 24px; border-radius: var(--radius-sm);
    font-weight: 700; font-size: 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4); transition: all var(--transition); border: none;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(239, 68, 68, 0.6); filter: brightness(1.1); }
.btn-primary.btn-sm { padding: 10px 20px; font-size: 14px; }
.btn-block { width: 100%; margin-top: 8px; }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; font-size: 14px; font-weight: 600;
    color: var(--text-primary); transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-panel); }

.btn-action { font-size: 13px; font-weight: 600; color: var(--text-sec); transition: all 0.2s; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--bg-panel); }
.btn-action:hover { color: var(--text-primary); background: var(--bg-panel); border-color: var(--border-hover); }
.btn-fetch { color: var(--accent); background: #eff6ff; }
.btn-fetch:hover { color: #1d4ed8; border-color: #bfdbfe; background: #dbeafe; }
.btn-delete { color: #dc2626; }
.btn-delete:hover { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }

/* === Alerts === */
.alert { padding: 16px; border-radius: var(--radius-sm); font-size: 14px; display: flex; align-items: center; gap: 12px; margin-bottom: 24px; border: 1px solid transparent; }
.alert strong { font-weight: 700; margin-right: 4px; }
.alert-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-info { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }

/* === Dashboard / Email List === */
.inbox-list { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }

.email-tile {
    display: flex; flex-direction: column; gap: 8px; padding: 20px 24px;
    cursor: pointer; transition: all 0.2s; border-radius: var(--radius-md);
}
.email-tile:hover { border-color: var(--border-hover); background: var(--bg-panel); transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.email-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.email-sender-wrapper { flex: 1; min-width: 0; }
.email-sender { font-weight: 400; font-size: 14px; color: var(--text-sec); margin-bottom: 2px; }
.email-contact-name { color: var(--accent); font-size: 13px; font-weight: 600; }
.email-account-tag { font-size: 12px; color: var(--text-sec); display: block; margin-bottom: 8px; }
.email-date { font-size: 13px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; padding-top: 2px; }
.email-subject { font-size: 16px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.email-preview { font-size: 15px; color: var(--text-sec); line-height: 1.5; }

.badge-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.badge-tag { font-size: 11px; padding: 4px 10px; border-radius: 100px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; }

/* Email Row (Classifier Results) */
.email-row {
    display: flex; align-items: center; justify-content: space-between; padding: 16px;
    cursor: pointer; transition: all 0.2s; border-bottom: 1px solid var(--border-light);
}
.email-row:last-child { border-bottom: none; }
.email-row:hover { border-color: var(--border-hover); background: var(--bg-panel); transform: translateX(4px); }
.email-row .email-sender { flex-basis: 150px; flex-shrink: 0; }
.email-row .email-subject { flex-grow: 1; padding: 0 16px; font-weight: 500; color: var(--text-sec); }
.email-row .email-date { min-width: 120px; text-align: right; color: var(--text-muted); }

/* Search Bar */
.search-area { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: 8px; display: flex; gap: 12px; margin-bottom: 32px; align-items: center; }
.search-input { flex-grow: 1; padding: 12px 16px; background: transparent !important; border: none; color: var(--text-primary); font-size: 16px; font-weight: 500; font-family: inherit; }
.search-input:focus { outline: none; }
.search-input::placeholder { color: var(--text-muted); }
.search-btn { padding: 10px 24px; border-radius: var(--radius-sm); font-weight: 700; }
.search-divider { width: 1px; height: 24px; background: var(--border-light); margin: 0 4px; flex-shrink: 0; }
.filter-select { padding-right: 32px; border: none; background: transparent !important; cursor: pointer; color: var(--text-primary); font-weight: 500; appearance: none; -webkit-appearance: none; font-size: 15px; font-family: inherit; min-width: 160px; padding: 12px 32px 12px 16px; }
.filter-select:focus { outline: none; }
.filter-select option { color: #000; }

/* Result count */
.result-count { font-size: 14px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; color: var(--text-sec); margin-bottom: 8px; }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 48px; font-size: 14px; }
.pagination a { font-weight: 600; }
.pagination span { color: var(--text-sec); font-weight: 600; }

/* === Contacts === */
.contacts-list { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }

.contact-card {
    padding: 20px 24px;
    display: grid; grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) auto auto;
    align-items: center; gap: 24px;
    transition: all 0.2s; border-radius: var(--radius-md);
}
.contact-card:hover { border-color: var(--border-hover); background: var(--bg-panel); transform: translateX(4px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.contact-card.has-error { border-color: #fecaca; }

.col-truncate { min-width: 0; }
.contact-name { font-size: 16px; font-weight: 700; color: var(--text-primary); }
.contact-email { font-size: 14px; color: var(--text-sec); font-family: monospace; }
.contact-error-msg { font-size: 12px; color: #dc2626; margin-top: 2px; }

.status-badge { font-size: 11px; padding: 4px 10px; border-radius: 100px; font-weight: 800; text-transform: uppercase; white-space: nowrap; letter-spacing: 0.5px; }
.status-active { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.status-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

.contact-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.action-bar { display: flex; gap: 12px; }

/* === Forms === */
.form-container { max-width: 600px; margin: 0 auto; }

.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text-sec); display: block; margin-bottom: 6px; }
.label-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 8px; }

.form-input {
    width: 100%; padding: 12px 14px;
    background: var(--bg-panel) !important;
    border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    color: var(--text-primary); font-size: 15px; font-family: inherit;
    transition: all var(--transition);
}
.form-input:focus { outline: none; border-color: var(--accent); background: #e8ecf1 !important; box-shadow: 0 0 0 3px var(--accent-glow); }
.form-input::placeholder { color: var(--text-muted); }

.form-checkbox { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.checkbox-label { font-size: 14px; color: var(--text-sec); cursor: pointer; display: flex; align-items: center; gap: 8px; }

.provider-hint {
    background: #eff6ff; border: 1px solid #bfdbfe;
    color: #1e40af; padding: 12px 16px; border-radius: var(--radius-sm);
    margin-bottom: 20px; font-size: 14px; display: flex; align-items: center; gap: 12px;
}
.provider-hint a { color: var(--accent); text-decoration: underline; }

/* === Auth Pages === */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-container { width: 100%; max-width: 440px; z-index: 10; animation: fadeIn 0.5s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.auth-brand { display: flex; flex-direction: column; align-items: center; justify-content: center; margin-bottom: 32px; }
.auth-icon { width: 56px; height: 56px; margin-bottom: 16px; border-radius: 14px; }
.auth-text { font-size: 36px; }
.auth-card { padding: 40px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1); }
.auth-title { font-size: 24px; font-weight: 700; text-align: center; margin-bottom: 8px; }
.auth-subtitle { font-size: 14px; color: var(--text-sec); text-align: center; margin-bottom: 32px; }
.auth-form { display: flex; flex-direction: column; gap: 20px; }
.auth-label { font-size: 13px; font-weight: 600; color: var(--text-sec); margin-bottom: 4px; display: block; }
.auth-error { color: #991b1b; background: #fef2f2; padding: 12px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 14px; text-align: center; border: 1px solid #fecaca; }
.auth-footer { margin-top: 32px; text-align: center; font-size: 14px; color: var(--text-muted); }

/* === Classifier === */
.classifier-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; margin-top: 32px; }
.classifier-card {
    padding: 32px 24px; display: flex; align-items: center; justify-content: center; text-align: center;
    font-size: 18px; font-weight: 700; color: var(--text-primary);
    border: 1px solid var(--border-light); border-radius: var(--radius-md);
    transition: all 0.2s; background: var(--bg-panel); text-decoration: none;
}
.classifier-card:hover { border-color: var(--accent); background: #eff6ff; transform: translateY(-4px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); color: var(--accent); }

.classifier-header { display: flex; align-items: baseline; gap: 16px; margin-bottom: 32px; }
.classifier-count { font-size: 14px; font-weight: 600; color: var(--accent); background: #eff6ff; padding: 4px 10px; border-radius: 12px; }

/* === Help === */
.help-section {
    background: var(--bg-panel); border: 1px solid var(--border-light);
    border-radius: var(--radius-sm); padding: 24px; margin-bottom: 24px;
}
.help-section h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 12px; }
.help-section p { color: var(--text-sec); line-height: 1.6; margin-bottom: 16px; }
.help-section a { color: var(--accent); text-decoration: underline; }
.help-section a:hover { color: #60a5fa; }
.help-section:last-child { margin-bottom: 0; }

/* === Email Detail === */
.email-detail { max-width: 700px; }
.email-detail .back-link { color: var(--text-sec); font-size: 14px; font-weight: 600; display: inline-block; margin-bottom: 24px; transition: color 0.2s; }
.email-detail .back-link:hover { color: var(--text-primary); }
.email-detail h1 { font-size: 24px; font-weight: 800; margin-bottom: 16px; letter-spacing: -0.3px; }
.email-detail-meta { background: var(--bg-panel); border: 1px solid var(--border-light); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 24px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-sec); }
.email-detail-meta strong { color: var(--text-primary); }
.email-body { white-space: pre-wrap; font-size: 15px; line-height: 1.7; color: var(--text-sec); }

/* === Responsive === */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .navbar-inner { height: 60px; }
    .brand-text { font-size: 22px; }
    .brand-icon { width: 30px; height: 30px; padding: 4px; }
    .user-name { display: none; }
    .nav-links { display: flex; position: absolute; top: 60px; left: 0; right: 0; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); padding: 16px; flex-direction: column; border-bottom: 1px solid var(--border-light); }
    .navbar { position: relative; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 16px; }
    .action-bar { width: 100%; justify-content: space-between; }
    .auth-card { padding: 24px; }
    .contact-card, .email-tile, .email-row { flex-direction: column; align-items: flex-start; gap: 12px; }
    .contact-card { display: flex; }
    .contact-actions { width: 100%; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light); }
}
