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

/* ============================================================
   Email Analyzer — Design System (Azul Corporativo, tema claro)
   ============================================================ */
:root {
    /* Surfaces & text */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    /* Brand */
    --primary: #2563eb;
    --primary-600: #1d4ed8;
    --primary-700: #1e40af;
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --accent: #f59e0b;          /* CTA âmbar */
    --accent-600: #d97706;

    /* Sidebar (grafite) */
    --sidebar-bg: #1e293b;
    --sidebar-bg-2: #0f172a;
    --sidebar-text: #cbd5e1;
    --sidebar-text-dim: #94a3b8;

    /* Status */
    --success: #10b981; --success-bg: #ecfdf5; --success-text: #047857;
    --danger:  #ef4444; --danger-bg:  #fef2f2; --danger-text:  #b91c1c;
    --warning: #f59e0b; --warning-bg: #fffbeb; --warning-text: #b45309;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(15,23,42,.04), 0 1px 3px rgba(15,23,42,.06);
    --shadow-md: 0 2px 4px rgba(15,23,42,.04), 0 8px 16px rgba(15,23,42,.08);
    --shadow-lg: 0 10px 25px rgba(15,23,42,.06), 0 20px 48px rgba(15,23,42,.10);

    /* Shape */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: var(--primary-100); color: var(--primary-700); }

/* Layout */
.app-container {
    display: grid;
    grid-template-columns: 256px 1fr;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
    padding: 1.75rem 1rem;
    color: #fff;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar h2 {
    margin: 0 .5rem 2rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #fff;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.sidebar h2::before {
    content: "";
    width: 10px; height: 10px;
    border-radius: 3px;
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(37,99,235,.25);
}

.nav-links { list-style: none; display: flex; flex-direction: column; gap: .25rem; }
.nav-links li { margin: 0; }

.nav-links a {
    display: flex; align-items: center; gap: .6rem;
    color: var(--sidebar-text);
    text-decoration: none;
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: .95rem;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.nav-links a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-links a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(37,99,235,.35);
}

.user-info {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,.10);
}
.user-info span { display: block; margin-bottom: .6rem; color: var(--sidebar-text-dim); font-size: .9rem; }

.btn-logout {
    display: inline-block;
    padding: .5rem 1rem;
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: .9rem; font-weight: 500;
    transition: background .18s ease;
}
.btn-logout:hover { background: rgba(255,255,255,.16); }

/* Main */
.main-content { padding: 2.25rem 2.5rem; width: 100%; min-width: 0; }

.page-header { margin-bottom: 1.75rem; }
.page-header h1 {
    font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text);
    margin-bottom: .35rem;
}
.page-header p { color: var(--text-muted); }

/* Stat cards */
.stats, .dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1.1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface);
    padding: 1.4rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    border-top: 3px solid var(--primary);
    transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card h3 {
    font-size: .78rem; color: var(--text-muted);
    margin-bottom: .5rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.stat-card.important { border-top-color: var(--success); }
.stat-card.important .stat-value { color: var(--success); }
.stat-card.not-important { border-top-color: var(--danger); }
.stat-card.not-important .stat-value { color: var(--danger); }
.stat-card.uncertain { border-top-color: var(--warning); }
.stat-card.uncertain .stat-value { color: var(--warning); }

/* Buttons */
.actions { display: flex; gap: .75rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.btn-primary {
    padding: .7rem 1.4rem;
    background: var(--primary);
    color: #fff; border: none;
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: .95rem; cursor: pointer;
    font-family: inherit;
    transition: background .18s ease, transform .12s ease, box-shadow .18s ease;
}
.btn-primary:hover { background: var(--primary-600); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(37,99,235,.30); }
.btn-primary:active { transform: scale(.98); }

.btn-accent { background: var(--accent); }
.btn-accent:hover { background: var(--accent-600); box-shadow: 0 6px 16px rgba(245,158,11,.30); }

.btn-secondary {
    padding: .7rem 1.4rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: .95rem; cursor: pointer;
    font-family: inherit;
    transition: all .18s ease;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-50); }

/* Filters */
.filters {
    display: grid;
    grid-template-columns: 2fr 1fr auto;
    gap: 1rem; margin-bottom: 1.5rem;
    background: var(--surface);
    padding: 1rem; border-radius: var(--radius);
    box-shadow: var(--shadow-sm); border: 1px solid var(--border);
}
.filters input, .filters select,
.form-group input, .form-group select {
    padding: .65rem .9rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: .95rem; font-family: inherit; color: var(--text);
    background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease;
}
.filters input:focus, .filters select:focus,
.form-group input:focus, .form-group select:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

/* Generic tables */
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-weight: 600; font-size: .8rem;
    text-transform: uppercase; letter-spacing: .04em;
    text-align: left; padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
}
tbody td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
tbody tr { transition: background .12s ease; }
tbody tr:nth-child(even) { background: var(--surface-2); }
tbody tr:hover { background: var(--primary-50); }

/* Cards (results / analyses) */
.results-list { display: grid; gap: 1rem; }
.result-card, .analysis-card {
    background: var(--surface);
    padding: 1.4rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.result-card:hover, .analysis-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-100); }
.result-card input[type="checkbox"] { width: 1.15rem; height: 1.15rem; cursor: pointer; accent-color: var(--primary); }
.result-card label { font-weight: 600; color: var(--text); font-size: 1.05rem; cursor: pointer; }

/* Badges (pílulas tonais) */
.badge {
    display: inline-block; padding: .25rem .7rem;
    border-radius: 999px; font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em; margin-left: .5rem;
}
.badge-status-important { background: var(--success-bg); color: var(--success-text); }
.badge-status-not_important { background: var(--danger-bg); color: var(--danger-text); }
.badge-status-uncertain { background: var(--warning-bg); color: var(--warning-text); }

.result-meta { margin: 1rem 0; padding: .75rem; background: var(--surface-2); border-radius: var(--radius-sm); color: var(--text-muted); }
.result-meta p { margin: .25rem 0; }
.result-details { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.result-details p { margin: .5rem 0; }
.result-details strong { color: var(--text); }

.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); font-size: 1.05rem; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.5); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; }
.modal.show { display: flex; }
.modal-content { background: var(--surface); padding: 2rem; border-radius: var(--radius-lg); max-width: 420px; width: 90%; box-shadow: var(--shadow-lg); animation: modalIn .2s ease; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.modal-header h2 { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.close-btn { background: none; border: none; font-size: 1.8rem; cursor: pointer; color: var(--text-muted); line-height: 1; transition: color .18s ease; }
.close-btn:hover { color: var(--text); }

.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: .5rem; font-weight: 600; color: var(--text); font-size: .92rem; }
.form-group input, .form-group select { width: 100%; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 2rem; }

/* Toast */
#toast { display: none; position: fixed; bottom: 2rem; right: 2rem; background: var(--text); color: #fff; padding: .9rem 1.4rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 9999; animation: slideIn .3s ease; }
#toast.show { display: block; }
@keyframes slideIn { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Login */
.login-container { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-700) 60%, var(--sidebar-bg-2) 100%); padding: 1rem; }
.login-card { background: var(--surface); padding: 2.75rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-width: 410px; width: 100%; }
.login-card h1 { text-align: center; margin-bottom: .5rem; color: var(--text); font-weight: 800; letter-spacing: -.02em; }
.login-card p { text-align: center; color: var(--text-muted); margin-bottom: 1.75rem; }
.login-card input { width: 100%; padding: .75rem 1rem; margin-bottom: 1rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: .95rem; font-family: inherit; transition: border-color .18s ease, box-shadow .18s ease; }
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.login-card button { width: 100%; padding: .8rem 1.5rem; background: var(--primary); color: #fff; border: none; border-radius: var(--radius-sm); font-weight: 600; font-size: 1rem; cursor: pointer; font-family: inherit; transition: background .18s ease, transform .12s ease; }
.login-card button:hover { background: var(--primary-600); transform: translateY(-1px); }

/* Analyses */
.analysis-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.analysis-header h3 { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.analysis-stats { display: flex; gap: .6rem; font-size: .8rem; flex-wrap: wrap; }
.analysis-stats span { padding: .25rem .6rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; color: var(--text-muted); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Responsive */
@media (max-width: 900px) {
    .app-container { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
    .sidebar h2 { margin: 0 1rem 0 0; }
    .nav-links { flex-direction: row; flex-wrap: wrap; }
    .user-info { margin: 0 0 0 auto; padding: 0; border: none; display: flex; align-items: center; gap: .75rem; }
    .user-info span { margin: 0; }
    .main-content { padding: 1.25rem; }
    .filters { grid-template-columns: 1fr; }
}
