/* Harle - Agent IA personnel */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-dark: #0f172a;
    --bg-sidebar: #111827;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ========== AUTH ========== */
.auth-body {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.auth-container { width: 100%; max-width: 420px; }
.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.15);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo svg { color: var(--primary); margin-bottom: 0.5rem; }
.auth-logo h1 { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.auth-logo p { color: var(--text-muted); margin-top: 0.25rem; }
.auth-form .form-group { margin-bottom: 1rem; }
.auth-footer {
    margin-top: 1.5rem; text-align: center; font-size: 0.875rem;
    display: flex; gap: 0.5rem; justify-content: center; align-items: center; flex-wrap: wrap;
}
.auth-footer a { color: var(--primary); text-decoration: none; font-weight: 500; }
.auth-footer a:hover { text-decoration: underline; }
.muted { color: var(--text-muted); }

/* ========== LAYOUT ========== */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 0.75rem;
}
.sidebar-header svg { color: var(--primary-light); }
.sidebar-header h2 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.sidebar-header .badge-pro {
    font-size: 0.625rem; background: var(--primary); color: white;
    padding: 0.125rem 0.375rem; border-radius: 4px; font-weight: 700;
}
.sidebar-nav { padding: 1rem 0.75rem; flex: 1; overflow-y: auto; }
.nav-section { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-light); padding: 0.75rem 0.75rem 0.5rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 0.125rem;
    transition: all 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-item.active { background: var(--primary); color: white; }
.nav-item svg { flex-shrink: 0; }
.sidebar-footer {
    padding: 1rem; border-top: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; gap: 0.75rem;
}
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.875rem;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 0.875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 0.75rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logout-btn {
    background: rgba(255,255,255,0.05); border: none; color: rgba(255,255,255,0.6);
    width: 32px; height: 32px; border-radius: var(--radius-sm); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.logout-btn:hover { background: var(--danger); color: white; }

.main { flex: 1; min-width: 0; }
.topbar {
    background: white; padding: 1rem 2rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }
.mobile-menu-btn {
    display: none; background: none; border: none; cursor: pointer; color: var(--text);
    width: 40px; height: 40px; border-radius: var(--radius-sm); align-items: center; justify-content: center;
}
.content { padding: 2rem; max-width: 1400px; }

/* ========== COMPONENTS ========== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.625rem 1.125rem; font-size: 0.9rem; font-weight: 600;
    border: none; border-radius: var(--radius-sm); cursor: pointer;
    transition: all 0.15s; text-decoration: none; white-space: nowrap;
    font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f1f5f9; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #059669; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.375rem; font-size: 0.875rem; font-weight: 600; color: var(--text); }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%; padding: 0.625rem 0.875rem; font-size: 0.9rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: white; color: var(--text); font-family: inherit;
    transition: all 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.alert {
    padding: 0.875rem 1rem; border-radius: var(--radius-sm);
    font-size: 0.875rem; margin-bottom: 1rem;
}
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: var(--primary); border: 1px solid #c7d2fe; }

/* ========== CARDS / STATS ========== */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-card); padding: 1.25rem;
    border-radius: var(--radius); border: 1px solid var(--border);
    display: flex; align-items: center; gap: 1rem;
    transition: all 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-icon {
    width: 48px; height: 48px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon.primary { background: rgba(99,102,241,0.1); color: var(--primary); }
.stat-icon.success { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-icon.info { background: rgba(6,182,212,0.1); color: var(--secondary); }
.stat-content { min-width: 0; }
.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; letter-spacing: -0.02em; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    margin-bottom: 1.5rem;
}
.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 700; }
.card-body { padding: 1.5rem; }
.card-body.p0 { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
@media (max-width: 1024px) { .grid-2 { grid-template-columns: 1fr; } }

/* ========== TABLE ========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table th {
    text-align: left; padding: 0.75rem 1.5rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase;
    font-size: 0.7rem; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
table td {
    padding: 0.875rem 1.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: #fafbfc; }

/* ========== BADGES ========== */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.25rem 0.625rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
}
.badge-pending { background: #f1f5f9; color: var(--text-muted); }
.badge-in_progress, .badge-running { background: #dbeafe; color: #1e40af; }
.badge-awaiting_validation, .badge-proposed, .badge-summarized { background: #fef3c7; color: #92400e; }
.badge-completed, .badge-confirmed, .badge-submitted, .badge-replied { background: #d1fae5; color: #065f46; }
.badge-cancelled, .badge-failed, .badge-archived { background: #fee2e2; color: #991b1b; }
.badge-requested, .badge-draft, .badge-queued, .badge-new { background: #e0e7ff; color: #3730a3; }
.badge-ready { background: #ccfbf1; color: #115e59; }
.badge-priority-high { background: #fee2e2; color: var(--danger); }
.badge-priority-normal { background: #dbeafe; color: #1e40af; }
.badge-priority-low { background: #f1f5f9; color: var(--text-muted); }

.type-icon {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 0.5rem; vertical-align: middle;
}
.type-icon.appointment { background: rgba(99,102,241,0.1); color: var(--primary); }
.type-icon.form { background: rgba(245,158,11,0.1); color: var(--warning); }
.type-icon.email { background: rgba(6,182,212,0.1); color: var(--secondary); }
.type-icon.web_action { background: rgba(16,185,129,0.1); color: var(--success); }

.actions-cell { white-space: nowrap; display: flex; gap: 0.375rem; }
.icon-btn {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: white;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); transition: all 0.15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.primary:hover { background: var(--primary); color: white; border-color: var(--primary); }
.icon-btn.danger:hover { background: var(--danger); color: white; border-color: var(--danger); }
.icon-btn.success:hover { background: var(--success); color: white; border-color: var(--success); }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    display: none; align-items: center; justify-content: center;
    z-index: 100; padding: 1rem; backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal {
    background: white; border-radius: var(--radius);
    width: 100%; max-width: 540px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    animation: modalIn 0.2s ease;
}
.modal.large { max-width: 720px; }
@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } }
.modal-header {
    padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.125rem; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: 0.5rem;
}

/* ========== TOAST ========== */
.toast-container {
    position: fixed; top: 1rem; right: 1rem; z-index: 200;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
    background: white; padding: 0.875rem 1rem;
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    display: flex; align-items: center; gap: 0.75rem;
    min-width: 280px; max-width: 400px;
    border-left: 4px solid var(--primary);
    animation: toastIn 0.25s ease;
    font-size: 0.875rem;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } }

/* ========== EMPTY ========== */
.empty {
    padding: 3rem 1rem; text-align: center; color: var(--text-muted);
}
.empty svg { color: var(--text-light); margin-bottom: 1rem; }
.empty h3 { font-size: 1.125rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; }
.empty p { font-size: 0.875rem; margin-bottom: 1rem; }

/* ========== ACTIVITY ========== */
.activity-list { list-style: none; padding: 0; }
.activity-item {
    display: flex; align-items: flex-start; gap: 0.75rem;
    padding: 0.875rem 0; border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary); margin-top: 0.5rem; flex-shrink: 0;
}
.activity-content { flex: 1; min-width: 0; }
.activity-action { font-size: 0.875rem; font-weight: 500; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }

/* ========== EMAIL CARDS ========== */
.email-card {
    padding: 1rem 1.5rem; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.15s;
}
.email-card:hover { background: #fafbfc; }
.email-card:last-child { border-bottom: none; }
.email-from { font-weight: 600; font-size: 0.875rem; }
.email-subject { font-size: 0.9rem; margin-top: 0.125rem; }
.email-summary { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.375rem; line-height: 1.4; }
.email-meta { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.5rem; }

/* ========== AGENT LOG ========== */
.agent-log {
    background: #0f172a; color: #e2e8f0;
    padding: 1rem; border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Monaco', monospace;
    font-size: 0.8rem; line-height: 1.6;
    white-space: pre-wrap; max-height: 300px; overflow-y: auto;
}
.agent-log .log-time { color: #64748b; }
.agent-log .log-action { color: #93c5fd; }

/* ========== MOBILE ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed; left: -260px; top: 0; z-index: 100;
        transition: left 0.25s;
        box-shadow: 0 0 50px rgba(0,0,0,0.2);
    }
    .sidebar.open { left: 0; }
    .mobile-menu-btn { display: flex; }
    .topbar { padding: 1rem; }
    .topbar-title { font-size: 1.25rem; }
    .content { padding: 1rem; }
    .form-row { grid-template-columns: 1fr; }
    .stat-card { padding: 1rem; }
    .stat-value { font-size: 1.25rem; }
    table th, table td { padding: 0.625rem 1rem; }
    .actions-cell { flex-direction: column; gap: 0.25rem; }
    .card-header { padding: 0.875rem 1rem; }
    .card-body { padding: 1rem; }
    .modal { max-width: 100%; }
}

.backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 99;
}
.backdrop.show { display: block; }

/* ========== UTILS ========== */
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
