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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* === Navbar === */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.nav-brand { font-weight: 700; font-size: 1.1rem; margin-right: 2rem; }
.nav-links { display: flex; gap: 1rem; flex: 1; }
.nav-link { text-decoration: none; color: var(--text-muted); padding: 0.25rem 0.5rem; border-radius: var(--radius); }
.nav-link:hover { color: var(--primary); background: #eff6ff; }
.nav-user { display: flex; align-items: center; gap: 0.75rem; color: var(--text-muted); font-size: 0.9rem; }

/* === Container === */
.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }

/* === Typography === */
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 0.75rem; }
h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.5rem; }

/* === Page header === */
.page-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.5rem 1rem; border-radius: var(--radius); border: 1px solid transparent;
    font-size: 0.9rem; font-weight: 500; cursor: pointer; text-decoration: none;
    transition: all 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover:not(:disabled) { background: #475569; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; }
.inline-form { display: inline; }

/* === Forms === */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 500; margin-bottom: 0.25rem; font-size: 0.9rem; }
.form-group input { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.95rem; }
.form-group input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* === Alerts === */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-warning { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }

/* === Badges === */
.badge {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 12px;
    font-size: 0.75rem; font-weight: 600; background: #e2e8f0; color: var(--text-muted);
}
.badge-auto { background: #dbeafe; color: #1e40af; }
.badge-contact { background: #dcfce7; color: #166534; }
.badge-appris { background: #f3e8ff; color: #7c3aed; }
.badge-undo { background: #fef3c7; color: #92400e; }

/* === Stats === */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat-card {
    background: var(--surface); padding: 1.25rem; border-radius: var(--radius);
    border: 1px solid var(--border); text-align: center;
}
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* === Actions === */
.actions-section { margin-bottom: 2rem; }
.actions-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.action-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

/* === Login === */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; }
.login-card {
    background: var(--surface); padding: 2rem; border-radius: var(--radius);
    border: 1px solid var(--border); box-shadow: var(--shadow);
    width: 100%; max-width: 400px;
}
.login-card h1 { text-align: center; margin-bottom: 0.5rem; }
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

/* === Table === */
.table-container { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.table thead { background: #f1f5f9; }
.table th { text-align: left; padding: 0.5rem 0.75rem; font-weight: 600; color: var(--text-muted); }
.table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.table tr:hover { background: #f8fafc; }
.nowrap { white-space: nowrap; }
.folder-path { font-family: monospace; font-size: 0.8rem; word-break: break-all; }
.empty-state { text-align: center; color: var(--text-muted); padding: 2rem; }

/* === Filter bar === */
.filter-bar { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; flex-wrap: wrap; align-items: center; }
.input-search { flex: 1; min-width: 200px; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: var(--radius); }
.input-select { padding: 0.5rem; border: 1px solid var(--border); border-radius: var(--radius); }

/* === Pagination === */
.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin-top: 1.5rem; }
.page-info { font-size: 0.9rem; color: var(--text-muted); }

/* === Progress === */
.progress-section { margin-bottom: 1.5rem; }
.progress-bar-container {
    width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.progress-bar {
    height: 100%; background: var(--primary); border-radius: 4px;
    transition: width 0.3s ease;
}
.progress-bar.complete { background: var(--success); }
.progress-text { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; }

/* === Event log === */
.event-log {
    background: #1e293b; color: #e2e8f0; border-radius: var(--radius);
    padding: 1rem; font-family: monospace; font-size: 0.8rem;
    max-height: 400px; overflow-y: auto; margin-bottom: 1.5rem;
}
.log-entry { padding: 0.2rem 0; }
.log-type {
    display: inline-block; min-width: 60px; padding: 0.1rem 0.3rem;
    border-radius: 3px; font-size: 0.7rem; text-align: center;
}
.log-moved .log-type { background: #166534; color: #bbf7d0; }
.log-error .log-type { background: #991b1b; color: #fecaca; }
.log-fatal .log-type { background: #7f1d1d; color: #fca5a5; }
.log-detail { color: #94a3b8; }

/* === Email card (confirmation) === */
.email-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
}
.email-card-header { padding: 0.75rem 1rem; background: #f1f5f9; border-bottom: 1px solid var(--border); }
.email-card-body { padding: 0.75rem 1rem; flex: 1; }
.email-field { display: flex; gap: 0.75rem; padding: 0.25rem 0; }
.field-label { font-weight: 600; min-width: 90px; font-size: 0.8rem; color: var(--text-muted); }
.field-value { font-size: 0.85rem; }
.email-card-actions { display: flex; gap: 0.75rem; padding: 1rem; border-top: 1px solid var(--border); background: #f8fafc; }

/* === Proposals list (checkboxes) === */
.confirm-actions-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 1rem;
}
.confirm-actions-buttons { display: flex; gap: 0.5rem; }
.proposals-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; }
.proposal-selectable {
    display: flex; align-items: stretch; cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.proposal-selectable:hover { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37,99,235,0.1); }
.proposal-selectable:has(input:checked) { border-color: var(--primary); background: #f0f7ff; }
.proposal-selectable:has(input:not(:checked)) { opacity: 0.6; }
.email-card-check {
    display: flex; align-items: center; justify-content: center;
    padding: 0 1rem; background: #f8fafc; border-right: 1px solid var(--border);
}
.proposal-checkbox { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.confirm-execute-bar {
    display: flex; align-items: center; gap: 1rem;
    padding: 1rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); position: sticky; bottom: 1rem;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

/* === Summary === */
.summary-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem; text-align: center;
}
.summary-stats { display: flex; justify-content: center; gap: 1.5rem; margin: 1rem 0 1.5rem; }
.confirm-summary { text-align: center; }
.confirm-summary .summary-stats { justify-content: center; }

/* === Responsive === */
@media (max-width: 640px) {
    .navbar { padding: 0 1rem; }
    .container { padding: 1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .actions-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .email-card-actions { flex-direction: column; }
    .email-field { flex-direction: column; gap: 0.25rem; }
    .field-label { min-width: auto; }
}
