/* Limitem l'amplada de la secció de mòduls perquè no ocupi tota la pantalla */
#modulesContainer {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    contain: layout style;
}

/* Assegurem que cada mòdul s'ajusti al contenidor */
.accordionWrapper {
    width: 100%;
    margin-bottom: 20px;
}
.expandable-btn {
    /* ... manté el que tenies i afegeix/revisa això: */
    flex-shrink: 0;         /* Evita que el botó s'aafi si hi ha poc espai */
}

.btnText {
    /* Assegura que el text no forci salts de línia estranys */
    white-space: nowrap;
}
/* EFECTE EXPANDIBLE DELS BOTONS */
.expandable-btn {
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 10px;
    height: 45px;
    min-width: 45px;
    border-radius: 10px;
    transition: padding 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                box-shadow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                background-color 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    white-space: nowrap;
    cursor: pointer;
    background-color: var(--bg-container);
    border: 2px solid var(--border-color);
    color: var(--text-main);
}

.btnText {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 14px;
}

.expandable-btn:hover {
    padding-right: 18px;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.expandable-btn:hover .btnText {
    max-width: 200px;
    opacity: 1;
    margin-left: 10px;
}

/* COLORS ESPECÍFICS */
#fastTaskBtn { border-color: #6f42c1; color: #6f42c1; }
#fastTaskBtn:hover { background-color: #f3ebff; }

#addModuleBtn { border-color: var(--primary-color); color: var(--primary-color); }
#addModuleBtn:hover { background-color: #f0f7ff; }

/* SELECTS DEL MODAL */
.modal-select {
    width: 100%;
    margin-top: 6px;
    padding: 11px 36px 11px 13px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background-color: var(--bg-container);
    color: var(--text-main);
    margin-bottom: 15px;
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    /* Flecha SVG personalitzada */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 16px;
}

.modal-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.13);
}

.modal-select:hover:not(:disabled) {
    border-color: var(--primary-color);
}

.modal-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: var(--bg-panel);
}

/* Options dins del select */
.modal-select option {
    padding: 10px 14px;
    background-color: var(--bg-container);
    color: var(--text-main);
    font-size: 14px;
    font-family: 'Roboto', sans-serif;
}

.modal-select option:checked,
.modal-select option:hover {
    background-color: rgba(0,123,255,0.12);
    color: var(--primary-color);
}

[data-theme="dark"] .modal-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaaaaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

[data-theme="dark"] .modal-select option {
    background-color: #1e1e1e;
    color: #e0e0e0;
}

/* Nou estil per al botó de tancar sessió */
#logoutBtn.logout-style {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    border-color: var(--danger-color);
    color: var(--danger-color);
    background-color: var(--bg-container); /* Color sòlid segons el tema */
    box-shadow: 0 4px 8px var(--shadow-color);
}

/* Efecte Hover: Canvi de fons suau */
#logoutBtn.logout-style:hover {
    background-color: #fff0f0; /* Vermell molt clar en mode clar */
    border-color: #b71c1c;
    color: #b71c1c;
}

/* Adaptació per al Mode Fosc */
[data-theme="dark"] #logoutBtn.logout-style {
    border-color: #ff6b6b;
    color: #ff6b6b;
    background-color: var(--bg-container);
}

[data-theme="dark"] #logoutBtn.logout-style:hover {
    background-color: #3f2a2a; /* Vermell fosc de fons */
}

        /* Botó Tasca Ràpida (Estil Lila) */
#fastTaskBtn {
    padding: 12px 35px;
    font-size: 16px;
    border: 2px solid #6f42c1; /* Color Lila */
    background-color: var(--bg-container);
    color: #6f42c1;
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow-color);
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

#fastTaskBtn:hover {
    background-color: #f3ebff;
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] #fastTaskBtn {
    border-color: #a78bfa;
    color: #a78bfa;
}
[data-theme="dark"] #fastTaskBtn:hover {
    background-color: #2e2a36;
}

/* (modal-select styles defined above) */

        /* Animación al pasar el cursor */
        #logoutBtn:hover {
            background-color: #b71c1c; /* Rojo más oscuro */
            transform: scale(1.05); /* Se hace un pelín más grande */
            box-shadow: 0 6px 12px rgba(0,0,0,0.2);
        }

        /* Animación al hacer clic */
        #logoutBtn:active {
            transform: scale(0.95);
        }
        :root {
            /* Colors Base (Light Mode) */
            --bg-body: #f5f5f5;
            --bg-container: #ffffff;
            --text-main: #222222;
            --text-secondary: #555555;
            --text-muted: #777777;
            --border-color: #dddddd;
            --shadow-color: rgba(0, 0, 0, 0.1);

            /* Colors d'Acció */
            --primary-color: #007bff;
            --primary-hover: #0056b3;
            --secondary-color: #6c757d;
            --success-color: #28a745;
            --danger-color: #dc3545;
            --warning-color: #f39c12;
            --info-color: #17a2b8;
            --highlight-color-light: #e0e0e0;
            --rosa-red-color: #F91818;

            /* Fons Específics */
            --bg-panel: #f8f8f8;
            --bg-ra-header: #f7f7f7;
            --bg-ra-hover: #e9e9e9;
            --bg-table-header: #e9ecef;
            --bg-table-hover: #f8f8ff;

            /* Altres */
            --radius-main: 12px;
            --radius-sm: 8px;
            --transition-speed: 0.3s;
        }

        [data-theme="dark"] {
            /* Colors Base (Dark Mode) */
            --bg-body: #121212;
            --bg-container: #1e1e1e;
            --text-main: #e0e0e0;
            --text-secondary: #b0b0b0;
            --text-muted: #888888;
            --border-color: #333333;
            --shadow-color: rgba(0, 0, 0, 0.5);
            --highlight-color-dark: #3a3a3a;

            /* Fons Específics */
            --bg-panel: #181818;
            --bg-ra-header: #252525;
            --bg-ra-hover: #303030;
            --bg-table-header: #2c2c2c;
            --bg-table-hover: #2a2a2a;
        }

        body {
            font-family: 'Roboto', sans-serif;
            background: var(--bg-body);
            margin: 0;
            padding: 20px;
            color: var(--text-main);
            transition: background-color var(--transition-speed), color var(--transition-speed);
        }

        .container {
            max-width: 900px;
            margin: 0 auto;
        }

        #toastNotification {
            position: fixed;
            top: -60px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 2000;
            padding: 12px 25px;
            border-radius: 8px;
            font-size: 15px;
            font-weight: 500;
            color: white;
            background-color: #333;
            box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
            opacity: 0;
            transition: top 0.5s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.5s ease;
        }

        #toastNotification.show {
            top: 20px;
            opacity: 1;
        }

        /* ===== GRUP BOTONS TOP-RIGHT ===== */
        #topRightGroup {
            position: fixed;
            top: 15px;
            right: 15px;
            z-index: 1001;
            display: flex;
            align-items: center;
            gap: 6px;
        }

        /* Botó circular genèric (campana, tema, hamburguesa) */
        .tr-btn {
            position: relative;
            width: 40px;
            height: 40px;
            border-radius: 50%;
            border: 1px solid var(--border-color);
            background: var(--bg-container);
            color: var(--text-secondary);
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 2px 8px var(--shadow-color);
            transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
            padding: 0;
            flex-shrink: 0;
        }
        .tr-btn:hover {
            background: var(--bg-panel);
            color: var(--text-main);
            transform: scale(1.08);
            box-shadow: 0 4px 14px var(--shadow-color);
        }
        .tr-btn.active {
            background: var(--primary-color);
            color: white;
            border-color: var(--primary-color);
        }
        /* Campana amb notificacions pendents: petit pulse */
        .tr-btn.has-notifs { animation: bellPulse 2.5s ease infinite; }
        @keyframes bellPulse {
            0%, 100% { box-shadow: 0 2px 8px var(--shadow-color); }
            50%       { box-shadow: 0 2px 16px rgba(234, 67, 53, 0.45); }
        }

        /* Sobreescriure #themeToggleBtn per eliminar el position:fixed propi */
        #themeToggleBtn {
            position: static !important;
            width: 40px !important;
            height: 40px !important;
            box-shadow: none !important;
        }
        #themeToggleBtn:hover { transform: scale(1.08) !important; }

        #topControls {
    display: flex;
    justify-content: center; /* Centra els botons al mig */
    align-items: center;
    padding: 15px;
    gap: 25px;              /* Espai fix i controlat entre botons */
    flex-wrap: wrap;        /* Per si no caben en mòbil */
}


#secondaryControls {
    display: flex;
    gap: 10px;              /* Espai entre els botons de la dreta */
}

        #addModuleBtn,
        #exportDataBtn,
        #importDataBtn,
        #showPendingTasksBtn,
        .addRaBtn,
        .toggleStatusBtn,
        .raAccordion {
            cursor: pointer;
            transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s;
            font-weight: 500;
            white-space: nowrap;
        }

        button:focus,
        input:focus,
        .accordion:focus,
        .raAccordion:focus {
            outline: 2px solid var(--primary-color);
            outline-offset: 2px;
            border-radius: 5px;
        }

        /* Botó principal i fletxa del split-btn: sense outline propi */
        .add-task-main-btn:focus,
        .add-task-arrow-btn:focus,
        #fastTaskBtn:focus {
            outline: none;
        }

        /* Focus visible al contenidor del split-btn */
        .add-task-split-btn:focus-within {
            outline: 2px solid #6f42c1;
            outline-offset: 3px;
            border-radius: 11px;
        }

        #addModuleBtn {
            padding: 12px 35px;
            font-size: 16px;
            border: 2px solid var(--primary-color);
            background-color: var(--bg-container);
            color: var(--primary-color);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
            margin: 0;
            display: flex;
            align-items: center;
        }

        #addModuleBtn:hover {
            background-color: #f0f7ff;
            transform: translateY(-2px);
            box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
        }

        [data-theme="dark"] #addModuleBtn {
            background-color: var(--bg-container);
            border-color: #3b82f6;
            color: #3b82f6;
        }

        [data-theme="dark"] #addModuleBtn:hover {
            background-color: #27272a;
            box-shadow: 0 6px 10px rgba(0, 0, 0, 0.3);
        }

        .btnIconWrapper {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 18px;
            height: 18px;
            margin-right: 5px;
        }

        .btnIconWrapper svg {
            width: 100%;
            height: 100%;
            stroke-width: 2.5;
        }

        #exportDataBtn,
        #importDataBtn,
        #showPendingTasksBtn {
            padding: 8px 14px;
            font-size: 14px;
            border-radius: 6px;
            border-width: 1px;
            border-style: solid;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
            background-color: var(--bg-container);
            display: flex;
            align-items: center;
        }

        #exportDataBtn {
            border-color: var(--warning-color);
            color: var(--warning-color);
        }

        #exportDataBtn:hover {
            background-color: #fff8e1;
            transform: translateY(-1px);
        }

        #importDataBtn {
            border-color: #3498db;
            color: #3498db;
        }

        #importDataBtn:hover {
            background-color: #eaf6ff;
            transform: translateY(-1px);
        }

        #showPendingTasksBtn {
            border: 2px solid var(--danger-color);
            color: var(--danger-color);
        }

        #showPendingTasksBtn:hover {
            background-color: #fff0f0;
            transform: translateY(-1px);
        }

        [data-theme="dark"] #exportDataBtn:hover { background-color: #4a3e26; }
        [data-theme="dark"] #importDataBtn:hover { background-color: #2b3a4a; }
        [data-theme="dark"] #showPendingTasksBtn:hover { background-color: #3f2a2a; }

        .addRaBtn {
            padding: 8px 16px;
            font-size: 14px;
            margin: 10px 0 0 0;
            border: 2px solid var(--info-color);
            color: var(--info-color);
            background-color: var(--bg-container);
            border-radius: 8px;
            box-shadow: 0 4px 6px var(--shadow-color);
        }

        .addRaBtn:hover {
            background-color: #e8f9fd;
            transform: translateY(-1px);
        }

        [data-theme="dark"] .addRaBtn:hover { background-color: #2a3a3d; }

        .accordionWrapper {
            position: relative;
            margin: 15px 0;
            border-radius: 12px;
            box-shadow: 0 4px 8px var(--shadow-color);
            padding: 0;
            background-color: var(--bg-container);
            transition: border-left-color 0.3s ease, background-color var(--transition-speed);
            border-left: 8px solid;
            border-left-color: var(--module-color, #ccc);
        }

        .accordion {
            cursor: default;
            border: none;
            background: none;
            display: flex;
            flex-direction: column;
            transition: 0.3s;
            outline: none;
            padding: 0;
            text-align: left;
            width: 100%;
        }

        .titleRow {
            padding: 12px 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: var(--bg-container);
            border-radius: 12px;
            transition: background 0.3s;
            cursor: pointer;
        }

        .titleRow .rightControls { cursor: default; }

        .moduleInfo {
            display: flex;
            flex-direction: column;
            flex-grow: 1;
        }

        .moduleTitle {
            font-weight: 700;
            font-size: 18px;
            color: var(--text-main);
        }

        .professor {
            font-weight: 400;
            font-size: 14px;
            color: var(--text-secondary);
            margin-top: 4px;
        }

        /* ── TASCA PROPERA: pill que s'expandeix al hover ── */
        .deadlineAlert {
            position: absolute;
            top: -11px;
            right: 12px;
            height: 22px;
            width: 22px;
            border-radius: 11px;
            background: linear-gradient(135deg, #e53935 0%, #dc3545 100%);
            border: 2px solid var(--bg-container);
            box-shadow: 0 2px 8px rgba(220,53,69,0.5);
            z-index: 10;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 0;
            overflow: hidden;
            white-space: nowrap;
            transition:
                width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease,
                transform 0.15s ease;
        }

        /* Lletra "i" d'informació */
        .deadlineAlert::before {
            content: "i";
            font-family: 'Georgia', 'Times New Roman', serif;
            font-style: italic;
            font-weight: 700;
            font-size: 13px;
            color: #ffffff;
            line-height: 1;
            flex-shrink: 0;
            display: block;
            min-width: 18px;
            text-align: center;
        }

        /* Text "Tasca propera" — ocult per defecte */
        .deadlineAlert::after {
            content: "Tasca propera";
            /* Combined with ::before "i" gives: i | Tasca propera */
            font-family: 'Roboto', sans-serif;
            font-style: normal;
            font-size: 11px;
            font-weight: 700;
            color: #ffffff;
            letter-spacing: 0.02em;
            padding-right: 8px;
            max-width: 0;
            overflow: hidden;
            opacity: 0;
            transition:
                max-width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                opacity 0.2s ease 0.08s;
        }

        .deadlineAlert:hover {
            width: 136px;
            box-shadow: 0 4px 14px rgba(220,53,69,0.6);
            transform: translateY(-1px);
        }

        .deadlineAlert:hover::after {
            max-width: 115px;
            opacity: 1;
        }

        .rightControls {
            display: flex;
            flex-direction: row;
            align-items: center;
            gap: 10px;
            margin-left: 20px;
        }

        .toggleStatusBtn {
            padding: 8px 14px;
            font-size: 14px;
            font-weight: 600;
            border-radius: 8px;
            border: none;
            cursor: pointer;
            transition: box-shadow 0.25s ease, transform 0.2s ease;
            white-space: nowrap;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
            display: flex;
            align-items: center;
            gap: 5px;
            position: relative;
            overflow: hidden;
        }

        /* Animació sortida (s'encongeix) */
        @keyframes statusExit {
            0%   { transform: scale(1); opacity: 1; }
            100% { transform: scale(0.75); opacity: 0; }
        }

        /* Animació entrada (rebota amb el nou color) */
        @keyframes statusEnter {
            0%   { transform: scale(0.6); opacity: 0; }
            60%  { transform: scale(1.12); opacity: 1; }
            80%  { transform: scale(0.95); }
            100% { transform: scale(1); opacity: 1; }
        }

        .toggleStatusBtn.status-btn-exit {
            animation: statusExit 0.15s ease forwards;
            pointer-events: none;
        }

        .toggleStatusBtn.status-btn-enter {
            animation: statusEnter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        }

        .toggleStatusBtn.done {
            background: linear-gradient(135deg, #28a745 0%, #20c955 100%);
            color: white;
            box-shadow: 0 3px 8px rgba(40,167,69,0.40);
        }
        .toggleStatusBtn.done:hover {
            background: linear-gradient(135deg, #218838 0%, #1aad49 100%);
            transform: translateY(-1px);
            box-shadow: 0 5px 14px rgba(40,167,69,0.45);
        }
        .toggleStatusBtn.todo {
            background: linear-gradient(135deg, #dc3545 0%, #f04556 100%);
            color: white;
            box-shadow: 0 3px 8px rgba(220,53,69,0.40);
        }
        .toggleStatusBtn.todo:hover {
            background: linear-gradient(135deg, #c82333 0%, #e0303f 100%);
            transform: translateY(-1px);
            box-shadow: 0 5px 14px rgba(220,53,69,0.45);
        }

        .iconBtn {
            width: 24px;
            height: 24px;
            cursor: pointer;
            transition: transform 0.2s;
            color: var(--text-secondary);
            padding: 0;
            border: none;
            background: none;
        }

        .iconBtn:hover { transform: scale(1.15); color: var(--text-main); }
        .editModuleIcon:hover { color: var(--primary-color); }
        .deleteModuleIcon:hover { color: var(--danger-color); }

        .accordionArrow { transition: transform 0.3s ease; }
        .accordion[aria-expanded="true"]~.rightControls .accordionArrow { transform: rotate(90deg); }

        .colorPicker {
            margin: 0;
            cursor: pointer;
            border: 1px solid var(--border-color);
            height: 24px;
            width: 36px;
            border-radius: 4px;
            padding: 0;
            -webkit-appearance: none;
            appearance: none;
            background: none;
        }
        
        .colorPicker::-webkit-color-swatch-wrapper { padding: 0; }
        .colorPicker::-webkit-color-swatch { border: none; border-radius: 4px; }

        .panel {
            padding: 0 20px;
    overflow: hidden;
    max-height: 0;
    /* Cambio: Más rápido (0.3s) y curva más fluida */
    transition: max-height 0.8s cubic-bezier(0.4, 0, 0.2, 1), padding 0.8s ease;
    background-color: var(--bg-panel);
    border-radius: 0 0 12px 12px;
        }

        .accordion[aria-expanded="true"]~.panel { padding: 20px; }

        /* ── Scroll quan el panel té contingut que desborda ── */
        .panel.is-open {
            overflow-y: auto;
            overflow-x: hidden;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
            scrollbar-color: var(--border-color) transparent;
        }
        .panel.is-open::-webkit-scrollbar { width: 5px; }
        .panel.is-open::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 6px; }
        .panel.is-open::-webkit-scrollbar-track { background: transparent; }

        .raAccordionWrapper {
            margin-bottom: 5px;
            border: 1px solid var(--border-color);
            border-left: 3px solid var(--module-color, #888);
            border-radius: 7px;
            background-color: var(--bg-container);
            transition: border-left-color 0.3s ease, box-shadow 0.2s;
            overflow: hidden;
        }

        .raAccordionWrapper:hover {
            box-shadow: 0 2px 8px var(--shadow-color);
        }

/* Contenedor interno para los RA — sense scroll propi */
        .raContainer {
            max-height: none;
            overflow-y: visible;
            margin-bottom: 15px;
        }

        .raAccordion {
            cursor: pointer;
            padding: 11px 14px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-weight: 600;
            font-size: 14px;
            background-color: var(--bg-ra-header);
            border-radius: 6px;
            transition: background-color 0.2s;
            border: none;
            width: 100%;
            text-align: left;
            color: var(--text-main);
            gap: 12px;
        }

        .raAccordion:hover { background-color: var(--bg-ra-hover); }

        .raName {
            flex: 1;
            min-width: 0;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* Badge de nombre de tasques */
        .raBadge {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            min-width: 20px;
            height: 20px;
            padding: 0 6px;
            border-radius: 10px;
            background: var(--border-color);
            color: var(--text-secondary);
            font-size: 11px;
            font-weight: 700;
            flex-shrink: 0;
            transition: background 0.25s, color 0.25s;
        }
        .raAccordion[aria-expanded="true"] .raBadge {
            background: var(--primary-color);
            color: #fff;
        }

        .raControls {
            display: flex;
            gap: 8px;
            align-items: center;
            flex-shrink: 0;
        }

        .raControls .iconBtn { width: 17px; height: 17px; }

        /* Fletxa del RA — classe raArrow, transició correcta */
        .raArrow {
            transition: transform 0.3s ease;
            flex-shrink: 0;
            color: var(--text-secondary);
        }
        .raAccordion[aria-expanded="true"] .raArrow { transform: rotate(90deg); }

        .raPanel {
            padding: 0 10px;
            overflow: hidden;
            max-height: 0;
            transition: max-height 0.7s cubic-bezier(0.4, 0, 0.2, 1), padding 0.7s ease;
            background-color: var(--bg-body);
        }

        .raAccordion[aria-expanded="true"]~.raPanel {
            padding: 10px;
            border-top: 1px solid var(--border-color);
        }

        .taskScrollContainer {
            max-height: 240px;
            overflow-y: auto;
            margin-bottom: 6px;
            border: 1px solid var(--border-color);
            border-radius: 6px;
            scrollbar-width: thin;
            scrollbar-color: var(--border-color) transparent;
        }
        .taskScrollContainer::-webkit-scrollbar { width: 5px; }
        .taskScrollContainer::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 6px; }

        .taskTable {
            width: 100%;
            border-collapse: collapse;
            border-radius: 6px;
            overflow: hidden;
        }

        .taskTable th, .taskTable td {
            border: none;
            padding: 7px 10px;
            text-align: left;
            vertical-align: middle;
            font-size: 13px;
        }

        .taskTable th {
            background: var(--bg-table-header);
            color: var(--text-secondary);
            font-weight: 600;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            border-bottom: 1px solid var(--border-color);
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .taskTable tr:not(:first-child) {
            border-bottom: 1px solid var(--border-color);
            transition: background-color 0.15s;
        }

        .taskTable tr:not(:first-child):hover { background-color: var(--bg-table-hover); }

        .taskTable td:first-child { text-align: center; width: 28px; font-weight: 500; color: var(--text-muted); font-size: 12px; }
        .taskTable td:nth-child(4) { width: 55px; }
        .taskTable td:nth-child(5) { text-align: center; width: 70px; }
        .taskTable .task-toggle-cell {
            text-align: center;
            vertical-align: middle;
            padding-left: 10px;
            padding-right: 10px;
        }

        .taskTable td input[type="text"], .taskTable td input[type="date"] {
            padding: 5px 7px;
            border: 1px solid transparent;
            background-color: transparent;
            color: var(--text-main);
            border-radius: 5px;
            width: 95%;
            font-size: 13px;
            transition: border-color 0.2s, background 0.2s;
        }

        .taskTable td input[type="text"]:hover, .taskTable td input[type="date"]:hover {
            border-color: var(--border-color);
            background-color: var(--bg-container);
        }

        .taskTable td input[type="text"]:focus, .taskTable td input[type="date"]:focus {
            border-color: var(--primary-color);
            background-color: var(--bg-container);
            outline: none;
        }

        .taskTable td input[type="date"] { width: 100%; }

        .taskTable td input[type="text"].task-done {
            text-decoration: line-through;
            opacity: 0.5;
            color: var(--text-muted) !important;
        }

        .task-highlight {
            background-color: var(--highlight-color-light) !important;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            transition: all 0.5s ease;
        }

        [data-theme="dark"] .task-highlight {
            background-color: var(--highlight-color-dark) !important;
            box-shadow: 0 0 15px rgba(255, 255, 255, 0.1);
        }

        .addTaskBtn {
            padding: 7px 0;
            width: 100%;
            font-size: 12px;
            font-weight: 600;
            border: 1.5px dashed #2ecc71;
            background-color: transparent;
            color: #2ecc71;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.2s ease;
            margin-top: 6px;
            margin-bottom: 4px;
            letter-spacing: 0.3px;
        }

        .addTaskBtn:hover {
            background-color: #f0fff4;
            border-style: solid;
            transform: translateY(-1px);
            box-shadow: 0 2px 8px rgba(46, 204, 113, 0.2);
        }

        [data-theme="dark"] .addTaskBtn { color: #48c56c; border-color: #48c56c; }
        [data-theme="dark"] .addTaskBtn:hover { background-color: rgba(72, 197, 108, 0.08); box-shadow: 0 2px 8px rgba(72, 197, 108, 0.15); }

     

    
        .slider::before {
            content: "";
            position: absolute;
            height: 14px;
            width: 14px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: transform 0.3s;
            transform: translateX(0);
            border-radius: 50%;
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
        }


        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.6);
            display: none;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            backdrop-filter: blur(2px);
            opacity: 0;
            transition: opacity 0.3s ease;
        }

        .modal-overlay.visible { opacity: 1; }

        .modal {
            background: var(--bg-container);
            padding: 30px;
            border-radius: 10px;
            max-width: 450px;
            width: 90%;
            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
            text-align: center;
            transform: scale(0.95);
            transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .modal-overlay.visible .modal { transform: scale(1); }

        .modal h3 { margin-top: 0; color: var(--text-main); }
        #editModal .modal { text-align: left; }
        
        .modal label {
            display: block;
            text-align: left;
            margin-top: 15px;
            font-weight: 500;
            color: var(--text-secondary);
        }

        .modal input {
            width: 100%;
            margin-top: 5px;
            padding: 10px;
            border-radius: 6px;
            border: 1px solid var(--border-color);
            background-color: var(--bg-container);
            color: var(--text-main);
            font-size: 16px;
        }

        .modal div.modal-actions {
            display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 25px;
        }

        .modal button {
            padding: 12px 25px;
            border: none;
            border-radius: 8px;
            cursor: pointer;
            font-weight: 500;
            font-size: 16px;
            min-width: 100px;
            transition: all 0.2s ease-in-out;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .modal .confirmBtn { background: var(--primary-color); color: #fff; }
        .modal .confirmBtn:hover { background: var(--primary-hover); transform: scale(1.05); }

        .modal .cancelBtn { background: #e9ecef; color: #495057; }
        .modal .cancelBtn:hover { background: #ced4da; transform: scale(1.05); }
        
        [data-theme="dark"] .modal .cancelBtn { background: #333333; color: #e0e0e0; }
        [data-theme="dark"] .modal .cancelBtn:hover { background: #444444; }

        #pendingTasksModal .modal {
            max-width: 600px;
            text-align: center;
            padding: 30px;
        }

        #pendingTasksContent ul {
            list-style: none;
            padding: 0;
            max-height: 400px;
            overflow-y: auto;
            display: inline-block;
            width: 100%;
            text-align: left;
        }

        #pendingTasksContent li {
            padding: 15px 20px;
            margin-bottom: 12px;
            border-radius: 10px;
            border-left: 6px solid #e0e0e0;
            background-color: var(--bg-panel);
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
            transition: transform 0.2s;
            cursor: pointer;
        }

        [data-theme="dark"] #pendingTasksContent li { border-left: 6px solid #333333; }
        #pendingTasksContent li:hover { transform: translateY(-2px); background-color: var(--bg-ra-hover); }

        #pendingTasksContent .task-info {
            font-family: 'Playfair Display', serif;
            font-weight: 700;
            font-size: 19px;
            color: var(--text-main);
        }

        #pendingTasksContent .task-meta {
            font-size: 14px;
            color: var(--text-muted);
            margin-top: 5px;
            line-height: 1.2;
            font-weight: 400;
        }

        .urgent-task {
            border-left-color: var(--danger-color) !important;
            background-color: rgba(220, 53, 69, 0.1);
        }

        [data-theme="dark"] .urgent-task { background-color: rgba(220, 53, 69, 0.15); }

        #pendingTasksContent .task-date-status {
            text-align: right;
            font-size: 14px;
            font-weight: 700;
            min-width: 80px;
        }

        .footer {
            text-align: center;
            padding: 20px 0;
            margin-top: 30px;
            font-size: 13px;
            color: var(--text-muted);
            background-color: var(--bg-panel);
            border-radius: 10px;
        }

        .footer p { margin: 5px 0; }
        .footer a { color: var(--primary-color); text-decoration: none; }
        .footer a:hover { text-decoration: underline; }

        /* Auth Styles */
        .auth-wrapper {
            position: fixed;
            inset: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            width: 100vw;
            background: linear-gradient(135deg, #667eea, #764ba2);
            font-family: system-ui, Arial;
            z-index: 9999;
        }

        .auth-card {
            background: white;
            padding: 30px;
            border-radius: 16px;
            width: 320px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, .25);
            display: flex;
            flex-direction: column;
            gap: 12px;
            animation: fadeIn .6s ease;
            text-align: center;
        }

        .auth-card h2 { margin: 0; text-align: center; }
        .auth-sub { text-align: center; color: #666; font-size: 14px; }

        .google-login-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 10px;
            background-color: #ffffff;
            color: #333;
            border: 1px solid #ddd;
            border-radius: 8px;
            padding: 12px;
            font-size: 15px;
            font-weight: 500;
            cursor: pointer;
            transition: all 0.2s;
            width: 100%;
        }

        .google-login-btn:hover { background-color: #ffffff; color: #202124; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); }
        .auth-msg { color: #e53935; text-align: center; font-size: 13px; }
        @keyframes fadeIn { from { opacity: 0; transform: scale(.95) } to { opacity: 1; transform: scale(1) } }

        /* From Uiverse.io by Galahhad - CORREGIT */
/* Botó estat tasca original */
.taskStatusToggle {
    display: inline-block;
    width: 46px;
    height: 24px;
    background-color: #e9e9ea; /* Gris suau (No feta) */
    border-radius: 50px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

/* Color quan està Feta (Verd modern) */
.taskStatusToggle[data-status="Feta"] {
    background-color: #34c759;
}

/* La boleta blanca */
.taskStatusToggle .slider {
    position: absolute;
    width: 20px;
    height: 20px;
    background-color: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Moviment de la boleta */
.taskStatusToggle[data-status="Feta"] .slider {
    left: 24px;
}

/* Ratllat del text */
.task-done {
    text-decoration: line-through !important;
    opacity: 0.5;
    color: #8e8e93 !important;
}
/* Mou el text "Estat" de la capçalera cap a la dreta */
.taskTable thead th:nth-child(4) {
    text-align: center;
    padding-left: 25px; /* Mateix valor que hem posat a .task-toggle-cell */
}
/* ==================== TASK LINKS COLUMN ==================== */

/* Cel·la de la columna Enllaços */
.task-links-cell {
    text-align: center;
    padding: 4px 8px;
    white-space: nowrap;
}

/* Grup de 2 icones (document + moodle) */
.task-links-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Cada parella icona + botó editar */
.task-link-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

/* Icona principal clicable */
.task-link-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    text-decoration: none;
    transition: background 0.2s, opacity 0.2s, transform 0.15s;
}

/* Quan NO té link: gris apagat */
.task-link-icon.no-link {
    opacity: 0.25;
    cursor: default;
}
.task-link-icon.no-link svg {
    stroke: var(--text-muted, #999);
}

/* Quan SÍ té link: color actiu */
.task-link-icon.has-link {
    opacity: 1;
}
.task-link-icon.doc-link.has-link svg {
    stroke: #4a90e2;
}
.task-link-icon.moodle-link.has-link svg {
    stroke: #e66000;
}
.task-link-icon.has-link:hover {
    transform: scale(1.15);
    background: rgba(0,0,0,0.07);
}

/* Botó llapis petit per editar la URL */
.edit-link-btn {
    position: absolute;
    top: -6px;
    right: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--bg-container, #fff);
    border: 1px solid var(--border-color, #ddd);
    padding: 0;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    color: var(--text-main);
}
.task-link-wrapper:hover .edit-link-btn {
    opacity: 1;
}
.edit-link-btn:hover {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    color: #fff;
}
.edit-link-btn svg {
    stroke: currentColor;
}

/* fi modal enllaç */

/* ==================== MODAL EDITAR ENLLAÇ ==================== */

#linkEditModal .modal {
    max-width: 460px;
    text-align: left;
}

/* Icona gran de color al capdamunt del modal */
.link-modal-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    margin: 0 auto 16px auto;
    transition: background 0.2s;
}

.link-modal-icon.icon-doc {
    background: #e8f0fe;
    color: #4a90e2;
}
.link-modal-icon.icon-doc svg { stroke: #4a90e2; }

.link-modal-icon.icon-moodle {
    background: #fff0e6;
    color: #e66000;
}
.link-modal-icon.icon-moodle svg { stroke: #e66000; }

[data-theme="dark"] .link-modal-icon.icon-doc { background: #1a2a40; }
[data-theme="dark"] .link-modal-icon.icon-moodle { background: #2e1a00; }

#linkEditModal h3 {
    text-align: center;
    margin-bottom: 4px;
}

/* Subtítol descriptiu */
.link-modal-subtitle {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0 0 18px 0;
    line-height: 1.4;
}

/* Wrapper input amb icona prefix */
.link-input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-container);
    margin-top: 5px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.link-input-wrapper:focus-within {
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.12);
}

.link-input-prefix {
    display: flex;
    align-items: center;
    padding: 0 10px;
    color: var(--text-secondary);
    background: var(--bg-container);
    border-right: 1px solid var(--border-color);
    height: 42px;
}

.link-input-wrapper input {
    flex: 1;
    border: none !important;
    box-shadow: none !important;
    outline: none;
    padding: 10px 12px;
    font-size: 16px;
    background: var(--bg-container);
    color: var(--text-main);
    font-family: inherit;
}

/* Botons del modal d'enllaç */
.link-modal-actions {
    display: flex;
    justify-content: space-between !important;
    align-items: center;
    margin-top: 22px;
}

.link-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px !important;
    padding: 10px 14px !important;
    min-width: unset !important;
    background: #fff0f0 !important;
    color: #c0392b !important;
    border: 1px solid #fdd !important;
}

.link-clear-btn:hover {
    background: #fde0e0 !important;
    transform: scale(1.03) !important;
}

[data-theme="dark"] .link-clear-btn {
    background: #3a1a1a !important;
    border-color: #6b2020 !important;
    color: #ff7070 !important;
}

/* ==================== OPCIONALS TASCA RÀPIDA ==================== */

.optionals-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
    padding: 9px 14px;
    border-radius: 8px;
    border: 1.5px dashed var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    text-align: left;
}

.optionals-toggle-btn:hover {
    border-color: #6f42c1;
    color: #6f42c1;
    background: #f3ebff;
}

[data-theme="dark"] .optionals-toggle-btn:hover {
    background: #2a1a40;
    color: #b388ff;
    border-color: #b388ff;
}

.optionals-toggle-btn svg {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.optionals-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.55;
    letter-spacing: 0.01em;
}

/* Panel col·lapsable */
.optionals-panel {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.35s ease, opacity 0.25s ease, margin-top 0.25s ease;
    margin-top: 0;
}

.optionals-panel.open {
    max-height: 400px;
    opacity: 1;
    margin-top: 12px;
}

/* ================================================================
   GMAIL / MOODLE NOTIFICATIONS PANEL
   Panel lateral deslizant amb tasques detectades dels correus
   ================================================================ */

/* --- Botó principal de notificacions --- */
#gmailNotifBtn {
    border-color: #ea4335;
    color: #ea4335;
    position: relative;
}
#gmailNotifBtn:hover { background-color: #fff5f5; }
#gmailNotifBtn.gmail-connected { border-color: #34a853; color: #34a853; }
#gmailNotifBtn.gmail-connected:hover { background-color: #f0fff4; }
[data-theme="dark"] #gmailNotifBtn { border-color: #ff6b6b; color: #ff6b6b; }
[data-theme="dark"] #gmailNotifBtn:hover { background-color: #3a2424; }
[data-theme="dark"] #gmailNotifBtn.gmail-connected { border-color: #4caf6e; color: #4caf6e; }

/* --- Badge número notificacions --- */
.notif-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ea4335;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 17px;
    height: 17px;
    border-radius: 10px;
    padding: 0 4px;
    margin-left: 6px;
    line-height: 1;
    animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes badgePop {
    from { transform: scale(0); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* --- Overlay fosc de fons --- */
.gmail-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 1500;
    pointer-events: none;
    transition: background 0.35s ease;
}
.gmail-panel-overlay.visible {
    background: rgba(0,0,0,0.35);
    pointer-events: all;
}

/* --- Panel lateral --- */
.gmail-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 380px;
    max-width: 95vw;
    height: 100vh;
    background: var(--bg-container);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 32px rgba(0,0,0,0.18);
    z-index: 1600;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}
.gmail-panel.open {
    right: 0;
}
/* GPU compositing al gmail panel */
.gmail-panel {
    will-change: transform;
    backface-visibility: hidden;
}

/* --- Capçalera del panel --- */
.gmail-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-panel);
    flex-shrink: 0;
}
.gmail-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
}
.gmail-panel-title svg { color: #ea4335; flex-shrink: 0; }
.gmail-panel-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.2s, background 0.2s;
}
.gmail-panel-close:hover { color: var(--text-main); background: var(--bg-ra-hover); }

/* --- Estats del panel (connect / loading / empty) --- */
.gmail-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px 28px;
    flex: 1;
    text-align: center;
}
.gmail-state-icon {
    color: var(--text-muted);
    opacity: 0.7;
}
.gmail-state-title {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-main);
    margin: 0;
}
.gmail-state-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.5;
    max-width: 260px;
}

/* --- Botó connectar Google --- */
.gmail-connect-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    color: #333;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    padding: 11px 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    margin-top: 4px;
}
.gmail-connect-btn:hover {
    background: #f7f7f7;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-1px);
}
[data-theme="dark"] .gmail-connect-btn {
    background: #2a2a2a;
    color: #e0e0e0;
    border-color: #444;
}
[data-theme="dark"] .gmail-connect-btn:hover { background: #333; }

/* --- Spinner de càrrega --- */
.gmail-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: #ea4335;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Capçalera de resultats --- */
.gmail-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    flex-shrink: 0;
}
.gmail-count-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.gmail-refresh-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1.5px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.gmail-refresh-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f7ff;
}
[data-theme="dark"] .gmail-refresh-btn:hover { background: #1a2a3a; }

/* --- Llista de tasques --- */
.gmail-tasks-list {
    padding: 4px 12px 20px;
    overflow-y: auto;
    flex: 1;
}
.gmail-tasks-list::-webkit-scrollbar { width: 5px; }
.gmail-tasks-list::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* --- Card de cada tasca --- */
.gmail-task-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-color);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 10px;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
    animation: slideInCard 0.35s ease both;
}
@keyframes slideInCard {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
.gmail-task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}
.gmail-task-card.gmail-task-urgent {
    border-left-color: #ea4335;
    background: rgba(234, 67, 53, 0.04);
}
[data-theme="dark"] .gmail-task-card.gmail-task-urgent {
    background: rgba(234, 67, 53, 0.1);
}
.gmail-task-card.gmail-task-added {
    opacity: 0.5;
    border-left-color: #34a853;
}

/* --- Contingut de la card --- */
.gmail-task-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 5px;
}
.gmail-task-name {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-main);
    line-height: 1.3;
    flex: 1;
}
.gmail-task-date {
    font-size: 11px;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
    background: rgba(0, 123, 255, 0.08);
    padding: 2px 7px;
    border-radius: 10px;
    flex-shrink: 0;
}
.gmail-task-date.urgent {
    color: #ea4335;
    background: rgba(234, 67, 53, 0.1);
}
.gmail-task-curs {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.3;
    font-weight: 400;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Accions de la card --- */
.gmail-task-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.gmail-task-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(234, 67, 53, 0.08);
    color: #ea4335;
    border: 1px solid rgba(234, 67, 53, 0.25);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}
.gmail-task-link-btn:hover {
    background: rgba(234, 67, 53, 0.15);
    transform: translateY(-1px);
}
.gmail-task-add-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 123, 255, 0.07);
    color: var(--primary-color);
    border: 1px solid rgba(0, 123, 255, 0.25);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.gmail-task-add-btn:hover:not(:disabled) {
    background: rgba(0, 123, 255, 0.15);
    transform: translateY(-1px);
}
.gmail-task-add-btn:disabled { opacity: 0.5; cursor: default; color: #34a853; border-color: #34a853; }
.gmail-task-no-link {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* ================================================================
   RESPONSIVE — Disseny mòbil professional (estil Trello)
   ================================================================ */

/* El div de fons del nav mòbil és invisible en escriptori */
#mobileNavBg { display: none; }

@media (max-width: 768px) {

    /* ── BODY ── */
    body {
        padding: 0;
        font-size: 15px;
    }

    .container { padding: 0; max-width: 100%; }

    /* ─────────────────────────────────────────────
       BARRA DE NAV MÒBIL — franja fixa al capdamunt
       ────────────────────────────────────────────── */
    #mobileNavBg {
        display: block;
        position: fixed;
        top: 0; left: 0; right: 0;
        height: 56px;
        background: var(--bg-container);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 10px var(--shadow-color);
        z-index: 999;
    }

    /* Logout: ancorat a l'esquerra de la barra */
    #logoutBtn.logout-style {
        position: fixed;
        top: 0;
        left: 0;
        height: 56px;
        padding: 0 14px !important;
        font-size: 12px;
        border: none;
        border-right: 1px solid var(--border-color);
        border-radius: 0 !important;
        background: transparent;
        z-index: 1001;
        min-width: unset;
    }

    /* Top-right group: alineat verticalment al centre de la barra */
    #topRightGroup {
        top: 0;
        right: 0;
        height: 56px;
        padding: 0 10px;
        gap: 4px;
        align-items: center;
    }

    .tr-btn {
        width: 36px;
        height: 36px;
    }

    /* Tot el contingut principal comença SOTA la barra */
    #appContainer > #globalSearchBar,
    #appContainer > .container,
    #appContainer > div:not(#mobileNavBg):not(#topRightGroup) {
        /* El globalSearchBar no és fill directe de appContainer, però
           li donem marge via el primer element de flux */
    }

    /* La barra de cerca: just sota la barra de nav */
    #globalSearchBar {
        padding: 12px 12px 0;
        max-width: 100%;
        margin-top: 56px !important;   /* alçada de la barra de nav */
    }

    /* Controls principals */
    #topControls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px 12px;
        background: var(--bg-container);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 6px var(--shadow-color);
        margin-bottom: 0;
    }

    /* Nou Mòdul: amplada completa */
    #addModuleBtn {
        grid-column: 1 / -1;
        justify-content: center;
        padding: 11px 16px;
        font-size: 14px;
        border-radius: 10px;
    }

    /* Split button tasca ràpida */
    .add-task-dropdown-wrapper { grid-column: 1 / -1; }
    .add-task-split-btn { width: 100%; height: 42px; }
    .add-task-main-btn { font-size: 13px !important; }

    /* Botons Export, Import, Pending */
    #exportDataBtn,
    #importDataBtn,
    #showPendingTasksBtn {
        padding: 8px 10px;
        font-size: 12.5px;
        justify-content: center;
        border-radius: 9px;
    }

    /* ── MODULES CONTAINER ── */
    #modulesContainer { padding: 10px; max-width: 100%; }

    /* ── CARD MÒDUL ── */
    .accordionWrapper {
        border-radius: 10px;
        border-left-width: 5px;
        margin: 0 0 10px 0;
        box-shadow: 0 2px 8px var(--shadow-color);
    }

    .titleRow {
        padding: 10px 12px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .moduleTitle { font-size: 15px; }
    .professor { font-size: 12px; margin-top: 1px; }

    .rightControls {
        gap: 5px;
        margin-left: 6px;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }

    .toggleStatusBtn {
        padding: 6px 9px;
        font-size: 12px;
        border-radius: 7px;
        gap: 4px;
    }

    .toggleStatusBtn svg {
        width: 13px !important;
        height: 13px !important;
        margin-left: 0 !important;
    }

    /* Amaga colorPicker en mòbil */
    .colorPicker { display: none; }

    .iconBtn { width: 21px; height: 21px; }
    .accordionArrow { width: 20px; height: 20px; }

    /* ── RA ── */
    .raAccordion { padding: 9px 8px; font-size: 13px; }
    .raControls { gap: 5px; }
    .raControls .iconBtn { width: 16px; height: 16px; }

    /* ── TAULA TASQUES ── */
    .taskScrollContainer {
        max-height: 210px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Augmentar min-width i donar espai al camp "Nom" */
    .taskTable { min-width: 520px; }
    .taskTable th:nth-child(2),
    .taskTable td:nth-child(2) {
        min-width: 160px;
        max-width: 200px;
    }
    /* Columna data: mida fixa */
    .taskTable th:nth-child(3),
    .taskTable td:nth-child(3) { min-width: 110px; }

    .taskTable th,
    .taskTable td { padding: 6px 8px; font-size: 12px; }

    .taskTable td input[type="text"],
    .taskTable td input[type="date"] { font-size: 12px; padding: 4px 5px; }

    /* ── MODALS: bottom sheet en mòbil ── */
    .modal-overlay { align-items: flex-end; }

    .modal {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        padding: 24px 18px 36px !important;
        margin: 0 !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    /* El modal premium és especial — no el fem bottom sheet */
    .premium-gate-modal {
        border-radius: 18px !important;
        max-width: 340px !important;
        margin: auto !important;
        max-height: unset;
    }

    .modal-overlay:has(.premium-gate-modal) {
        align-items: center;
    }

    .modal div.modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
        margin-top: 18px;
    }

    .modal button {
        width: 100%;
        padding: 14px;
        font-size: 15px;
        border-radius: 10px;
    }

    /* Botons del premium gate no han d'heretar width:100% */
    .pg-btn-close,
    .pg-btn-upgrade {
        width: auto !important;
        padding: 11px 16px !important;
        font-size: 13.5px !important;
    }

    #pendingTasksModal .modal { border-radius: 20px 20px 0 0 !important; }
    #pendingTasksContent ul { max-height: 260px; }

    #pendingTasksContent li {
        padding: 10px 12px;
        margin-bottom: 8px;
        flex-wrap: wrap;
        gap: 4px;
    }

    #pendingTasksContent .task-info { font-size: 15px; }
    #pendingTasksContent .task-date-status { min-width: unset; font-size: 12px; }

    /* ── PANELLS LATERALS: full screen en mòbil ── */
    .side-panel,
    .gmail-panel {
        width: 100vw !important;
        right: -100vw !important;
        border-radius: 0;
        max-width: 100%;
    }

    .side-panel.open,
    .gmail-panel.open {
        right: 0 !important;
    }

    /* ── TOAST ── */
    #toastNotification {
        width: calc(100% - 28px);
        text-align: center;
        font-size: 13.5px;
    }

    /* ── FOOTER ── */
    .footer {
        border-radius: 0;
        margin: 0;
        padding: 14px 16px;
        font-size: 12px;
    }

    /* ── FIX: Panel del mòdul — no retallar els RA ── */
    /* Quan el mòdul és expandit, permet l'alçada necessària i scroll */
    .accordion[aria-expanded="true"] ~ .panel {
        max-height: 85vh !important;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 12px !important; /* Menys padding per donar més amplada als RA */
    }

    /* Garantir que el row de cada RA no es retalli mai per la dreta */
    .raAccordion {
        box-sizing: border-box;
        width: 100%;
    }
    .raControls {
        flex-shrink: 0;
        min-width: 0;
    }
    .raArrow {
        flex-shrink: 0;
        min-width: 16px;
    }

    /* ── FIX: Login centrat i que no se surti de pantalla ── */
    .auth-wrapper {
        padding: 16px;
        align-items: center;
    }
    .auth-card {
        padding: 26px 28px;
        border-radius: 18px;
        max-width: 340px;
        width: 90%;
    }
    .auth-title { font-size: 19px; }
    .auth-sub { font-size: 13px; }
}

@media (max-width: 480px) {
    /* Una sola columna per als controls secundaris */
    #topControls {
        grid-template-columns: 1fr;
        padding: 8px 10px;
        gap: 7px;
    }

    #addModuleBtn { grid-column: 1; }
    .add-task-dropdown-wrapper { grid-column: 1; }

    /* Botons secundaris: fila de 3 */
    #exportDataBtn,
    #importDataBtn,
    #showPendingTasksBtn {
        grid-column: unset;
        flex: 1;
        font-size: 12px;
    }

    .moduleTitle { font-size: 14px; }
    .rightControls { gap: 4px; }

    .toggleStatusBtn {
        padding: 5px 7px;
        font-size: 11px;
    }

    .iconBtn { width: 19px; height: 19px; }

    /* Login en pantalla molt petita */
    .auth-card {
        padding: 22px 20px;
        border-radius: 14px;
        max-width: 300px;
        width: 88%;
    }
    .auth-form-actions {
        flex-direction: column;
    }
    .auth-form-actions .auth-email-btn {
        width: 100%;
    }
}

/* ================================================================
   BADGE DE LA CAMPANA TOP-RIGHT
   ================================================================ */
.tr-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    background: #ea4335;
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 8px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--bg-container);
    animation: badgePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ================================================================
   MENÚ HAMBURGUESA DESPLEGABLE
   ================================================================ */
#hamburgerWrapper { position: relative; }

.hamburger-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 188px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.16);
    /* Animació d'entrada */
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: top right;
    z-index: 1200;
}
.hamburger-menu.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.hm-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 5px 10px 3px;
    margin: 0;
}

.hm-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    background: none;
    color: var(--text-main);
    font-size: 13.5px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-align: left;
}
.hm-item svg { color: var(--text-muted); flex-shrink: 0; transition: color 0.15s; }
.hm-item:hover { background: var(--bg-ra-hover); color: var(--primary-color); }
.hm-item:hover svg { color: var(--primary-color); }

/* ================================================================
   OVERLAY PANELLS LATERALS
   ================================================================ */
.side-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 1500;
    pointer-events: none;
    transition: background 0.35s ease;
}
.side-overlay.visible {
    background: rgba(0,0,0,0.35);
    pointer-events: all;
}

/* ================================================================
   PANELLS LATERALS GENÈRICS (Suport + Configuració)
   ================================================================ */
.side-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 380px;
    max-width: 95vw;
    height: 100vh;
    background: var(--bg-container);
    border-left: 1px solid var(--border-color);
    box-shadow: -8px 0 32px rgba(0,0,0,0.18);
    z-index: 1600;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    will-change: transform;
    contain: layout style;
    backface-visibility: hidden;
}
.side-panel.open { right: 0; }

.sp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-panel);
    flex-shrink: 0;
}
.sp-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
}
.sp-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 5px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    transition: color 0.2s, background 0.2s;
}
.sp-close:hover { color: var(--text-main); background: var(--bg-ra-hover); }

.sp-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 18px 28px;
}
.sp-body::-webkit-scrollbar { width: 5px; }
.sp-body::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }

/* --- Panell Suport --- */
.sp-intro {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 18px;
    line-height: 1.55;
}
.sp-cards { display: flex; flex-direction: column; gap: 10px; }
.sp-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 15px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 11px;
    transition: transform 0.2s, box-shadow 0.2s;
}
.sp-card:hover { transform: translateY(-2px); box-shadow: 0 4px 14px var(--shadow-color); }
.sp-card-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sp-card-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.sp-card-title { font-size: 14px; font-weight: 600; color: var(--text-main); }
.sp-card-sub { font-size: 12px; color: var(--text-muted); }
.sp-soon-badge {
    font-size: 10px; font-weight: 700;
    color: var(--warning-color);
    background: rgba(243,156,18,0.12);
    padding: 2px 8px; border-radius: 8px;
    white-space: nowrap;
}

/* --- Panell Configuració --- */
.sp-section-label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 20px 0 8px 2px;
}
.sp-section-label:first-child { margin-top: 0; }

.sp-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    margin-bottom: 8px;
}
.sp-row-info { flex: 1; min-width: 0; }
.sp-row-title { display: block; font-size: 13.5px; font-weight: 600; color: var(--text-main); }
.sp-row-sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sp-action-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 12px;
    background: var(--bg-container);
    border: 1.5px solid var(--border-color);
    border-radius: 7px;
    font-size: 12px; font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.sp-action-btn:hover { border-color: var(--primary-color); color: var(--primary-color); background: rgba(0,123,255,0.05); }
.sp-danger-btn { color: var(--danger-color); border-color: rgba(220,53,69,0.4); }
.sp-danger-btn:hover { background: rgba(220,53,69,0.07); border-color: var(--danger-color); color: var(--danger-color); }
.sp-version {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 26px;
    font-style: italic;
}

/* ================================================================
   TASQUES VENCUDES en el panell Gmail
   ================================================================ */

/* Separadors de secció dins la llista */
.gmail-section-sep {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 10px 4px 6px;
    margin-top: 2px;
}
.gmail-section-sep.expired-sep {
    color: #c2750a;
    padding-top: 14px;
    margin-top: 8px;
    border-top: 1px dashed var(--border-color);
}
[data-theme="dark"] .gmail-section-sep.expired-sep { color: #f59e0b; }

/* Card vencuda: fons ambre suau */
.gmail-task-card.gmail-task-expired {
    border-left-color: #d97706;
    background: rgba(217,119,6,0.035);
    opacity: 0.88;
}
[data-theme="dark"] .gmail-task-card.gmail-task-expired {
    background: rgba(217,119,6,0.1);
}
.gmail-task-card.gmail-task-expired:hover { opacity: 1; }

/* Data vencuda: badge ambre */
.gmail-task-date.date-expired {
    color: #b45309;
    background: rgba(217,119,6,0.1);
}
[data-theme="dark"] .gmail-task-date.date-expired {
    color: #fbbf24;
    background: rgba(245,158,11,0.15);
}

/* Botó Moodle per vencudes: menys vibrant */
.gmail-task-link-btn.link-expired {
    background: rgba(217,119,6,0.07);
    color: #b45309;
    border-color: rgba(217,119,6,0.25);
}
.gmail-task-link-btn.link-expired:hover { background: rgba(217,119,6,0.14); }

/* ================================================================
   RESPONSIVE
   ================================================================ */
/* (side-panel i top-right mòbil coberts per @media max-width:768px) */

/* Email clicable al panell Suport */
.sp-card-email {
    display: block;
    font-size: 12px;
    color: var(--success-color);
    text-decoration: none;
    font-weight: 500;
    margin-top: 2px;
    transition: opacity 0.2s;
    word-break: break-all;
}
.sp-card-email:hover { opacity: 0.75; text-decoration: underline; }

/* ================================================================
   MODAL OCR MOODLE
   ================================================================ */

/* Estilos específicos para el modal de OCR - con scroll */
#ocrModal .modal {
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
}

/* Scrollbar personalizado para el modal */
#ocrModal .modal::-webkit-scrollbar {
    width: 8px;
}

#ocrModal .modal::-webkit-scrollbar-track {
    background: var(--bg-panel);
    border-radius: 10px;
}

#ocrModal .modal::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

#ocrModal .modal::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.ocr-instructions {
    margin-bottom: 20px;
}

.ocr-info-box {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: rgba(0, 123, 255, 0.05);
    border: 1px solid rgba(0, 123, 255, 0.15);
    border-radius: 10px;
    color: var(--text-secondary);
}

.ocr-info-box svg {
    flex-shrink: 0;
    color: var(--primary-color);
    margin-top: 2px;
}

.ocr-info-box strong {
    color: var(--text-main);
    font-size: 14px;
    display: block;
    margin-bottom: 6px;
}

.ocr-info-box p {
    margin: 0 0 8px 0;
    font-size: 13px;
    line-height: 1.5;
}

.ocr-info-box ul {
    margin: 0;
    padding-left: 18px;
    font-size: 12.5px;
    line-height: 1.6;
}

.ocr-info-box li {
    margin-bottom: 4px;
}

[data-theme="dark"] .ocr-info-box {
    background: rgba(0, 123, 255, 0.08);
    border-color: rgba(0, 123, 255, 0.25);
}

/* Zona de subida de archivos */
.ocr-upload-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 30px;
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    background: var(--bg-panel);
    cursor: pointer;
    transition: all 0.3s;
}

.ocr-upload-zone:hover {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.03);
}

.ocr-upload-zone svg {
    color: var(--text-muted);
    margin-bottom: 12px;
}

.ocr-upload-zone p {
    margin: 0;
    color: var(--text-main);
}

.ocr-upload-hint {
    font-size: 13px !important;
    color: var(--text-muted) !important;
    margin-top: 4px !important;
}

.ocr-upload-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(0, 123, 255, 0.08);
}

/* Barra de progreso */
.ocr-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin: 20px 0 10px;
}

.ocr-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #4a90e2);
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progressPulse 1.5s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Mensajes de éxito RA */
#ocrRaMatch p, #ocrRaNew p {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Responsive OCR Modal */
@media (max-width: 600px) {
    #ocrModal .modal {
        max-width: 95vw;
        max-height: 85vh;
        padding: 20px;
    }
    
    .ocr-info-box {
        flex-direction: column;
    }
    
    .ocr-upload-zone {
        padding: 35px 20px;
    }
}


/* =====================================================
   ANIMACIONS D'ICONES ALS BOTONS (hover)
   ===================================================== */

/* --- KEYFRAMES --- */

/* Campana que sona */
@keyframes bellRing {
    0%   { transform: rotate(0deg); }
    10%  { transform: rotate(18deg); }
    20%  { transform: rotate(-16deg); }
    30%  { transform: rotate(13deg); }
    40%  { transform: rotate(-10deg); }
    50%  { transform: rotate(7deg); }
    60%  { transform: rotate(-4deg); }
    70%  { transform: rotate(2deg); }
    100% { transform: rotate(0deg); }
}

/* Fletxa que surt cap a la dreta (logout) */
@keyframes arrowRight {
    0%   { transform: translateX(0); }
    40%  { transform: translateX(5px); }
    60%  { transform: translateX(3px); }
    80%  { transform: translateX(5px); }
    100% { transform: translateX(5px); }
}

/* Llamp que vibra (tasca ràpida) */
@keyframes boltZap {
    0%   { transform: scale(1) rotate(0deg); }
    20%  { transform: scale(1.2) rotate(-8deg); }
    40%  { transform: scale(0.95) rotate(6deg); }
    60%  { transform: scale(1.15) rotate(-4deg); }
    80%  { transform: scale(1) rotate(2deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* Rellotge que gira (tasques pendents) */
@keyframes clockSpin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Fletxa de baixada que rebota (exportar) */
@keyframes bounceDown {
    0%   { transform: translateY(0); }
    40%  { transform: translateY(5px); }
    65%  { transform: translateY(2px); }
    85%  { transform: translateY(5px); }
    100% { transform: translateY(5px); }
}

/* Fletxa de pujada que rebota (importar) */
@keyframes bounceUp {
    0%   { transform: translateY(0); }
    40%  { transform: translateY(-5px); }
    65%  { transform: translateY(-2px); }
    85%  { transform: translateY(-5px); }
    100% { transform: translateY(-5px); }
}

/* Lluna que rota (tema) */
@keyframes moonSpin {
    from { transform: rotate(0deg) scale(1); }
    to   { transform: rotate(-30deg) scale(1.15); }
}

/* Menú hamburguesa que puja i baixa lleugerament */
@keyframes menuBounce {
    0%   { transform: scaleY(1); }
    30%  { transform: scaleY(0.7); }
    60%  { transform: scaleY(1.15); }
    80%  { transform: scaleY(0.95); }
    100% { transform: scaleY(1); }
}

/* Càmera/OCR que fa flash (pulse) */
@keyframes cameraFlash {
    0%   { transform: scale(1); opacity: 1; }
    25%  { transform: scale(1.2); opacity: 0.7; }
    50%  { transform: scale(1); opacity: 1; }
    75%  { transform: scale(1.1); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
}

/* Suma que gira (afegir mòdul) */
@keyframes plusRotate {
    from { transform: rotate(0deg) scale(1); }
    to   { transform: rotate(90deg) scale(1.2); }
}


/* --- APLICACIÓ ALS BOTONS --- */

/* Campana de notificacions */
#notifBellBtn:hover svg {
    animation: bellRing 0.7s ease forwards;
    transform-origin: top center;
}

/* Botó OCR (càmera) */
#ocrBtn:hover svg {
    animation: cameraFlash 0.5s ease forwards;
}

/* Tema (lluna) */
#themeToggleBtn:hover svg {
    animation: moonSpin 0.35s ease forwards;
    transform-origin: center;
}

/* Menú hamburguesa */
#hamburgerBtn:hover svg {
    animation: menuBounce 0.4s ease forwards;
    transform-origin: center;
}

/* Cerrar sesión — icona de fletxa cap a la dreta */
#logoutBtn:hover .btnIconWrapper svg {
    animation: arrowRight 0.5s ease forwards;
}

/* Afegir mòdul — creu/+ que rota */
#addModuleBtn:hover .btnIconWrapper svg {
    animation: plusRotate 0.3s ease forwards;
    transform-origin: center;
}

/* Tasca Ràpida — llamp que zap */
#fastTaskBtn:hover .btnIconWrapper svg {
    animation: boltZap 0.5s ease forwards;
    transform-origin: center;
}

/* Tasques Pendents — rellotge que gira */
#showPendingTasksBtn:hover .btnIconWrapper svg {
    animation: clockSpin 0.6s linear forwards;
    transform-origin: center;
}

/* Exportar JSON — fletxa cap avall que rebota */
#exportDataBtn:hover .btnIconWrapper svg {
    animation: bounceDown 0.5s ease forwards;
}

/* Importar JSON — fletxa cap amunt que rebota */
#importDataBtn:hover .btnIconWrapper svg {
    animation: bounceUp 0.5s ease forwards;
}


/* =====================================================
   TIPOGRAFIA INTER — RAs i Tasques
   ===================================================== */

.raAccordion .raName {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.2px;
}

.raBadge {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
}

.taskTable th {
    font-family: 'Inter', sans-serif;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.6px;
}

.taskTable td,
.taskTable td input[type="text"],
.taskTable td input[type="date"] {
    font-family: 'Inter', sans-serif;
    font-size: 13.5px;
}

.taskTable td:first-child {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 500;
}

.addTaskBtn {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

/* =====================================================
   FIX: Input date — mode fosc visible + posició correcta
   ===================================================== */

/* Color del text i icona del calendari en tots els inputs date */
input[type="date"] {
    color-scheme: light;
}

[data-theme="dark"] input[type="date"] {
    color-scheme: dark;
    color: var(--text-main);
    background-color: var(--bg-container);
    border-color: var(--border-color);
}

/* Evitar que el popover del calendari surti fora de la finestra */
input[type="date"] {
    position: relative;
}

/* Fix específic per la taula de tasques */
[data-theme="dark"] .taskTable td input[type="date"] {
    color-scheme: dark;
    color: var(--text-main);
    background-color: var(--bg-container);
}

/* Fix per la tasca ràpida (opcionals) */
[data-theme="dark"] #fastTaskDate {
    color-scheme: dark;
    color: var(--text-main);
    background-color: var(--bg-container);
    border-color: var(--border-color);
}

/* Contenidor de la data a la taula — overflow visible per al popover */
.taskTable td:nth-child(3) {
    position: relative;
    overflow: visible;
}

.taskScrollContainer {
    overflow-x: visible;
    overflow-y: auto;
}


/* ================================================================
   AUTH PAGE - IMPROVED DESIGN
   ================================================================ */
.auth-wrapper {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e8f4fd 0%, #f0e8ff 50%, #e8fdf4 100%);
    padding: 20px;
    overflow-y: auto;
    box-sizing: border-box;
}

.auth-bg-shapes {
    position: absolute; inset: 0; pointer-events: none; overflow: hidden;
}
.auth-shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.12;
    animation: authFloat 8s ease-in-out infinite;
}
.auth-shape-1 { width: 400px; height: 400px; background: #007bff; top: -100px; left: -100px; animation-delay: 0s; }
.auth-shape-2 { width: 300px; height: 300px; background: #6f42c1; bottom: -80px; right: -80px; animation-delay: 3s; }
.auth-shape-3 { width: 200px; height: 200px; background: #28a745; top: 50%; right: 10%; animation-delay: 5s; }
@keyframes authFloat { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-20px) scale(1.05); } }

.auth-card {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.8);
    border-radius: 24px;
    padding: 30px 44px;
    width: 100%;
    max-width: 460px;
    box-sizing: border-box;
    box-shadow: 0 20px 60px rgba(0,0,0,0.12), 0 4px 20px rgba(0,0,0,0.06);
    position: relative;
    z-index: 1;
}

[data-theme="dark"] .auth-wrapper {
    background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #0d1117 100%);
}
[data-theme="dark"] .auth-card {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(255,255,255,0.08);
}

.auth-logo {
    display: flex; align-items: center; gap: 10px; margin-bottom: 24px;
}
.auth-logo-img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    display: block;
    flex-shrink: 0;
}
.auth-logo-text {
    font-family: 'Playfair Display', serif;
    font-size: 22px; font-weight: 700;
    color: var(--primary-color);
}

.auth-title {
    font-size: 22px; font-weight: 700;
    color: var(--text-main); margin: 0 0 6px 0;
}
.auth-sub {
    font-size: 14px; color: var(--text-muted); margin: 0 0 24px 0;
}

.google-login-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 13px 20px;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-container);
    color: var(--text-main);
    font-size: 14.5px; font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px var(--shadow-color);
}
.google-login-btn:hover {
    background: #ffffff;
    border-color: #4285f4;
    box-shadow: 0 4px 16px rgba(66,133,244,0.22);
    transform: translateY(-1px);
    color: #202124;
}
.google-login-btn:active { transform: translateY(0); }

.auth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 20px 0; color: var(--text-muted); font-size: 13px;
}
.auth-divider::before, .auth-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

.auth-input-wrapper {
    display: flex; align-items: center; gap: 8px;
    border: 1.5px solid var(--border-color);
    border-radius: 10px; padding: 10px 12px;
    background: var(--bg-panel);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.auth-input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}
.auth-input-wrapper svg { flex-shrink: 0; color: var(--text-muted); }
.auth-input-wrapper input {
    flex: 1; border: none; background: transparent;
    font-size: 14px; color: var(--text-main); outline: none;
}
.auth-eye-btn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 0; display: flex;
    transition: color 0.2s;
}
.auth-eye-btn:hover { color: var(--text-main); }

.auth-form-actions { display: flex; gap: 10px; margin-top: 4px; }
.auth-email-btn {
    flex: 1; padding: 12px;
    border-radius: 10px; border: none;
    background: var(--primary-color); color: white;
    font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(0,123,255,0.25);
}
.auth-email-btn:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,123,255,0.3); }
.auth-register-btn { background: var(--bg-panel); color: var(--text-secondary); border: 1.5px solid var(--border-color); box-shadow: none; }
.auth-register-btn:hover { background: var(--bg-body); border-color: var(--primary-color); color: var(--primary-color); box-shadow: none; }

.auth-msg {
    margin-top: 14px; font-size: 13px; text-align: center;
    min-height: 18px; color: var(--danger-color);
}

.auth-privacy-link {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.auth-privacy-sep {
    color: var(--border-color);
    font-size: 14px;
}

.auth-privacy-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.auth-privacy-link a:hover {
    opacity: 0.75;
    text-decoration: underline;
}

/* ================================================================
   GLOBAL SEARCH BAR
   ================================================================ */
#globalSearchBar {
    max-width: 500px;
    margin: 0 auto 16px;
    padding: 0 20px;
    position: relative;
    z-index: 200;
}
.global-search-wrapper {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-container);
    border: 1.5px solid var(--border-color);
    border-radius: 50px;
    padding: 10px 16px;
    box-shadow: 0 2px 12px var(--shadow-color);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.global-search-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(0,123,255,0.15);
}
.search-icon-svg { flex-shrink: 0; color: var(--text-muted); }
#globalSearchInput {
    flex: 1; border: none; background: transparent;
    font-size: 14px; color: var(--text-main); outline: none;
}
#globalSearchInput::placeholder { color: var(--text-muted); }
#clearSearchBtn {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 2px; display: flex;
    align-items: center; transition: color 0.2s;
}
#clearSearchBtn:hover { color: var(--text-main); }
.search-results {
    position: absolute; top: calc(100% + 6px); left: 20px; right: 20px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    box-shadow: 0 8px 30px var(--shadow-color);
    overflow: hidden; z-index: 300;
}
.search-result-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-panel); }
.search-result-icon { font-size: 16px; flex-shrink: 0; }
.search-result-label { display: block; font-size: 13.5px; font-weight: 500; color: var(--text-main); }
.search-result-sub { display: block; font-size: 11.5px; color: var(--text-muted); }
.search-no-results { padding: 16px; text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 0; }

/* ================================================================
   ADD TASK DROPDOWN BUTTON
   ================================================================ */
.add-task-dropdown-wrapper { position: relative; }

/* El contenidor és el "botó" visual unificat */
.add-task-split-btn {
    display: flex;
    align-items: stretch;
    height: 45px;
    border: 2px solid #6f42c1;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.18s, transform 0.18s, background 0.18s;
    background: var(--bg-container);
    cursor: pointer;
}
.add-task-split-btn:hover {
    box-shadow: 0 6px 14px rgba(111,66,193,0.22);
    transform: translateY(-2px);
    background: #f3ebff;
}
[data-theme="dark"] .add-task-split-btn {
    border-color: #a78bfa;
}
[data-theme="dark"] .add-task-split-btn:hover {
    background: #2e2a36;
    box-shadow: 0 6px 14px rgba(167,139,250,0.25);
}

/* El botó principal — sense estils propis, hereda del pare */
.add-task-main-btn {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    height: 100% !important;
    background: transparent !important;
    padding: 10px 14px !important;
    color: var(--text-main) !important;
    flex: 1;
}
.add-task-main-btn:hover {
    box-shadow: none !important;
    transform: none !important;
    background: transparent !important;
}

/* Divisor vertical + fletxa */
.add-task-arrow-btn {
    border: none !important;
    border-left: 1.5px solid rgba(111,66,193,0.35) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    height: 100% !important;
    min-width: 34px !important;
    max-width: 34px !important;
    padding: 0 !important;
    background: transparent !important;
    color: #6f42c1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.add-task-arrow-btn:hover {
    box-shadow: none !important;
    transform: none !important;
    background: transparent !important;
}
[data-theme="dark"] .add-task-arrow-btn {
    border-left-color: rgba(167,139,250,0.35) !important;
    color: #a78bfa !important;
}

/* L'animació de l'icona es fa quan el pare (.split-btn) té hover */
.add-task-split-btn:hover .add-task-main-btn .btnIconWrapper svg {
    animation: boltZap 0.45s ease forwards;
}

.add-task-dropdown-menu {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 200px;
    background: var(--bg-container);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-color);
    overflow: hidden; z-index: 500;
    opacity: 0; transform: translateY(-8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.18s, transform 0.18s;
}
.add-task-dropdown-menu.open {
    opacity: 1; transform: translateY(0) scale(1); pointer-events: all;
}
.add-task-option {
    display: flex; align-items: center; gap: 10px;
    width: 100%; padding: 11px 16px;
    border: none; background: transparent;
    font-size: 13.5px; color: var(--text-main);
    cursor: pointer; text-align: left;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.add-task-option:last-child { border-bottom: none; }
.add-task-option:hover { background: var(--bg-panel); color: #6f42c1; }
.add-task-option svg { flex-shrink: 0; }

/* ================================================================
   NOTES BUTTON IN TASK ROW
   ================================================================ */
.notes-btn {
    opacity: 0.4;
    transition: opacity 0.2s, color 0.2s;
}
.notes-btn:hover, .notes-btn.has-notes { opacity: 1; }
.notes-btn.has-notes { color: #6f42c1 !important; }
.notes-task-name {
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    margin: -10px 0 14px 0;
    padding: 8px 12px;
    background: var(--bg-panel);
    border-radius: 8px;
}
.notes-textarea {
    width: 100%; box-sizing: border-box;
    padding: 12px; border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-panel); color: var(--text-main);
    font-size: 14px; font-family: inherit;
    resize: vertical; min-height: 140px;
    transition: border-color 0.2s;
    margin-top: 6px; margin-bottom: 16px;
}
.notes-textarea:focus { border-color: var(--primary-color); outline: none; box-shadow: 0 0 0 3px rgba(0,123,255,0.1); }

/* ================================================================
   HISTORIAL
   ================================================================ */
.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px 0; margin: 0; }
.history-item {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 10px 12px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 10px;
}
.history-item-icon {
    width: 26px; height: 26px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; margin-top: 1px;
}
.history-icon-add { background: rgba(40,167,69,0.12); color: var(--success-color); }
.history-icon-delete { background: rgba(220,53,69,0.1); color: var(--danger-color); }
.history-icon-edit { background: rgba(0,123,255,0.1); color: var(--primary-color); }
.history-icon-done { background: rgba(111,66,193,0.1); color: #6f42c1; }
.history-item-body { flex: 1; min-width: 0; }
.history-item-desc { display: block; font-size: 13px; color: var(--text-main); font-weight: 500; }
.history-item-time { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.hm-badge {
    margin-left: auto; background: var(--primary-color); color: white;
    font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px;
}

/* ================================================================
   CALENDARI PANEL
   ================================================================ */
.calendar-body { padding: 16px; overflow-y: auto; }
.calendar-nav {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.cal-month-label { font-weight: 700; font-size: 15px; color: var(--text-main); }
.cal-nav-btn {
    background: var(--bg-panel); border: 1px solid var(--border-color);
    border-radius: 8px; width: 32px; height: 32px;
    font-size: 20px; cursor: pointer; color: var(--text-secondary);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.cal-nav-btn:hover { background: var(--bg-ra-hover); color: var(--text-main); }
.cal-weekdays {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 2px; margin-bottom: 4px;
}
.cal-weekdays span {
    text-align: center; font-size: 11px; font-weight: 700;
    color: var(--text-muted); padding: 4px 0;
}
.cal-days {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px;
}
.cal-day {
    aspect-ratio: 1; border-radius: 8px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
    transition: background 0.15s;
    font-size: 13px;
}
.cal-day:hover { background: var(--bg-ra-hover); }
.cal-day-empty { cursor: default; }
.cal-day-num { font-size: 13px; font-weight: 500; color: var(--text-main); line-height: 1; }
.cal-today { background: rgba(0,123,255,0.1) !important; }
.cal-today .cal-day-num { color: var(--primary-color); font-weight: 700; }
.cal-has-tasks { background: rgba(220,53,69,0.06); }
.cal-all-done { background: rgba(40,167,69,0.06); }
.cal-dot {
    width: 5px; height: 5px; border-radius: 50%; margin-top: 2px;
}
.cal-dot-pending { background: var(--danger-color); }
.cal-dot-done { background: var(--success-color); }
.cal-day-tasks {
    margin-top: 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 12px; overflow: hidden;
}
.cal-day-tasks-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px;
    font-weight: 700; font-size: 13px; color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
}
.cal-task-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}
.cal-task-item:last-child { border-bottom: none; }
.cal-task-item:hover { background: var(--bg-ra-hover); }
.cal-task-done { opacity: 0.55; }
.cal-task-status { font-size: 14px; flex-shrink: 0; color: var(--text-muted); }
.cal-task-name { display: block; font-size: 13px; font-weight: 500; color: var(--text-main); }
.cal-task-meta { display: block; font-size: 11px; color: var(--text-muted); }

/* ================================================================
   HISTORY UNDO/REDO
   ================================================================ */
.history-undo-row {
    display: flex; gap: 6px; align-items: center;
    margin-bottom: 12px;
}
.history-undo-btn {
    display: flex; align-items: center; gap: 5px;
    padding: 6px 12px; border-radius: 8px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-panel); color: var(--text-secondary);
    font-size: 12.5px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.history-undo-btn:hover:not(:disabled) {
    border-color: var(--primary-color); color: var(--primary-color);
    background: rgba(0,123,255,0.06);
}
.history-undo-btn:disabled {
    opacity: 0.38; cursor: not-allowed;
}

/* ================================================================
   NOTES IN PENDING TASKS LIST
   ================================================================ */
.pending-task-note {
    font-size: 11.5px; color: var(--text-muted);
    margin-top: 4px; font-style: italic;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 280px;
}

/* ================================================================
   NOTES IN CALENDAR TASK ITEMS
   ================================================================ */
.cal-task-note {
    display: block; font-size: 11px; color: var(--text-muted);
    font-style: italic; margin-top: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 240px;
}

/* ================================================================
   CALENDAR VIEW MODE TABS
   ================================================================ */
.cal-view-tabs {
    display: flex; gap: 4px; margin-bottom: 14px;
    background: var(--bg-panel);
    border-radius: 10px; padding: 4px;
}
.cal-view-tab {
    flex: 1; padding: 7px 6px; border-radius: 7px;
    border: none; background: transparent;
    font-size: 12px; font-weight: 600;
    color: var(--text-muted); cursor: pointer;
    transition: all 0.18s;
}
.cal-view-tab.active {
    background: var(--bg-container);
    color: var(--primary-color);
    box-shadow: 0 2px 8px var(--shadow-color);
}
.cal-view-tab:hover:not(.active) {
    color: var(--text-main);
}

/* Week view */
.cal-week-grid {
    display: flex; flex-direction: column; gap: 4px;
}
.cal-week-day-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 10px; border-radius: 10px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    cursor: default;
    transition: background 0.15s;
}
.cal-week-day-row.cal-week-today {
    border-color: var(--primary-color);
    background: rgba(0,123,255,0.04);
}
.cal-week-day-label {
    min-width: 40px; text-align: center;
}
.cal-week-day-name {
    display: block; font-size: 10px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase;
}
.cal-week-day-num {
    display: block; font-size: 18px; font-weight: 700;
    color: var(--text-main); line-height: 1;
}
.cal-week-today .cal-week-day-num { color: var(--primary-color); }
.cal-week-tasks {
    flex: 1; display: flex; flex-direction: column; gap: 3px;
}
.cal-week-task-chip {
    display: flex; align-items: center; gap: 6px;
    padding: 4px 8px; border-radius: 6px;
    font-size: 12px; background: var(--bg-container);
    border: 1px solid var(--border-color);
    cursor: pointer; transition: background 0.15s;
}
.cal-week-task-chip:hover { background: var(--bg-ra-hover); }
.cal-week-task-chip.done { opacity: 0.5; }
.cal-week-empty {
    font-size: 12px; color: var(--text-muted);
    font-style: italic; padding: 4px 0;
}
.cal-week-task-dot {
    width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
}
.cal-week-task-dot.pending { background: var(--danger-color); }
.cal-week-task-dot.done { background: var(--success-color); }

/* Day view */
.cal-day-view {
    display: flex; flex-direction: column; gap: 6px;
}
.cal-day-view-header {
    text-align: center; padding: 10px;
    font-size: 15px; font-weight: 700; color: var(--text-main);
}
.cal-day-view-empty {
    text-align: center; color: var(--text-muted); font-size: 13px;
    padding: 20px 0; font-style: italic;
}

/* ── Premium Gate: botó bloquejat al dropdown ─────────────── */
.add-task-option--locked {
    opacity: 0.6;
    cursor: not-allowed;
    justify-content: space-between;
}
.add-task-option--locked:hover {
    background: transparent;
    color: inherit;
}
.locked-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #b8860b;
    background: rgba(255, 200, 0, 0.15);
    border: 1px solid rgba(255, 200, 0, 0.4);
    border-radius: 20px;
    padding: 2px 7px;
    margin-left: auto;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

/* ── Premium Gate: modal ──────────────────────────────────── */
.premium-gate-modal {
    max-width: 360px;
    text-align: center;
    padding: 0 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    overflow: hidden;
    border-radius: 18px !important;
}

/* Capçalera daurada */
.pg-header {
    width: 100%;
    background: linear-gradient(145deg, #1a1a2e 0%, #16213e 40%, #0f3460 100%);
    padding: 30px 0 26px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-bottom: 20px;
    overflow: hidden;
}

.pg-glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% -10%, rgba(139,92,246,0.35) 0%, transparent 65%),
                radial-gradient(ellipse at 80% 100%, rgba(59,130,246,0.2) 0%, transparent 50%);
    pointer-events: none;
}

/* Partícules decoratives */
.pg-particles { position: absolute; inset: 0; pointer-events: none; }
.pg-p {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
}
.pg-p1 { width: 6px; height: 6px; top: 18%; left: 12%; animation: pg-float 3.2s ease-in-out infinite; }
.pg-p2 { width: 4px; height: 4px; top: 55%; left: 22%; animation: pg-float 2.8s ease-in-out infinite 0.6s; }
.pg-p3 { width: 5px; height: 5px; top: 25%; right: 15%; animation: pg-float 3.5s ease-in-out infinite 1.2s; }
.pg-p4 { width: 3px; height: 3px; top: 65%; right: 25%; animation: pg-float 2.5s ease-in-out infinite 0.3s; }
@keyframes pg-float {
    0%, 100% { transform: translateY(0) scale(1); opacity: 0.15; }
    50% { transform: translateY(-8px) scale(1.2); opacity: 0.4; }
}

.pg-crown {
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 4px 16px rgba(139,92,246,0.5));
    margin-bottom: 10px;
}

.pg-header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    position: relative;
    z-index: 2;
}
.pg-header-label {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,0.65);
    letter-spacing: 2px;
    text-transform: uppercase;
}
.pg-header-badge {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 3px;
    padding: 3px 12px;
    border-radius: 20px;
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    color: #fff;
    box-shadow: 0 2px 12px rgba(139,92,246,0.5);
}

/* Títol i subtítol */
.pg-title-area {
    padding: 0 24px;
    margin-bottom: 16px;
}
.pg-title {
    font-size: 19px;
    font-weight: 800;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}
.pg-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0;
}

/* Beneficis */
.pg-benefits {
    list-style: none;
    padding: 0 24px;
    margin: 0 0 18px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 9px;
    text-align: left;
}
.pg-benefits li {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.pg-check {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(139,92,246,0.15) 0%, rgba(59,130,246,0.15) 100%);
    color: #8b5cf6;
    font-size: 10px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
    border: 1px solid rgba(139,92,246,0.25);
}

/* Preu destacat */
.pg-price-box {
    width: calc(100% - 48px);
    background: linear-gradient(135deg, rgba(139,92,246,0.08) 0%, rgba(59,130,246,0.08) 100%);
    border: 1.5px solid rgba(139,92,246,0.2);
    border-radius: 14px;
    padding: 12px 20px;
    margin-bottom: 14px;
}
.pg-price-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}
.pg-price-num {
    font-size: 36px;
    font-weight: 900;
    background: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    letter-spacing: -0.03em;
}
.pg-price-right {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.pg-price-period {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 600;
}
.pg-price-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 400;
}

/* Missatge original */
.premium-gate-msg {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
    margin: 0 24px 18px;
    font-style: italic;
}

/* Botons d'acció */
.pg-actions {
    display: flex;
    gap: 10px;
    padding: 0 24px;
    width: 100%;
    box-sizing: border-box;
}
.pg-btn-close {
    flex: 1;
    padding: 11px 16px;
    border-radius: 10px;
    border: 1.5px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s;
}
.pg-btn-close:hover {
    background: var(--bg-ra-hover);
    color: var(--text-main);
}
.pg-btn-upgrade {
    flex: 2;
    padding: 11px 16px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 60%, #4f46e5 100%);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: all 0.18s;
    box-shadow: 0 3px 12px rgba(139,92,246,0.45);
    text-decoration: none;
}
.pg-btn-upgrade:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    box-shadow: 0 6px 20px rgba(139,92,246,0.55);
    transform: translateY(-1px);
}
.pg-btn-upgrade:active { transform: translateY(0); }
/* ===================================================
   HORARI PERSONAL — Stylesheet
   Integrat amb RaOrg. Segueix les CSS vars del tema.
   =================================================== */

/* ── Modal Overlay ── */
#horariModal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.28s ease;
}
#horariModal.visible { opacity: 1; }

/* ── Modal Container ── */
.horari-container {
    width: min(1200px, 97vw);
    height: min(880px, 95vh);
    background: var(--bg-container, #fff);
    border-radius: 20px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    box-shadow: 0 32px 80px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96) translateY(8px);
    transition: transform 0.28s cubic-bezier(0.22,1,0.36,1);
}
#horariModal.visible .horari-container {
    transform: scale(1) translateY(0);
}

/* ── Header ── */
.horari-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px 16px;
    border-bottom: 1.5px solid var(--border-color, #e8e8e8);
    flex-shrink: 0;
}
.horari-header-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main, #1a1a1a);
    letter-spacing: -0.3px;
}
.horari-header-title svg { color: var(--primary-color, #007bff); }

.horari-week-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}
.horari-week-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main, #333);
    min-width: 190px;
    text-align: center;
    letter-spacing: -0.2px;
}
.horari-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    background: var(--bg-container, #fff);
    color: var(--text-main, #333);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
}
.horari-nav-btn:hover {
    background: var(--primary-color, #007bff);
    color: #fff;
    border-color: var(--primary-color, #007bff);
    transform: scale(1.07);
}
.horari-today-btn {
    padding: 0 13px;
    height: 32px;
    border-radius: 8px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    background: var(--bg-container, #fff);
    color: var(--text-main, #333);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.18s ease;
}
.horari-today-btn:hover {
    background: var(--primary-color, #007bff);
    color: #fff;
    border-color: var(--primary-color, #007bff);
}

.horari-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 14px;
}
.horari-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 13px;
    height: 33px;
    border-radius: 9px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    background: var(--bg-container, #fff);
    color: var(--text-main, #444);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    transition: all 0.18s ease;
    white-space: nowrap;
}
.horari-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}
.horari-action-btn.primary {
    background: var(--primary-color, #007bff);
    color: #fff;
    border-color: var(--primary-color, #007bff);
}
.horari-action-btn.primary:hover { filter: brightness(1.08); }
.horari-action-btn.break-btn {
    border-color: #f59e0b;
    color: #f59e0b;
}
.horari-action-btn.break-btn:hover { background: #fffbeb; }
[data-theme="dark"] .horari-action-btn.break-btn:hover { background: #2d2200; }

.horari-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-muted, #888);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s ease;
    margin-left: 4px;
}
.horari-close-btn:hover {
    background: var(--danger-color, #dc3545);
    color: #fff;
    transform: scale(1.08);
}

/* ── Body ── */
.horari-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* ── Welcome Screen ── */
.horari-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 28px;
    padding: 40px;
    text-align: center;
}
.horari-welcome-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--primary-color, #007bff) 0%, #6f42c1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0,123,255,0.25);
}
.horari-welcome h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main, #1a1a1a);
    margin: 0;
    letter-spacing: -0.5px;
}
.horari-welcome p {
    font-size: 0.95rem;
    color: var(--text-muted, #666);
    max-width: 480px;
    line-height: 1.65;
    margin: 0;
}
.horari-welcome-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    max-width: 640px;
    width: 100%;
}
.horari-welcome-card {
    background: var(--bg-panel, #f8f9fa);
    border: 1.5px solid var(--border-color, #e8e8e8);
    border-radius: 14px;
    padding: 18px 16px;
    text-align: left;
}
.horari-welcome-card-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}
.horari-welcome-card-title {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-main, #1a1a1a);
    margin-bottom: 4px;
}
.horari-welcome-card-desc {
    font-size: 0.75rem;
    color: var(--text-muted, #666);
    line-height: 1.5;
}
.horari-welcome-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 13px 28px;
    border-radius: 12px;
    border: none;
    background: var(--primary-color, #007bff);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0,123,255,0.3);
}
.horari-welcome-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,123,255,0.35);
}

/* ── Grid Layout ── */
.horari-grid-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Day headers row */
.horari-day-headers {
    display: grid;
    grid-template-columns: 60px repeat(5, 1fr);
    border-bottom: 1.5px solid var(--border-color, #e8e8e8);
    flex-shrink: 0;
}
.horari-day-header-cell {
    padding: 10px 8px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-right: 1px solid var(--border-color, #e8e8e8);
}
.horari-day-header-cell:last-child { border-right: none; }
.horari-day-header-cell.today {
    color: var(--primary-color, #007bff);
}
.horari-day-header-cell .day-num {
    display: block;
    font-size: 1.1rem;
    font-weight: 800;
    margin-top: 2px;
    color: var(--text-main, #1a1a1a);
}
.horari-day-header-cell.today .day-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: var(--primary-color, #007bff);
    color: #fff;
    border-radius: 50%;
}
.horari-day-header-corner { /* time column placeholder */
    border-right: 1px solid var(--border-color, #e8e8e8);
}

/* Scrollable grid area */
.horari-scroll-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}
.horari-grid {
    display: grid;
    grid-template-columns: 60px repeat(5, 1fr);
    position: relative;
    min-height: 100%;
}

/* Time slots column */
.horari-time-col {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-container, #fff);
}
.horari-time-slot {
    height: 60px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 4px 8px 0 0;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted, #aaa);
    border-bottom: 1px solid var(--border-color, #f0f0f0);
    letter-spacing: 0.3px;
}

/* Day columns */
.horari-day-col {
    position: relative;
    border-right: 1px solid var(--border-color, #e8e8e8);
    border-bottom: 1px solid var(--border-color, #e8e8e8);
}
.horari-day-col:last-child { border-right: none; }
.horari-day-col.today-col {
    background: rgba(0,123,255,0.025);
}
[data-theme="dark"] .horari-day-col.today-col {
    background: rgba(0,123,255,0.04);
}

/* Hour lines */
.horari-hour-line {
    height: 60px;
    border-bottom: 1px solid var(--border-color, #f0f0f0);
    position: relative;
}
.horari-hour-line:last-child { border-bottom: none; }

/* Drop zones (invisible, cover each slot) */
.horari-drop-zone {
    position: absolute;
    left: 0; right: 0;
    pointer-events: none;
}
.horari-drop-zone.drag-over {
    background: rgba(0,123,255,0.07);
    border: 2px dashed var(--primary-color, #007bff);
    border-radius: 6px;
    pointer-events: none;
}

/* ── Blocks ── */
.horari-block {
    position: absolute;
    left: 4px;
    right: 4px;
    border-radius: 10px;
    padding: 6px 9px;
    cursor: grab;
    overflow: hidden;
    box-sizing: border-box;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
    z-index: 3;
    user-select: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 28px;
}
.horari-block:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.18);
    transform: scale(1.015);
    z-index: 10;
}
.horari-block.dragging {
    opacity: 0.6;
    cursor: grabbing;
    transform: rotate(1.5deg) scale(1.04);
    z-index: 99;
    box-shadow: 0 12px 32px rgba(0,0,0,0.25);
}
.horari-block-title {
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.horari-block-prof {
    font-size: 0.65rem;
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}
.horari-block-time {
    font-size: 0.62rem;
    opacity: 0.7;
    margin-top: auto;
}
/* Break style */
.horari-block.is-break {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(0,0,0,0.04) 4px,
        rgba(0,0,0,0.04) 8px
    ) !important;
    border: 1.5px dashed currentColor !important;
}
.horari-block.is-break .horari-block-title { opacity: 0.85; }

/* Task block inside schedule */
.horari-block.is-task {
    border-left: 3px solid transparent;
}
.horari-block.is-task .horari-block-title::before {
    content: "⬜ ";
    font-size: 0.65rem;
}
.horari-block.is-task.task-done .horari-block-title::before {
    content: "✅ ";
}

/* Resize handle */
.horari-resize-handle {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.horari-resize-handle::after {
    content: '';
    width: 24px;
    height: 2px;
    background: rgba(255,255,255,0.7);
    border-radius: 2px;
}
.horari-block:hover .horari-resize-handle { opacity: 1; }

/* Block actions (on hover) */
.horari-block-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: none;
    gap: 3px;
}
.horari-block:hover .horari-block-actions { display: flex; }
.horari-block-action-btn {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    border: none;
    background: rgba(0,0,0,0.2);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: background 0.15s;
}
.horari-block-action-btn:hover { background: rgba(0,0,0,0.4); }

/* ── Add Block Modal ── */
#horariAddModal {
    position: fixed;
    inset: 0;
    z-index: 9100;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.22s ease;
}
#horariAddModal.visible { opacity: 1; }

.horari-add-modal {
    width: min(460px, 96vw);
    background: var(--bg-container, #fff);
    border-radius: 18px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    box-shadow: 0 24px 60px rgba(0,0,0,0.2);
    overflow: hidden;
    transform: scale(0.95) translateY(8px);
    transition: transform 0.25s cubic-bezier(0.22,1,0.36,1);
}
#horariAddModal.visible .horari-add-modal {
    transform: scale(1) translateY(0);
}
.horari-add-modal-header {
    padding: 18px 20px 14px;
    border-bottom: 1.5px solid var(--border-color, #e8e8e8);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.horari-add-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main, #1a1a1a);
    display: flex;
    align-items: center;
    gap: 8px;
}
.horari-add-modal-body {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.horari-form-row {
    display: flex;
    gap: 12px;
}
.horari-form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}
.horari-form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.horari-form-group input,
.horari-form-group select {
    padding: 9px 11px;
    border-radius: 9px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    background: var(--bg-container, #fff);
    color: var(--text-main, #1a1a1a);
    font-size: 0.85rem;
    font-family: 'Roboto', sans-serif;
    transition: border-color 0.18s, box-shadow 0.18s;
    width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}
.horari-form-group input:focus,
.horari-form-group select:focus {
    outline: none;
    border-color: var(--primary-color, #007bff);
    box-shadow: 0 0 0 3px rgba(0,123,255,0.12);
}
.horari-color-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.horari-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: transform 0.15s, border-color 0.15s;
}
.horari-color-swatch:hover { transform: scale(1.15); }
.horari-color-swatch.selected {
    border-color: var(--text-main, #1a1a1a);
    transform: scale(1.1);
}
.horari-add-modal-footer {
    padding: 14px 20px;
    border-top: 1.5px solid var(--border-color, #e8e8e8);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}
.horari-btn-cancel {
    padding: 9px 18px;
    border-radius: 9px;
    border: 1.5px solid var(--border-color, #e0e0e0);
    background: var(--bg-container, #fff);
    color: var(--text-muted, #666);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.horari-btn-cancel:hover { background: var(--bg-panel, #f5f5f5); }
.horari-btn-save {
    padding: 9px 22px;
    border-radius: 9px;
    border: none;
    background: var(--primary-color, #007bff);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
}
.horari-btn-save:hover { filter: brightness(1.08); transform: translateY(-1px); }

/* ── Current time indicator ── */
.horari-current-time-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #ef4444;
    z-index: 8;
    pointer-events: none;
}
.horari-current-time-line::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -4px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444;
}

/* ── Scrollbar ── */
.horari-scroll-area::-webkit-scrollbar { width: 5px; }
.horari-scroll-area::-webkit-scrollbar-track { background: transparent; }
.horari-scroll-area::-webkit-scrollbar-thumb {
    background: var(--border-color, #d0d0d0);
    border-radius: 99px;
}

/* ── Dark mode tweaks ── */
[data-theme="dark"] .horari-container {
    box-shadow: 0 32px 80px rgba(0,0,0,0.55);
}
[data-theme="dark"] .horari-block.is-break {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(255,255,255,0.04) 4px,
        rgba(255,255,255,0.04) 8px
    ) !important;
}

/* ── Drag ghost ── */
.horari-drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 99999;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    opacity: 0.85;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    transform: rotate(2deg);
    min-width: 100px;
    max-width: 180px;
    transition: none;
}

/* ── Empty state (column) ── */
.horari-empty-col-hint {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    color: var(--text-muted, #bbb);
    font-size: 0.7rem;
    text-align: center;
}
.horari-day-col:hover .horari-empty-col-hint { opacity: 0.6; }

/* ── Responsive ── */
@media (max-width: 768px) {
    .horari-container { border-radius: 14px; height: 98vh; }
    .horari-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
    .horari-week-label { min-width: 140px; font-size: 0.78rem; }
    .horari-action-btn span { display: none; }
    .horari-day-header-cell { font-size: 0.65rem; padding: 7px 3px; }
    .horari-day-header-cell .day-num { font-size: 0.9rem; }
    .horari-time-slot { font-size: 0.6rem; width: 44px; }
    .horari-grid { grid-template-columns: 44px repeat(5, 1fr); }
    .horari-day-headers { grid-template-columns: 44px repeat(5, 1fr); }
    .horari-welcome-cards { grid-template-columns: 1fr; }
}

/* Botó Horari */
#horariBtn { border-color: #10b981; color: #10b981; }
#horariBtn:hover { background-color: #f0fdf4; }
[data-theme="dark"] #horariBtn { border-color: #34d399; color: #34d399; }
[data-theme="dark"] #horariBtn:hover { background-color: #022c22; }

/* ═══════════════════════════════════════════════════
   MILLORES DE CONTRAST - MODE CLAR (RA CARDS)
   ═══════════════════════════════════════════════════ */

/* RA wrapper: fons lleugerament diferent del mòdul per destacar */
:root {
    --ra-bg: #f4f6fb;
    --ra-header-bg: #edf0f7;
    --ra-header-hover: #e0e5f0;
    --ra-border: #c8d0e0;
}
[data-theme="dark"] {
    --ra-bg: #1a1d24;
    --ra-header-bg: #22262e;
    --ra-header-hover: #2a2f3a;
    --ra-border: #333a48;
}

/* Override light mode RA accordion wrapper for better visibility */
:root .raAccordionWrapper {
    border: 1.5px solid var(--ra-border) !important;
    border-left: 4px solid var(--module-color, #007bff) !important;
    background-color: var(--bg-container) !important;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
    margin-bottom: 8px !important;
}

:root .raAccordionWrapper:hover {
    box-shadow: 0 3px 10px rgba(0,0,0,0.10) !important;
}

:root .raAccordion {
    background-color: var(--ra-header-bg) !important;
    border-bottom: 1px solid var(--ra-border);
}
:root .raAccordion:hover {
    background-color: var(--ra-header-hover) !important;
}


/* raPanel — use container variable so dark mode works */
:root:not([data-theme="dark"]) .raPanel {
    background-color: var(--bg-body) !important;
    border-top: 1.5px solid var(--ra-border) !important;
}

/* Task table header in light mode only */
:root:not([data-theme="dark"]) .taskTable thead tr {
    background-color: #e5eaf5 !important;
}
:root:not([data-theme="dark"]) .taskTable tbody tr:hover {
    background-color: #f0f4ff !important;
}

/* ═══════════════════════════════════════════════════
   BOTÓ "+" AFEGIR RA — expandible en hover
   ═══════════════════════════════════════════════════ */
/* addRaBtn — same expandable-btn mechanic as top buttons, color from module */
.addRaBtn {
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 9px;
    height: 40px;
    min-width: 40px;
    border-radius: 10px;
    border: 2px solid var(--module-color, #007bff);
    background-color: var(--bg-container);
    color: var(--module-color, #007bff);
    cursor: pointer;
    white-space: nowrap;
    transition: padding 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                box-shadow 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275),
                background-color 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin: 12px 0 4px 0;
}

.addRaBtn:hover {
    padding-right: 16px;
    box-shadow: 0 4px 10px var(--shadow-color);
    background-color: color-mix(in srgb, var(--module-color, #007bff) 8%, var(--bg-container));
}

/* Reuse .btnIconWrapper and .btnText inside addRaBtn */
.addRaBtn .btnIconWrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}
.addRaBtn .btnIconWrapper svg {
    width: 18px;
    height: 18px;
}

.addRaBtn .btnText {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 13px;
}

.addRaBtn:hover .btnText {
    max-width: 200px;
    opacity: 1;
    margin-left: 9px;
}

[data-theme="dark"] .addRaBtn:hover {
    background-color: color-mix(in srgb, var(--module-color, #007bff) 12%, var(--bg-container));
}

/* ═══════════════════════════════════════════════════
   MODAL TITLES — add icon alignment
   ═══════════════════════════════════════════════════ */
.modal h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal h3 svg {
    opacity: 0.75;
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════
   OCR INSTRUCTIONS LIST — checkmark icons
   ═══════════════════════════════════════════════════ */
.ocr-info-box ul li {
    padding-left: 4px;
    list-style: none;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.ocr-info-box ul li::before {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%2328a745' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
    margin-top: 2px;
}

/* ═══════════════════════════════════════════════════
   PENDING TASKS — notes icon fix
   ═══════════════════════════════════════════════════ */
.pending-task-note {
    font-size: 11.5px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
}
.pending-task-note::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='16' y1='13' x2='8' y2='13'/%3E%3Cline x1='16' y1='17' x2='8' y2='17'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    flex-shrink: 0;
}


/* ═══════════════════════════════════════════════════════════════
   SISTEMA D'ANIMACIÓ DE CREACIÓ — VERSIÓ DEFINITIVA
   ═══════════════════════════════════════════════════════════════ */

/* ── Partícules ── */
@keyframes particle-fly {
    0%   { transform: translate(0,0) scale(1); opacity: 1; }
    100% { transform: translate(var(--px),var(--py)) scale(0); opacity: 0; }
}
@keyframes particle-ring {
    0%   { transform: scale(0); opacity: 0.6; }
    60%  { opacity: 0.3; }
    100% { transform: scale(1); opacity: 0; }
}
.creation-particle {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 99999;
    animation: particle-fly var(--dur,480ms) cubic-bezier(0.15,0,0.85,1) var(--delay,0ms) both;
}
.creation-ring {
    position: fixed;
    border-radius: 50%;
    border: 2px solid var(--ring-color,#007bff);
    pointer-events: none;
    z-index: 99998;
    animation: particle-ring var(--dur,500ms) cubic-bezier(0.2,0.6,0.4,1) var(--delay,0ms) both;
}

/* ── TASK ROW — entrada immediata, sense pre-hidden ── */
@keyframes task-row-in {
    0%  { opacity:0; transform:scaleY(0.6) translateY(-6px); background:var(--task-flash-color,rgba(0,120,255,0.07)); }
    50% { opacity:1; transform:scaleY(1.02) translateY(1px); }
    75% { transform:scaleY(1) translateY(0); }
    100%{ opacity:1; transform:scaleY(1) translateY(0); background:transparent; }
}
tr.task-row-entering {
    transform-origin: top center;
    animation: task-row-in 0.45s cubic-bezier(0.22,1,0.36,1) forwards;
}

/* ── RA — entrada lateral IMMEDIATA, sense pre-hidden ── */
@keyframes ra-in {
    0%  { opacity:0; transform:translateX(-16px) scaleX(0.92); filter:blur(1px); }
    45% { opacity:1; transform:translateX(2px) scaleX(1.006); filter:blur(0); }
    70% { transform:translateX(-1px) scaleX(1); }
    100%{ opacity:1; transform:translateX(0) scaleX(1); }
}
@keyframes ra-glow {
    0%  { box-shadow:0 0 0 2.5px var(--ra-entry-color,#007bff), 0 4px 18px rgba(0,120,255,0.22); }
    55% { box-shadow:0 0 0 4px rgba(0,120,255,0.1), 0 6px 22px rgba(0,120,255,0.14); }
    100%{ box-shadow:none; }
}
@keyframes ra-shimmer {
    0%  { left:-80%; opacity:0.8; }
    100%{ left:140%; opacity:0; }
}
.raAccordionWrapper.ra-animate-in {
    animation: ra-in 0.42s cubic-bezier(0.22,1,0.36,1) forwards,
               ra-glow 0.7s ease forwards;
    transform-origin: left center;
}
.raAccordionWrapper.ra-animate-in .raAccordion::after {
    content:'';
    position:absolute;
    top:0; left:-80%;
    width:55%; height:100%;
    background:linear-gradient(90deg,transparent,rgba(255,255,255,0.45) 50%,transparent);
    animation: ra-shimmer 0.55s ease 0.08s forwards;
    pointer-events:none;
    border-radius:inherit;
    z-index:2;
}
.raAccordion { position:relative; overflow:hidden; }

/* ── addRaBtn — hover + creating ── */
.addRaBtn .btnIconWrapper svg {
    transition: transform 0.42s cubic-bezier(0.34,1.56,0.64,1);
}
.addRaBtn:hover .btnIconWrapper svg { transform: rotate(90deg) scale(1.12); }

@keyframes raBtn-wave {
    0%  { box-shadow:0 0 0 0 var(--module-color,#007bff); }
    35% { box-shadow:0 0 0 9px rgba(0,120,255,0.13); }
    65% { box-shadow:0 0 0 15px rgba(0,120,255,0.04); }
    100%{ box-shadow:0 0 0 0 rgba(0,120,255,0); }
}
@keyframes plus-spin {
    0%  { transform:rotate(0deg) scale(1); }
    40% { transform:rotate(155deg) scale(1.35); }
    65% { transform:rotate(130deg) scale(1.15); }
    100%{ transform:rotate(180deg) scale(1); opacity:0; }
}
.addRaBtn--creating { animation: raBtn-wave 0.6s ease-out forwards; }
.addRaBtn--creating .btnIconWrapper svg {
    animation: plus-spin 0.48s cubic-bezier(0.34,1.56,0.64,1) forwards !important;
    transition: none !important;
}

/* ── ACCORDIONWRAPPER — position:relative, NO overflow:hidden (trenca box-shadow) ── */
.accordionWrapper { position: relative; }

/* ══════════════════════════════════════════════════
   ANIMACIÓ MÒDUL — neta, sense clip-path ni ::before
   ══════════════════════════════════════════════════ */
@keyframes mod-in {
    0%   { opacity: 0; transform: translateY(-16px) scale(0.97); }
    60%  { opacity: 1; transform: translateY(3px)   scale(1.003); }
    82%  {             transform: translateY(-1px)  scale(1); }
    100% { opacity: 1; transform: translateY(0)     scale(1); }
}

.accordionWrapper.module-animate-in {
    animation: mod-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transform-origin: top center;
}

/* Shimmer overlay — div injectat per JS, no ::before/after */
.mod-shimmer-overlay {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    z-index: 20;
    overflow: hidden;
}
.mod-shimmer-overlay::after {
    content: '';
    position: absolute;
    top: 0; left: -80%;
    width: 60%; height: 100%;
    background: linear-gradient(105deg, transparent 20%, rgba(255,255,255,0.45) 50%, transparent 80%);
    animation: mod-shimmer-sweep 0.7s ease 0.2s forwards;
}
@keyframes mod-shimmer-sweep {
    0%   { left: -80%; opacity: 0; }
    10%  { opacity: 1; }
    100% { left: 140%; opacity: 0; }
}

/* ── addModuleBtn creating state ── */
#addModuleBtn.btn-creating .btnIconWrapper svg {
    animation: plus-spin 0.48s cubic-bezier(0.34,1.56,0.64,1) forwards;
    transition: none !important;
}

/* ══════════════════════════════════════════════════
   ANIMACIÓ ESBORRAT — fluida, sense salt
   ══════════════════════════════════════════════════ */

/* Wrap el contingut i anima l'altura del wrapper extern */
.deleting-wrapper {
    overflow: hidden;
    transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                opacity    0.22s ease,
                margin     0.38s cubic-bezier(0.4, 0, 0.2, 1),
                padding    0.38s cubic-bezier(0.4, 0, 0.2, 1);
}
.deleting-wrapper.collapsing {
    max-height: 0 !important;
    opacity: 0;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

