/* ================================================================
   MONITOR DE CORREO - SUPERMERCADOS EURO
   Design System & Styles
   ================================================================ */

/* === DESIGN TOKENS === */
:root {
    /* Brand: Euro Supermercados */
    --primary: #283069;
    --primary-light: #3a4590;
    --primary-dark: #1a2050;
    --primary-50: #eef0f8;
    --accent: #FFD825;
    --accent-dark: #E5C000;
    --accent-light: #FFF3B0;

    /* Semantic */
    --urgent: #DC2626;
    --urgent-bg: #FEE2E2;
    --urgent-border: #FECACA;
    --important: #F59E0B;
    --important-bg: #FEF3C7;
    --important-border: #FDE68A;
    --normal: #3B82F6;
    --normal-bg: #DBEAFE;
    --normal-border: #BFDBFE;
    --info: #6B7280;
    --info-bg: #F3F4F6;
    --info-border: #E5E7EB;
    --success: #10B981;
    --success-bg: #D1FAE5;
    --danger: #DC2626;
    --danger-bg: #FEE2E2;

    /* Neutrals */
    --bg: #F0F2F8;
    --surface: #FFFFFF;
    --border: #E2E4EC;
    --border-light: #F0F1F5;
    --text: #1F2937;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --text-inverse: #FFFFFF;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --fs-xs: 0.7rem;
    --fs-sm: 0.8125rem;
    --fs-base: 0.9375rem;
    --fs-lg: 1.0625rem;
    --fs-xl: 1.25rem;
    --fs-2xl: 1.5rem;
    --fs-3xl: 2rem;

    /* Spacing */
    --sp-1: 0.25rem;
    --sp-2: 0.5rem;
    --sp-3: 0.75rem;
    --sp-4: 1rem;
    --sp-5: 1.25rem;
    --sp-6: 1.5rem;
    --sp-8: 2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* Borders & Shadows */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --shadow-xs: 0 1px 2px rgba(40, 48, 105, 0.04);
    --shadow-sm: 0 1px 3px rgba(40, 48, 105, 0.06), 0 1px 2px rgba(40, 48, 105, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(40, 48, 105, 0.07), 0 2px 4px -1px rgba(40, 48, 105, 0.04);
    --shadow-lg: 0 10px 25px -3px rgba(40, 48, 105, 0.1), 0 4px 6px -2px rgba(40, 48, 105, 0.05);
    --shadow-xl: 0 20px 50px -5px rgba(40, 48, 105, 0.15);
}

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

html { font-size: 16px; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === HEADER === */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--text-inverse);
    padding: var(--sp-3) var(--sp-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(40, 48, 105, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 60px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.header-logo { height: 32px; filter: brightness(0) invert(1); }

.header-divider {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, 0.25);
}

.header-title {
    font-size: var(--fs-lg);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--fs-sm);
}

.user-email {
    font-size: var(--fs-sm);
    opacity: 0.9;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-inverse);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

/* === FOOTER === */
.app-footer {
    text-align: center;
    padding: var(--sp-6);
    color: var(--text-light);
    font-size: var(--fs-xs);
}

/* === LOGIN === */
.login-body {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 50%, #151a3a 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    width: 100%;
    max-width: 440px;
    padding: var(--sp-4);
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.login-header {
    background: var(--primary);
    padding: var(--sp-8) var(--sp-6);
    text-align: center;
}

.login-logo {
    height: 44px;
    filter: brightness(0) invert(1);
}

.login-content {
    padding: var(--sp-8);
}

.login-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    margin-bottom: var(--sp-1);
}

.login-subtitle {
    color: var(--text-secondary);
    text-align: center;
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-6);
    line-height: 1.5;
}

.login-form { display: flex; flex-direction: column; gap: var(--sp-4); }

.form-group { display: flex; flex-direction: column; gap: var(--sp-1); }

.form-group label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: var(--sp-3);
    color: var(--text-light);
    pointer-events: none;
}

.input-wrapper input {
    width: 100%;
    padding: var(--sp-3) var(--sp-3) var(--sp-3) 42px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    font-family: var(--font);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--surface);
}

.input-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(40, 48, 105, 0.1);
}

.input-wrapper input::placeholder {
    color: var(--text-light);
}

.login-info {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
    margin-top: var(--sp-5);
    padding: var(--sp-3);
    background: var(--primary-50);
    border-radius: var(--radius-sm);
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    line-height: 1.4;
}

.login-info svg { flex-shrink: 0; margin-top: 1px; color: var(--success); }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-light);
    text-decoration: none;
}

.btn-block { width: 100%; padding: var(--sp-3); font-size: var(--fs-base); }

.btn-text, .btn-loading { display: inline-flex; align-items: center; gap: var(--sp-2); }

/* === ALERTS === */
.alert {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-4);
    animation: slideDown 0.3s ease;
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--urgent-border);
}

.alert-success {
    background: var(--success-bg);
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.alert-close:hover { opacity: 1; }

/* === DASHBOARD === */
.dashboard-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-4);
}

.dashboard-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--sp-6);
    flex-wrap: wrap;
    gap: var(--sp-3);
}

.controls-left {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.page-title {
    font-size: var(--fs-2xl);
    font-weight: 700;
    color: var(--primary);
}

.scan-status {
    font-size: var(--fs-xs);
    color: var(--text-light);
}

.controls-right {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
}

.form-select {
    padding: var(--sp-2) var(--sp-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: var(--fs-sm);
    color: var(--text);
    background: var(--surface);
    cursor: pointer;
    min-width: 180px;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* === LOADING === */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(240, 242, 248, 0.95);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: var(--sp-4);
}

.loading-content {
    text-align: center;
    max-width: 380px;
}

.loading-content-wide {
    max-width: 640px;
    width: 100%;
    text-align: left;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.loading-top {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    padding: var(--sp-6);
    border-bottom: 1px solid var(--border-light);
}

.loading-top .loading-spinner {
    flex-shrink: 0;
}

.loading-status {
    flex: 1;
    min-width: 0;
}

.loading-spinner {
    position: relative;
    width: 64px;
    height: 64px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
}

.loading-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--sp-1);
}

.loading-text {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    margin-bottom: var(--sp-3);
}

/* === LOG PANEL === */
.loading-log-wrapper {
    background: #1a1d2e;
    max-height: 350px;
    display: flex;
    flex-direction: column;
}

.loading-log-header {
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--fs-xs);
    color: #8b8fa7;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid #2a2d42;
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-shrink: 0;
}

.log-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 1.5s ease-in-out infinite;
}

.loading-log {
    padding: var(--sp-3) var(--sp-4);
    overflow-y: auto;
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.7;
    min-height: 120px;
    max-height: 300px;
}

.log-entry {
    color: #c8cce0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: logFadeIn 0.2s ease;
}

.log-entry .log-time {
    color: #5a5f7a;
    margin-right: var(--sp-2);
}

.log-info { color: #a8b1d4; }
.log-success { color: #4ade80; }
.log-warn { color: #fbbf24; }
.log-urgent { color: #f87171; }
.log-error { color: #f87171; font-weight: 600; }

/* Scrollbar for log */
.loading-log::-webkit-scrollbar { width: 6px; }
.loading-log::-webkit-scrollbar-track { background: transparent; }
.loading-log::-webkit-scrollbar-thumb { background: #3a3d52; border-radius: 3px; }
.loading-log::-webkit-scrollbar-thumb:hover { background: #4a4d62; }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes logFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.loading-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
    max-width: 240px;
    margin: 0 auto;
}

.loading-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 2px;
    width: 0%;
    transition: width 0.5s ease;
    animation: loadingPulse 2s ease-in-out infinite;
}

/* === DASHBOARD SUMMARY === */
.dashboard-summary {
    margin-bottom: var(--sp-6);
}

.summary-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--accent);
}

.summary-card h3 {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.summary-card h3::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    flex-shrink: 0;
}

.summary-card p {
    color: var(--text-secondary);
    font-size: var(--fs-base);
    line-height: 1.7;
}

.summary-card h4 {
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--primary);
    margin-top: var(--sp-5);
    margin-bottom: var(--sp-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-card ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.summary-card li {
    padding: var(--sp-2) var(--sp-3);
    background: var(--primary-50);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--text);
    display: flex;
    align-items: flex-start;
    gap: var(--sp-2);
}

.summary-card li::before {
    content: '>';
    font-weight: 700;
    color: var(--primary);
    flex-shrink: 0;
}

.scan-info {
    display: block;
    margin-top: var(--sp-4);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--border-light);
    font-size: var(--fs-xs);
    color: var(--text-light);
}

/* === PRIORITY COUNTERS === */
.priority-counters {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}

.counter-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-5);
    text-align: center;
    box-shadow: var(--shadow-xs);
    border-top: 3px solid;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
}

.counter-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.counter-icon { opacity: 0.7; }
.counter-urgent { border-color: var(--urgent); }
.counter-urgent .counter-icon { color: var(--urgent); }
.counter-urgent .counter-number { color: var(--urgent); }
.counter-important { border-color: var(--important); }
.counter-important .counter-icon { color: var(--important); }
.counter-important .counter-number { color: var(--important); }
.counter-normal { border-color: var(--normal); }
.counter-normal .counter-icon { color: var(--normal); }
.counter-normal .counter-number { color: var(--normal); }
.counter-info { border-color: var(--info); }
.counter-info .counter-icon { color: var(--info); }
.counter-info .counter-number { color: var(--info); }

.counter-number {
    font-size: var(--fs-3xl);
    font-weight: 800;
    line-height: 1;
}

.counter-label {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* === RISK ALERTS === */
.risk-alerts-container {
    margin-bottom: var(--sp-6);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.risk-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    background: var(--urgent-bg);
    border: 1px solid var(--urgent-border);
    border-radius: var(--radius-sm);
    color: #991B1B;
    font-size: var(--fs-sm);
    line-height: 1.5;
}

.risk-icon {
    font-size: var(--fs-lg);
    flex-shrink: 0;
}

/* === EMAIL LIST === */
.email-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}

.empty-state {
    text-align: center;
    padding: var(--sp-12) var(--sp-4);
    color: var(--text-secondary);
}

.empty-icon {
    color: var(--border);
    margin-bottom: var(--sp-4);
}

.empty-state h3 {
    font-size: var(--fs-xl);
    color: var(--text);
    margin-bottom: var(--sp-2);
}

.empty-state p {
    font-size: var(--fs-sm);
    max-width: 400px;
    margin: 0 auto var(--sp-5);
    line-height: 1.6;
}

/* === EMAIL CARD === */
.email-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-4) var(--sp-5);
    box-shadow: var(--shadow-xs);
    border-left: 4px solid var(--border);
    cursor: pointer;
    transition: all 0.15s ease;
}

.email-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateX(2px);
}

.email-card.priority-urgente { border-left-color: var(--urgent); }
.email-card.priority-importante { border-left-color: var(--important); }
.email-card.priority-normal { border-left-color: var(--normal); }
.email-card.priority-informativo { border-left-color: var(--info); }

.email-card-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
    flex-wrap: wrap;
}

.email-date {
    margin-left: auto;
    font-size: var(--fs-xs);
    color: var(--text-light);
    white-space: nowrap;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.6;
}

.badge-urgente { background: var(--urgent-bg); color: var(--urgent); }
.badge-importante { background: var(--important-bg); color: #B45309; }
.badge-normal { background: var(--normal-bg); color: #1D4ED8; }
.badge-informativo { background: var(--info-bg); color: var(--info); }

.badge-risk {
    background: #FFF7ED;
    color: #C2410C;
    border: 1px solid #FED7AA;
}

.badge-sentiment-positivo { background: var(--success-bg); color: #065F46; }
.badge-sentiment-neutro { background: var(--info-bg); color: var(--info); }
.badge-sentiment-negativo { background: var(--danger-bg); color: var(--danger); }

.email-card-body { margin-bottom: var(--sp-2); }

.email-sender {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--text);
    margin-bottom: 2px;
}

.email-subject {
    font-size: var(--fs-base);
    color: var(--primary);
    font-weight: 600;
    margin-bottom: var(--sp-1);
    line-height: 1.4;
}

.email-summary {
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.email-card-footer {
    display: flex;
    gap: var(--sp-3);
    flex-wrap: wrap;
    font-size: var(--fs-xs);
    color: var(--text-light);
}

.task-count {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--important);
    font-weight: 600;
}

.task-count::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--important);
    border-radius: 50%;
}

.needs-response {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--normal);
    font-weight: 600;
}

.needs-response::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--normal);
    border-radius: 50%;
}

.attachment-count {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-light);
}

.attachment-count::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--text-light);
    border-radius: 50%;
}

/* === EMAIL DETAIL === */
.detail-container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--sp-6) var(--sp-4);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--sp-6);
}

.back-link:hover { text-decoration: none; opacity: 0.8; }

.detail-header {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-4);
}

.detail-header h2 {
    font-size: var(--fs-xl);
    color: var(--primary);
    margin: var(--sp-3) 0;
    line-height: 1.4;
}

.detail-meta {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.detail-meta strong { color: var(--text); }

/* Analysis panel */
.detail-analysis {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-4);
    border-left: 4px solid var(--accent);
}

.detail-analysis h3 {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--sp-4);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.detail-analysis h3::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
}

.analysis-grid {
    display: flex;
    flex-direction: column;
    gap: var(--sp-4);
}

.analysis-item {
    padding-bottom: var(--sp-4);
    border-bottom: 1px solid var(--border-light);
}

.analysis-item:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.analysis-item label {
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-1);
    display: block;
}

.analysis-item p {
    font-size: var(--fs-base);
    color: var(--text);
    line-height: 1.6;
}

.risk-highlight {
    background: var(--urgent-bg);
    padding: var(--sp-3) !important;
    border-radius: var(--radius-sm);
    border: 1px solid var(--urgent-border);
}

.task-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.task-list li {
    padding: var(--sp-2) var(--sp-3);
    background: var(--primary-50);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.task-desc { color: var(--text); font-weight: 500; }

.task-deadline, .task-responsible {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}

.suggested-response {
    background: var(--primary-50);
    padding: var(--sp-3);
    border-radius: var(--radius-sm);
    font-style: italic;
}

/* Email body */
.detail-body {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
    margin-bottom: var(--sp-4);
}

.detail-body h3 {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--sp-4);
}

.email-body-content {
    font-size: var(--fs-sm);
    color: var(--text);
    line-height: 1.7;
    overflow-x: auto;
    word-wrap: break-word;
}

.email-body-content img { max-width: 100%; height: auto; }

.detail-attachments {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--sp-6);
    box-shadow: var(--shadow-sm);
}

.detail-attachments h3 {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--primary);
    margin-bottom: var(--sp-3);
}

.detail-attachments ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.detail-attachments li {
    padding: var(--sp-2) var(--sp-3);
    background: var(--info-bg);
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

/* === SPINNER === */
.spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-inline {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-3);
    padding: var(--sp-8);
    color: var(--text-secondary);
    font-size: var(--fs-sm);
}

.loading-inline .spinner-sm {
    border-color: var(--border);
    border-top-color: var(--primary);
}

/* === TOAST NOTIFICATIONS === */
.toast-container {
    position: fixed;
    top: 72px;
    right: var(--sp-4);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-width: 400px;
}

.toast {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: var(--fs-sm);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    animation: slideIn 0.3s ease;
}

.toast-danger {
    background: var(--danger);
    color: white;
}

.toast-success {
    background: var(--success);
    color: white;
}

/* === CHAT PANEL === */
.chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(40, 48, 105, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
    transition: all 0.2s;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(40, 48, 105, 0.45);
}

.chat-panel {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 420px;
    max-height: 560px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 48px rgba(40, 48, 105, 0.2);
    z-index: 400;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.25s ease;
}

@keyframes chatSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    background: var(--primary);
    color: white;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 600;
    font-size: var(--fs-sm);
}

.chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    padding: 4px;
    border-radius: 4px;
    display: flex;
}

.chat-close:hover { opacity: 1; background: rgba(255,255,255,0.1); }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    min-height: 200px;
    max-height: 380px;
}

.chat-msg {
    display: flex;
    max-width: 88%;
}

.chat-msg-ai { align-self: flex-start; }
.chat-msg-user { align-self: flex-end; }

.chat-msg-content {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-msg-ai .chat-msg-content {
    background: var(--primary-50);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.chat-msg-ai .chat-msg-content ul {
    margin: var(--sp-2) 0 0 var(--sp-4);
    padding: 0;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}

.chat-msg-ai .chat-msg-content li { margin-bottom: var(--sp-1); }

.chat-msg-user .chat-msg-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg-loading .chat-msg-content {
    color: var(--text-light);
    font-style: italic;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border-light);
    background: var(--surface);
}

.chat-input {
    flex: 1;
    padding: var(--sp-2) var(--sp-3);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: var(--fs-sm);
    color: var(--text);
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus { border-color: var(--primary); }

.chat-input::placeholder { color: var(--text-light); }

.chat-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s;
}

.chat-send:hover { background: var(--primary-light); }
.chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Chat typing dots */
.typing-dots { display: inline-flex; gap: 4px; align-items: center; }
.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-light);
    border-radius: 50%;
    animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* === ANIMATIONS === */
@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes loadingPulse {
    0% { width: 5%; }
    50% { width: 70%; }
    100% { width: 95%; }
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-header {
        padding: var(--sp-3) var(--sp-4);
        flex-wrap: wrap;
        gap: var(--sp-2);
    }

    .header-title { font-size: var(--fs-base); }
    .user-email { display: none; }

    .dashboard-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-right {
        flex-direction: column;
    }

    .form-select { width: 100%; }

    .priority-counters {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-header h2 { font-size: var(--fs-lg); }

    .login-content { padding: var(--sp-6); }

    .chat-panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 70vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .chat-fab { bottom: 16px; right: 16px; }
}

@media (max-width: 480px) {
    .priority-counters {
        grid-template-columns: 1fr 1fr;
        gap: var(--sp-2);
    }

    .counter-card { padding: var(--sp-3); }
    .counter-number { font-size: var(--fs-2xl); }
}

/* ================================================================
   BADGE - YA RESPONDIDO
   ================================================================ */

.badge-respondido {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    font-size: var(--fs-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

.email-card-respondido {
    opacity: 0.6;
    border-left-color: #9ca3af !important;
}

.email-card-respondido:hover {
    opacity: 0.85;
}

/* ================================================================
   WHATSAPP BUTTON & MODAL
   ================================================================ */

.btn-whatsapp {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: #25D366;
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    white-space: nowrap;
}
.btn-whatsapp:hover { background: #1ebe5c; }
.btn-whatsapp:active { transform: scale(0.97); }
.btn-whatsapp:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.btn-ghost:hover { background: var(--surface-alt); color: var(--text-primary); }

/* Modal overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: var(--sp-4);
}

.modal-box {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-4) var(--sp-5);
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
}
.modal-header-left {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-weight: 600;
    font-size: var(--fs-base);
    color: var(--text-primary);
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--sp-1);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: background 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text-primary); }

.modal-body {
    padding: var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
}
.modal-desc {
    margin: 0;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
    line-height: 1.5;
}
.form-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.form-input {
    width: 100%;
    padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--fs-base);
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}
.form-input:focus {
    outline: none;
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}
.form-hint {
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    margin-top: calc(var(--sp-1) * -1);
}
.form-error {
    font-size: var(--fs-xs);
    color: var(--urgent);
    margin-top: calc(var(--sp-1) * -1);
    padding: var(--sp-2) var(--sp-3);
    background: rgba(220, 38, 38, 0.08);
    border-radius: var(--radius-sm);
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
}

/* ── Modal wide variant (for WhatsApp preview) ── */
.modal-box-lg {
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-box-lg .modal-body {
    overflow-y: auto;
    flex: 1 1 auto;
}

/* ── Secondary button ── */
.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    background: var(--surface-alt);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: var(--fs-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.btn-secondary:hover { background: var(--border); }
.btn-secondary:disabled { opacity: 0.6; cursor: not-allowed; }

/* ── Inline link-style button ── */
.btn-link {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: var(--fs-xs);
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}
.btn-link:hover { color: var(--text-primary); }

/* ── WhatsApp preview section ── */
.wa-preview-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: var(--sp-2);
}
.wa-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-primary);
}
.wa-preview-list {
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border);
}
.wa-preview-item {
    background: var(--surface);
    padding: var(--sp-3) var(--sp-4);
}
.wa-preview-label {
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: var(--sp-2);
}
.wa-preview-text {
    font-family: var(--font-mono, 'Courier New', monospace);
    font-size: 0.78rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    color: var(--text-primary);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: var(--sp-3);
}

@media (max-width: 640px) {
    .modal-box { max-width: 100%; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .modal-box-lg { max-width: 100%; max-height: 95vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .modal-overlay { align-items: flex-end; padding: 0; }
    .modal-footer { flex-direction: column-reverse; gap: var(--sp-2); }
    .modal-footer .btn-ghost,
    .modal-footer .btn-secondary,
    .modal-footer .btn-whatsapp { width: 100%; justify-content: center; }
}

/* ── Icon-only button ── */
.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

/* ── Modal footer with wrapping (for 4 buttons) ── */
.modal-footer-wrap {
    flex-wrap: wrap;
    gap: var(--sp-2);
}

/* ── Config panel ── */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
}
@media (max-width: 560px) {
    .config-grid { grid-template-columns: 1fr; }
}

.config-field {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.form-textarea {
    min-height: 90px;
    resize: vertical;
}

.config-radio-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-top: var(--sp-1);
}

.config-radio {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--fs-sm);
    cursor: pointer;
}
.config-radio input[type="radio"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}
