/**
 * Focus TDAH — Styles du mode Pomodoro forcé + vue Tunnel
 *
 * États :
 *  - .focus-tdah-modal : modale de configuration (avant démarrage)
 *  - body.focus-tdah-active : masque TOUT sauf l'overlay
 *  - .focus-tdah-overlay : vue tunnel plein écran avec timer + 1 tâche
 *  - .focus-tdah-complete : écran de fin "Bravo !"
 */

/* ============================================================
 * 1. BOUTON SIDEBAR
 * ============================================================ */

#focus-tdah-btn {
    color: #6366f1;
}

#focus-tdah-btn:hover {
    background: rgba(99, 102, 241, 0.12);
    color: #4f46e5;
}

#focus-tdah-btn[aria-pressed="true"] {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #ffffff;
}

body.dark-mode #focus-tdah-btn {
    color: #a5b4fc;
}

/* ============================================================
 * 2. MODALE DE CONFIGURATION
 * ============================================================ */

.focus-tdah-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: grid;
    place-items: center;
    z-index: 10010;
    animation: focus-tdah-fade-in 0.2s ease-out;
}

@keyframes focus-tdah-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.focus-tdah-modal[hidden] {
    display: none;
}

.focus-tdah-modal-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 28px;
    max-width: 480px;
    width: calc(100% - 32px);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
    animation: focus-tdah-modal-pop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes focus-tdah-modal-pop {
    from { opacity: 0; transform: scale(0.92) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.focus-tdah-modal-card h2 {
    margin: 0 0 20px;
    font-size: 1.4rem;
    font-weight: 700;
    color: #111827;
    font-family: 'Inter', sans-serif;
}

.focus-tdah-field {
    margin-bottom: 18px;
}

.focus-tdah-field > label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.focus-tdah-duration-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.focus-tdah-duration-btn {
    padding: 12px 8px;
    background: #f3f4f6;
    border: 2px solid transparent;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #4b5563;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Inter', sans-serif;
}

.focus-tdah-duration-btn:hover {
    background: #e5e7eb;
    transform: translateY(-1px);
}

.focus-tdah-duration-btn.active {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #ffffff;
    border-color: #6366f1;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.focus-tdah-field select,
.focus-tdah-field input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #ffffff;
    color: #1f2937;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.focus-tdah-field select:focus,
.focus-tdah-field input[type="text"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.focus-tdah-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

.focus-tdah-btn-primary,
.focus-tdah-btn-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: 'Inter', sans-serif;
    transition: all 0.15s;
}

.focus-tdah-btn-primary {
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.focus-tdah-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.focus-tdah-btn-secondary {
    background: #f3f4f6;
    color: #4b5563;
}

.focus-tdah-btn-secondary:hover {
    background: #e5e7eb;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    .focus-tdah-modal-card {
        background: #1f2937;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    }
    .focus-tdah-modal-card h2 { color: #f3f4f6; }
    .focus-tdah-field > label { color: #9ca3af; }
    .focus-tdah-duration-btn {
        background: #374151;
        color: #d1d5db;
    }
    .focus-tdah-duration-btn:hover { background: #4b5563; }
    .focus-tdah-field select,
    .focus-tdah-field input[type="text"] {
        background: #374151;
        color: #f3f4f6;
        border-color: #4b5563;
    }
    .focus-tdah-btn-secondary {
        background: #374151;
        color: #d1d5db;
    }
}

body.dark-mode .focus-tdah-modal-card {
    background: #1f2937;
}
body.dark-mode .focus-tdah-modal-card h2 { color: #f3f4f6; }
body.dark-mode .focus-tdah-field > label { color: #9ca3af; }
body.dark-mode .focus-tdah-duration-btn { background: #374151; color: #d1d5db; }
body.dark-mode .focus-tdah-field select,
body.dark-mode .focus-tdah-field input[type="text"] {
    background: #374151; color: #f3f4f6; border-color: #4b5563;
}
body.dark-mode .focus-tdah-btn-secondary { background: #374151; color: #d1d5db; }

/* ============================================================
 * 3. VUE TUNNEL — body.focus-tdah-active masque tout
 * ============================================================ */

body.focus-tdah-active {
    overflow: hidden;
    background: #0f172a;
}

body.focus-tdah-active > *:not(.focus-tdah-overlay):not(.focus-tdah-complete):not(#luafi-celebration-canvas):not(#luafi-coworker-avatar) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* L'avatar IA Co-Worker reste visible mais en mode sleeping */
body.focus-tdah-active #luafi-coworker-avatar {
    opacity: 0.4;
    pointer-events: none;
}

/* ============================================================
 * 4. OVERLAY TUNNEL
 * ============================================================ */

.focus-tdah-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at center, #1e1b4b 0%, #0f172a 70%);
    color: #f3f4f6;
    display: grid;
    place-items: center;
    z-index: 10005;
    animation: focus-tdah-tunnel-in 0.4s ease-out;
}

.focus-tdah-overlay[hidden] {
    display: none;
}

@keyframes focus-tdah-tunnel-in {
    from { opacity: 0; transform: scale(1.05); }
    to   { opacity: 1; transform: scale(1); }
}

.focus-tdah-tunnel {
    width: 90%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    text-align: center;
    position: relative;
    padding: 24px;
}

/* Bouton quitter */
.focus-tdah-quit {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.15s;
}

.focus-tdah-quit:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

/* Timer block */
.focus-tdah-timer-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.focus-tdah-timer {
    font-family: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
    font-size: clamp(4rem, 12vw, 8rem);
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.05em;
    line-height: 1;
    text-shadow: 0 0 60px rgba(129, 140, 248, 0.5);
    font-variant-numeric: tabular-nums;
}

.focus-tdah-timer-critical {
    color: #fca5a5;
    animation: focus-tdah-pulse-critical 1s ease-in-out infinite;
    text-shadow: 0 0 60px rgba(239, 68, 68, 0.7);
}

@keyframes focus-tdah-pulse-critical {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}

/* Barre de progression */
.focus-tdah-progress-bar {
    width: 100%;
    max-width: 480px;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.focus-tdah-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #818cf8, #a5b4fc);
    border-radius: 999px;
    transition: width 0.1s linear;
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.5);
}

/* Carte tâche */
.focus-tdah-task-card {
    background: rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 24px 32px;
    max-width: 600px;
    width: 100%;
}

.focus-tdah-task-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #a5b4fc;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
}

.focus-tdah-task-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.4;
    font-family: 'Inter', sans-serif;
    word-wrap: break-word;
}

/* Hint en bas */
.focus-tdah-hint {
    font-size: 0.95rem;
    color: #a5b4fc;
    font-style: italic;
    opacity: 0.85;
    min-height: 1.4em;
    transition: opacity 0.2s;
}

/* Responsive */
@media (max-width: 640px) {
    .focus-tdah-tunnel {
        gap: 20px;
        padding: 16px;
    }
    .focus-tdah-task-card {
        padding: 16px 20px;
    }
    .focus-tdah-task-title {
        font-size: 1.1rem;
    }
    .focus-tdah-quit {
        top: 8px;
        right: 8px;
        width: 38px;
        height: 38px;
    }
}

/* ============================================================
 * 5. ÉCRAN DE COMPLETION
 * ============================================================ */

.focus-tdah-complete {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    display: grid;
    place-items: center;
    z-index: 10020;
    animation: focus-tdah-fade-in 0.3s ease-out;
}

.focus-tdah-complete-card {
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 440px;
    width: calc(100% - 32px);
    text-align: center;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.4);
    animation: focus-tdah-complete-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes focus-tdah-complete-pop {
    0%   { opacity: 0; transform: scale(0.7) translateY(40px); }
    60%  { transform: scale(1.04) translateY(0); }
    100% { opacity: 1; transform: scale(1); }
}

.focus-tdah-complete-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    color: #10b981;
    background: rgba(16, 185, 129, 0.12);
    border-radius: 50%;
    display: grid;
    place-items: center;
    animation: focus-tdah-icon-bounce 0.6s ease-out 0.3s both;
}

@keyframes focus-tdah-icon-bounce {
    0%   { transform: scale(0); }
    60%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.focus-tdah-complete-card h2 {
    margin: 0 0 12px;
    font-size: 1.8rem;
    font-weight: 800;
    color: #111827;
    font-family: 'Inter', sans-serif;
}

.focus-tdah-complete-msg {
    font-size: 1.05rem;
    color: #4b5563;
    margin: 0 0 8px;
    line-height: 1.5;
}

.focus-tdah-complete-duration {
    font-size: 2rem;
    font-weight: 800;
    color: #6366f1;
    margin: 16px 0 24px;
    font-family: 'JetBrains Mono', monospace;
}

.focus-tdah-complete-card .focus-tdah-btn-primary {
    width: 100%;
    padding: 14px 24px;
    font-size: 1rem;
}

@media (prefers-color-scheme: dark) {
    .focus-tdah-complete-card {
        background: linear-gradient(135deg, #1f2937, #111827);
    }
    .focus-tdah-complete-card h2 { color: #f3f4f6; }
    .focus-tdah-complete-msg { color: #9ca3af; }
}

body.dark-mode .focus-tdah-complete-card {
    background: linear-gradient(135deg, #1f2937, #111827);
}
body.dark-mode .focus-tdah-complete-card h2 { color: #f3f4f6; }
body.dark-mode .focus-tdah-complete-msg { color: #9ca3af; }

/* ============================================================
 * 6. ACCESSIBILITÉ — prefers-reduced-motion
 * ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .focus-tdah-modal,
    .focus-tdah-modal-card,
    .focus-tdah-overlay,
    .focus-tdah-timer-critical,
    .focus-tdah-complete,
    .focus-tdah-complete-card,
    .focus-tdah-complete-icon {
        animation: none !important;
    }
    .focus-tdah-progress-fill {
        transition: none !important;
    }
}
