:root {
    /* Colore primario personalizzabile */
    --primary-color: #6b7280;
    --primary-color-dark: #ec4899;
    --primary-color-darker: #4b5563;
    --primary-color-light: #e879f9;
    --primary-text-color: #ffffff;

    /* Colore successo */
    --success-color: #4ade80;
    --success-color-light: rgba(74, 222, 128, 0.15);
    --success-color-dark: #22c55e;

    /* Tema scuro (default) */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #363636;
    --bg-hover: #3a3a3a;
    --bg-active: #454545;
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-tertiary: #888;
    --border-color: #3a3a3a;
}

/* Tema chiaro */
body.light-theme {
    --bg-primary: #e5e7eb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f3f4f6;
    --bg-hover: #e5e7eb;
    --bg-active: #d1d5db;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --border-color: #d1d5db;
}

/* Miglioramenti specifici per tema chiaro */
body.light-theme .section {
    background: #ffffff;
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body.light-theme .section-header {
    background: #f3f4f6;
}

body.light-theme .section-header:hover {
    background: #e5e7eb;
}

body.light-theme .section-header h2 {
    color: #1f2937;
}

body.light-theme .item-count {
    background: #e5e7eb;
    color: #6b7280;
}

body.light-theme .email-item,
body.light-theme .task-item,
body.light-theme .event-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border-left: 4px solid #4b5563; /* Grigio scuro per tema chiaro */
}

body.light-theme .item-title {
    color: #111827;
}

body.light-theme .item-from,
body.light-theme .event-details {
    color: #4b5563;
}

body.light-theme .item-snippet,
body.light-theme .task-notes {
    color: #6b7280;
}

body.light-theme .action-btn {
    background: transparent;
    border: none;
}

body.light-theme .action-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme .action-btn svg {
    stroke: #1f2937;
}

body.light-theme .task-menu-btn {
    background: #e5e7eb;
    border: 1px solid #d1d5db;
}

body.light-theme .task-menu-btn:hover {
    background: #d1d5db;
}

body.light-theme .task-menu-btn svg {
    stroke: #4b5563;
}

body.light-theme .task-menu-dropdown {
    background: #ffffff;
    border: 1px solid #d1d5db;
}

body.light-theme .icon-btn svg {
    stroke: #4b5563;
}

body.light-theme .btn-icon-small {
    background: #e5e7eb;
    border: 1px solid #d1d5db;
}

body.light-theme .btn-icon-small:hover {
    background: #d1d5db;
}

body.light-theme .btn-icon-small svg {
    stroke: #4b5563;
}

body.light-theme .header {
    background: #ffffff;
    border-bottom: 2px solid #d1d5db;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

body.light-theme .view-switch-btn {
    color: #4b5563;
}

body.light-theme .view-switch-btn:hover {
    background: #f3f4f6;
    color: #1f2937;
}

body.light-theme .view-switch-btn.active {
    background: #e5e7eb;
    color: #111827;
}

body.light-theme .view-switch-btn svg {
    stroke: currentColor;
}

body.light-theme .dropdown-menu {
    background: #ffffff;
    border: 1px solid #d1d5db;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

body.light-theme .dropdown-item {
    color: #1f2937;
}

body.light-theme .dropdown-item:hover {
    background: #f3f4f6;
}

body.light-theme .btn-today {
    background: #e5e7eb;
    color: #1f2937;
    border: 1px solid #d1d5db;
}

body.light-theme .btn-today:hover {
    background: #d1d5db;
}

body.light-theme .settings-btn {
    background: #e5e7eb;
    border: 1px solid #d1d5db;
}

body.light-theme .settings-btn:hover {
    background: #d1d5db;
}

body.light-theme .settings-btn svg {
    stroke: #495057;
}

body.light-theme .link-card {
    background: #ffffff;
    border: 1px solid #dee2e6;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body.light-theme .link-card:hover {
    background: #f8f9fa;
}

body.light-theme .postpone-popup-content,
body.light-theme .followup-popup-content,
body.light-theme .settings-popup-content {
    background: #ffffff;
    border: 1px solid #dee2e6;
}

body.light-theme .color-value-display {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
}

body.light-theme .theme-option {
    background: #f8f9fa;
    border: 3px solid #dee2e6;
}

body.light-theme .theme-option:hover {
    background: #e9ecef;
}

body.light-theme .notes-area {
    background: #f8f9fa;
}

body.light-theme .notes-area input[type="text"],
body.light-theme .notes-area textarea {
    background: #ffffff;
    border: 2px solid #dee2e6;
    color: #212529;
}

body.light-theme .followup-form-group input[type="date"],
body.light-theme .followup-form-group input[type="text"] {
    background: #ffffff;
    border: 2px solid #dee2e6;
    color: #212529;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========================================
   📜 SCROLLBAR GLOBALE
   ======================================== */

/* Webkit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color-dark);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-secondary);
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Links without specific classes use primary color */
a:not([class]) {
    color: var(--primary-color);
    text-decoration: none;
    transition: opacity 0.2s;
}

a:not([class]):hover {
    opacity: 0.8;
    text-decoration: underline;
}

a:not([class]):visited {
    color: var(--primary-color);
}

.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.login-box {
    background: var(--bg-secondary);
    padding: 60px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    text-align: center;
}

.login-box h1 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 32px;
}

.login-box p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

#signInBtn {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border: none;
    padding: 16px 40px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.4);
    transition: all 0.2s;
}

#signInBtn:hover {
    background: var(--primary-color-darker);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(75, 85, 99, 0.5);
}

.app {
    display: none;
}

.header {
    background: var(--bg-secondary);
    padding: 12px 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: nowrap;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h1 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 500;
    margin: 0;
}

.header-date {
    font-size: 18px;
}

.header-day {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.header-time {
    color: var(--text-secondary);
    font-size: 18px;
    font-weight: 500;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: nowrap;
}

/* Standardizzazione altezza e padding pulsanti header */
.header .icon-btn,
.header .btn,
.header .btn-today,
.header .user-avatar,
.header .view-switch-btn {
    height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header .icon-btn {
    padding: 10px;
    width: 44px;
}

.header .btn-today {
    padding: 0 20px;
    height: 44px;
}

.header .btn-new-icon {
    height: 44px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.user-profile {
    position: relative;
}

.new-menu-container {
    position: relative;
}

.user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--primary-color);
    transition: all 0.2s;
}

.user-avatar:hover {
    border-color: var(--primary-color-light);
    transform: scale(1.05);
}

.settings-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 2px solid var(--border-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.settings-btn:hover {
    background: var(--bg-active);
    border-color: var(--primary-color);
    transform: rotate(45deg);
}

.settings-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
    fill: none;
    stroke-width: 2;
}

.dropdown-menu {
    position: absolute;
    top: 50px;
    right: 0;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 0;
    min-width: 280px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    display: none;
    z-index: 1000;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    padding: 12px 20px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--bg-hover);
}

.dropdown-item:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

.dropdown-item svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-primary);
    flex-shrink: 0;
}

@media (max-width: 700px) {
    /* Nascondi data e ora sotto 700px */
    .header-title-group {
        display: none !important;
    }

    .header-left {
        gap: 8px;
    }
}

@media (max-width: 768px) {
    /* ========================================
       HEADER MOBILE - RICOSTRUITO COMPLETAMENTE
       ======================================== */

    .header {
        padding: 8px 12px;
        gap: 8px;
        min-height: 56px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Header Left - View Switcher + Title */
    .header-left {
        display: flex;
        align-items: center;
        gap: 12px;
        flex: 1;
        min-width: 0;
        flex-wrap: nowrap;
    }

    /* View Switcher Container */
    .view-switcher {
        display: flex;
        gap: 6px;
        align-items: center;
        flex-shrink: 0;
    }

    /* View Switch Buttons - Solo icone su mobile */
    .view-switch-btn {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    .view-switch-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Nascondi testo, mostra solo icone */
    .view-switch-btn .btn-text {
        display: none !important;
    }

    /* Title Group */
    .header-title-group {
        display: flex;
        align-items: center;
        flex: 1;
        min-width: 0;
    }

    .header-left h1 {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 0;
    }

    /* Nascondi orario su mobile */
    .header-time {
        display: none !important;
    }

    /* Header Actions - Pulsanti destra */
    .header-actions {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
        flex-wrap: nowrap;
    }

    /* Nascondi pulsante refresh su mobile */
    .header-actions > .icon-btn:first-child {
        display: none !important;
    }

    /* Pulsanti uniformi a 40px */
    .header .icon-btn,
    .header .btn-today,
    .header .user-avatar {
        width: 40px !important;
        height: 40px !important;
        min-width: 40px !important;
        min-height: 40px !important;
        padding: 0 !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Icon buttons */
    .header .icon-btn {
        border-radius: 8px;
    }

    .header .icon-btn svg {
        width: 20px;
        height: 20px;
    }

    /* Pulsante Oggi */
    .header .btn-today {
        border-radius: 8px;
        font-size: 13px;
        padding: 0 12px !important;
        width: auto !important;
        min-width: 60px !important;
    }

    /* Pulsante Nuovo */
    .header .btn-new-icon {
        height: 40px !important;
        min-height: 40px !important;
        min-width: 40px !important;
        width: 40px !important;
        padding: 0 !important;
        border-radius: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Nascondi testo "Nuovo" su mobile */
    .header .btn-new-icon .new-text {
        display: none !important;
    }

    .header .btn-new-icon .new-icon {
        font-size: 24px;
        line-height: 1;
    }

    /* Day Navigation */
    .day-nav {
        display: flex;
        gap: 4px;
        align-items: center;
    }

    /* User Avatar */
    .header .user-avatar {
        border-radius: 50%;
        object-fit: cover;
    }

    /* Assicura allineamento verticale perfetto */
    .header,
    .header-left,
    .header-actions,
    .view-switcher,
    .day-nav {
        align-items: center;
    }

    /* Dropdown menu mobile - fix positioning */
    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        right: 10px !important;
        left: auto !important;
        max-width: calc(100vw - 20px);
        margin-top: 10px;
    }

    .new-menu-container .dropdown-menu {
        right: 10px !important;
        left: auto !important;
        transform: none;
        z-index: 9999;
    }

    .user-profile .dropdown-menu {
        right: 10px !important;
        left: auto !important;
    }

    /* Nascondi pulsante impostazioni standalone su mobile */
    .settings-btn {
        display: none;
    }

    /* Tasks header mobile */
    .tasks-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px 20px;
        gap: 12px;
    }

    .tasks-header-content {
        width: 100%;
    }

    .tasks-header-content h2 {
        width: 100%;
        margin: 0;
    }

    .tasks-header h2 {
        font-size: 18px;
        width: 100%;
    }

    .tasks-header-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

.btn {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(192, 132, 252, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: var(--primary-color-darker);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(192, 132, 252, 0.4);
}

.btn-link {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(192, 132, 252, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-link:hover {
    background: var(--primary-color-darker);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(192, 132, 252, 0.4);
}

.btn-link svg {
    width: 16px;
    height: 16px;
}

/* Testo nero per pulsanti con colore primario chiaro */
.btn.btn-light-bg,
.btn-link.btn-light-bg {
    color: #000000 !important;
}

.btn.btn-light-bg svg,
.btn-link.btn-light-bg svg {
    stroke: #000000 !important;
}


.btn-today {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-today:hover {
    background: var(--bg-active);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(58, 58, 58, 0.4);
}

.main {
    max-width: 1900px;
    margin: 0 auto;
    padding: 12px;
}

.grid {
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.grid-column {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Quando una colonna è vuota la nascondiamo, così le altre due si ridistribuiscono */
.grid-column:empty {
    display: none;
}

/* L'empty state occupa tutta la larghezza sotto le colonne */
.grid > .empty-state-done {
    flex-basis: 100%;
}

/* Wrapper che tiene tutti i post-it nella stessa colonna */
.postit-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.postit-wrapper:empty {
    display: none;
}

.postit-wrapper .postit-board {
    display: block;
    width: 100%;
    margin-bottom: 0;
}

/* Layout fisso a 3 colonne (data-columns mantenuto per retrocompatibilità) */
.grid[data-columns] {
    display: flex;
}

/* Mobile: stack delle colonne */
@media (max-width: 768px) {
    .grid {
        flex-direction: column !important;
        gap: 0 !important;
    }
    .grid-column {
        width: 100%;
    }
}

.section {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transition: transform 0.2s, opacity 0.2s;
    overflow: hidden;
    word-wrap: break-word;
    margin-bottom: 12px;
    display: block;
    width: 100%;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 10px;
    border-bottom: none;
    background: var(--bg-hover);
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

.section-header:hover {
    background: var(--bg-active);
}

.section-header h2 {
    color: var(--primary-color);
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-count {
    background: var(--bg-hover);
    color: var(--text-tertiary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.2s;
}

.item-count.has-items {
    background: var(--primary-color);
    color: var(--primary-text-color);
}

.section-content {
    padding: 6px 4px 4px;
    display: none;
}

.section-content.expanded {
    display: block;
}

/* Quick-links uses flex layout when expanded */
.section-content.quick-links.expanded {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.section-header h2 a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

.section-header h2 a:hover {
    color: var(--primary-color-light);
    text-decoration: underline;
}

.email-item, .task-item, .event-item {
    background: var(--bg-tertiary);
    padding: 10px 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    border-left: 4px solid;
    border-left-color: #9ca3af; /* Grigio chiaro per tema scuro */
    touch-action: manipulation;
}

.email-item {
    border-left-color: #9ca3af;
}

.task-item {
    border-left-color: #9ca3af;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.task-item.tickets {
    border-left-color: #9ca3af;
}

.event-item {
    border-left-color: #9ca3af;
}

.event-item.urgent {
    background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
    border-left: 6px solid #ef4444;
    box-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
    animation: urgentPulse 2s ease-in-out infinite;
}

.event-item.urgent .item-title,
.event-item.urgent .event-time,
.event-item.urgent .event-details {
    color: #ffffff;
    font-weight: 600;
}

.event-item.hidden {
    opacity: 0.4;
    filter: grayscale(80%);
}

@keyframes urgentPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(220, 38, 38, 0.4);
    }
    50% {
        box-shadow: 0 0 30px rgba(220, 38, 38, 0.6);
    }
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
}

.item-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    flex: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.thread-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 6px;
    opacity: 0.8;
}

.item-from {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 6px;
}

.item-snippet {
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.item-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}

/* Fix alignment for task menu button inside task-item-header */
.task-item-header .item-actions {
    margin-top: 0;
    align-self: flex-start;
    margin-right: 0;
}

.link-buttons-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
}

.link-buttons-row .btn-link {
    width: 100%;
    justify-content: center;
}

.action-buttons-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Nascondi i pulsanti azione quando l'opzione è attiva */
body.hide-action-buttons .action-buttons-row,
body.hide-action-buttons .email-item .item-actions {
    display: none;
}

/* Mostra i pulsanti azione su hover (desktop) o quando attivato (mobile) */
body.hide-action-buttons .task-item:hover .action-buttons-row,
body.hide-action-buttons .event-item:hover .action-buttons-row,
body.hide-action-buttons .email-item:hover .item-actions,
body.hide-action-buttons .task-item.actions-visible .action-buttons-row,
body.hide-action-buttons .event-item.actions-visible .action-buttons-row,
body.hide-action-buttons .email-item.actions-visible .item-actions {
    display: flex;
}

/* Event action buttons: hidden by default on desktop, show on hover */
.event-item .action-buttons-row {
    display: none;
    transition: opacity 0.15s;
}

.event-item:hover .action-buttons-row,
.event-item.actions-visible .action-buttons-row {
    display: flex;
}

/* Email action buttons (item-actions container): hidden by default,
   visibili solo su hover come per gli eventi e le task */
.email-item .item-actions {
    display: none;
    transition: opacity 0.15s;
}

.email-item:hover .item-actions,
.email-item.actions-visible .item-actions {
    display: flex;
}

/* Mobile 3-dots menu for events */
.event-mobile-menu-btn {
    display: none;
    background: var(--bg-hover);
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-start;
    transition: background 0.2s;
}

.event-mobile-menu-btn:hover {
    background: var(--bg-active);
}

.event-mobile-menu-btn svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
    fill: none;
    stroke-width: 2;
}

.event-item-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    justify-content: space-between;
}

.event-item-main {
    flex: 1;
    min-width: 0;
}

/* Pulsanti azione: sfondo trasparente, icona contrasto col tema */
.action-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.action-btn svg {
    width: 18px;
    height: 18px;
    stroke: #ffffff;
    fill: none;
    stroke-width: 2;
}

/* Menu a 3 puntini per le azioni */
.task-menu-container {
    position: relative;
    display: inline-block;
}

.task-menu-btn {
    background: var(--bg-hover);
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    width: 34px;
    height: 34px;
    box-sizing: border-box;
}

.task-menu-btn:hover {
    background: var(--bg-active);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Stile per pulsante elimina attività completate */
.task-delete-btn {
    background: #ef4444 !important;
}

.task-delete-btn:hover {
    background: #dc2626 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.task-menu-btn svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-primary);
    fill: none;
    stroke-width: 2;
}

/* Stile specifico per pulsanti menù nelle subtask */
.subtask-actions .task-menu-btn {
    width: 28px;
    height: 28px;
    padding: 6px;
}

.subtask-actions .task-menu-btn svg {
    width: 14px;
    height: 14px;
}

.task-menu-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 200px;
    z-index: 1000;
    display: none;
    overflow: hidden;
}

.task-menu-dropdown.show {
    display: block;
}

.task-menu-dropdown.open-up {
    top: auto;
    bottom: calc(100% + 4px);
}

.task-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--text-primary);
    font-size: 14px;
    border: none;
    width: 100%;
    text-align: left;
    background: transparent;
}

.task-menu-item:hover {
    background: var(--bg-hover);
}

.task-menu-item svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    flex-shrink: 0;
}

.task-menu-item.danger {
    color: #ef4444;
}

.task-menu-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Date picker inline styling */
.task-due-date-input {
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.task-due-date-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* Style the date picker calendar icon */
.task-due-date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    filter: invert(0.7);
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.7;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--text-primary);
    fill: none;
    stroke-width: 2;
}

.day-nav {
    display: flex;
    gap: 10px;
    align-items: center;
}

.day-nav .icon-btn svg {
    width: 24px;
    height: 24px;
    stroke: var(--text-primary);
    fill: var(--text-primary);
}

.task-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-top: 2px;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    transition: all 0.2s;
    position: relative;
}

.task-checkbox:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.task-checkbox:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.task-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.task-content {
    flex: 1;
}

.task-notes {
    color: var(--text-tertiary);
    font-size: 14px;
    margin-top: 6px;
}

.event-time {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
}

.event-details {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 8px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

.all-day-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.all-day-section h3 {
    color: var(--text-secondary);
    font-size: 16px;
    margin-bottom: 15px;
}

.link-card {
    background: var(--bg-tertiary);
    padding: 12px 15px;
    border-radius: 6px;
    text-align: left;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
    transition: all 0.2s;
    border-left: 4px solid var(--primary-color);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.link-card:hover {
    background: var(--bg-hover);
    transform: translateX(3px);
}

.link-card.whatsapp {
    border-left-color: #25d366;
}

.link-card.facebook {
    border-left-color: #1877f2;
}

.link-card.linkedin {
    border-left-color: #0a66c2;
}

.link-card.keep {
    border-left-color: #4CAF50;
}

.link-status-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    font-size: 16px;
    font-weight: 500;
}

.loading::before {
    content: '';
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.empty {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.notes-area {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

.notes-area input[type="text"] {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.notes-area input[type="text"]:focus {
    outline: none;
    border-color: #60a5fa;
}

.notes-area textarea {
    width: 100%;
    min-height: 100px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 10px;
}

.notes-area textarea:focus {
    outline: none;
    border-color: #60a5fa;
}

.notes-area button {
    width: 100%;
}

/* Popup per selezione giorni posticipo */
.postpone-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.postpone-popup.show {
    display: flex;
}

.postpone-popup-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.postpone-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.postpone-popup-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.postpone-popup-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.postpone-popup-close:hover {
    background: var(--bg-hover);
}

.postpone-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.postpone-option {
    background: var(--bg-hover);
    border: none;
    color: var(--text-primary);
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.postpone-option:hover {
    background: var(--bg-active);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Popup per follow-up */
.followup-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.followup-popup.show {
    display: flex;
}

.followup-popup-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 25px;
    max-width: 450px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.followup-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.followup-popup-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.followup-form-group {
    margin-bottom: 15px;
}

.followup-form-group label {
    display: block;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 600;
}

.followup-form-group input[type="date"],
.followup-form-group input[type="text"] {
    width: 100%;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
}

.followup-form-group input:focus {
    outline: none;
    border-color: #60a5fa;
}

.followup-form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.followup-form-actions button {
    flex: 1;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    border: none;
}

.followup-form-actions .btn-create {
    background: var(--primary-color);
    color: var(--primary-text-color);
}

.followup-form-actions .btn-create:hover {
    background: var(--primary-color-darker);
    transform: translateY(-2px);
}

.followup-form-actions .btn-cancel {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.followup-form-actions .btn-cancel:hover {
    background: var(--bg-active);
}

/* Bottoni globali per modal */
.btn-create {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-create:hover {
    background: var(--primary-color-darker);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-cancel {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-cancel:hover {
    background: var(--bg-active);
    transform: translateY(-2px);
}

body.light-theme .btn-cancel {
    background: #d1d5db;
    color: #1f2937;
}

body.light-theme .btn-cancel:hover {
    background: #9ca3af;
}

/* Popup impostazioni */
.settings-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.settings-popup.show {
    display: flex;
}

.settings-popup-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.settings-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.settings-popup-header h3 {
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.settings-popup-close {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.settings-popup-close:hover {
    background: var(--bg-hover);
}

.settings-form-group {
    margin-bottom: 25px;
}

.settings-form-group label {
    display: block;
    color: var(--text-primary);
    font-size: 15px;
    margin-bottom: 12px;
    font-weight: 600;
}

.settings-form-group .form-description {
    display: block;
    color: var(--text-tertiary);
    font-size: 13px;
    margin-bottom: 10px;
}

.toggle-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
}

.toggle-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.toggle-option label {
    margin-bottom: 0 !important;
    font-weight: 400 !important;
    font-size: 14px !important;
    cursor: pointer;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
}

.color-picker-input {
    width: 40px;
    height: 25px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-picker-input:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.color-picker-compact,
.custom-color-input {
    width: 60px;
    height: 40px;
    min-width: 60px;
    min-height: 40px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    overflow: hidden;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.color-picker-compact:hover,
.custom-color-input:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

/* Stili per i componenti interni del color picker (WebKit) */
.color-picker-compact::-webkit-color-swatch-wrapper,
.custom-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker-compact::-webkit-color-swatch,
.custom-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
}

/* Stili per Firefox */
.color-picker-compact::-moz-color-swatch,
.custom-color-input::-moz-color-swatch {
    border: none;
    border-radius: 8px;
}

.color-value-display {
    flex: 1;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 15px;
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: 600;
}

.theme-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.theme-option {
    background: var(--bg-tertiary);
    border: 3px solid var(--border-color);
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.theme-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-option.active {
    border-color: var(--primary-color);
    background: var(--bg-hover);
}

.theme-option-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.theme-option-icon svg {
    stroke: var(--text-primary);
}

/* Tema chiaro: icone nere */
body.light-theme .theme-option-icon svg {
    stroke: #1f2937;
}

.theme-option-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.settings-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

.settings-actions button {
    flex: 1;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    border: none;
}

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

.settings-save-btn:hover {
    background: var(--primary-color-darker);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.settings-cancel-btn {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.settings-cancel-btn:hover {
    background: var(--bg-active);
}

/* Gestione Link nelle Impostazioni */
.links-list-container {
    margin-bottom: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.link-item-settings {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--primary-color);
    gap: 12px;
}

.link-item-info {
    flex: 1;
    min-width: 0; /* Permette overflow */
    overflow: hidden;
}

.link-item-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    word-break: break-word;
}

.link-item-url {
    color: var(--text-tertiary);
    font-size: 12px;
    margin-bottom: 4px;
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.link-item-frequency {
    color: var(--text-secondary);
    font-size: 12px;
    font-style: italic;
}

.link-item-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0; /* Impedisce al pulsante di rimpicciolirsi */
}

.btn-delete-link {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    white-space: nowrap; /* Impedisce al testo di andare a capo */
}

.btn-delete-link:hover {
    background: #c82333;
}

.btn-add-link {
    width: 100%;
    background: var(--primary-color);
    color: var(--primary-text-color);
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-add-link:hover {
    background: var(--primary-color-darker);
}

.add-link-form {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    border: 2px solid var(--border-color);
}

.add-link-form input[type="url"],
.add-link-form input[type="text"],
.add-link-form input[type="number"],
.add-link-form select {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 10px;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.frequency-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.frequency-inputs input {
    margin-bottom: 0;
}

.frequency-inputs select {
    margin-bottom: 0;
}

.link-form-actions {
    display: flex;
    gap: 10px;
}

.link-form-actions button {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    border: none;
}

.btn-cancel-link {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.btn-cancel-link:hover {
    background: var(--bg-active);
}

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

.btn-save-link:hover {
    background: var(--primary-color-darker);
}

.empty-links-message {
    text-align: center;
    padding: 20px;
    color: var(--text-tertiary);
    font-style: italic;
}

/* Tabs per modal trascrizione */
.tab-btn.active {
    color: var(--primary-color) !important;
    border-bottom-color: var(--primary-color) !important;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-content {
    animation: fadeIn 0.3s;
}

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

/* Task preview item */
.task-preview-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
}

.task-preview-item input[type="text"],
.task-preview-item textarea {
    width: 100%;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: inherit;
    margin-bottom: 10px;
}

.task-preview-item textarea {
    min-height: 60px;
    resize: vertical;
}

.subtask-preview {
    margin-left: 20px;
    padding: 10px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--primary-color);
    border-radius: 6px;
    margin-bottom: 8px;
}

.subtask-preview input {
    background: var(--bg-secondary);
}

.btn-remove-task {
    background: #ef4444;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.btn-remove-task:hover {
    background: #dc2626;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Inline Spinner for buttons and text */
.spinner-inline {
    display: inline-block;
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 6px;
}

.spinner-inline svg {
    animation: spin 1s linear infinite;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loading-text {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
}

/* ========================================
   📝 FORM FIELDS STANDARDIZZATI
   ======================================== */

/* Form Group Container */
.form-group {
    margin-bottom: 15px;
}

/* Form Label */
.form-label {
    display: block;
    color: var(--text-primary);
    font-size: 14px;
    margin-bottom: 8px;
    font-weight: 600;
}

/* Form Input Standard */
.form-input {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

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

.form-input::placeholder {
    color: var(--text-tertiary);
    opacity: 0.7;
}

/* Date picker input styling */
input[type="date"] {
    color-scheme: dark;
    position: relative;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0;
    position: absolute;
    right: 12px;
    width: 20px;
    height: 20px;
}

input[type="date"]::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    background-color: var(--primary-color);
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>');
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

/* Theme-specific date picker */
body.light-theme input[type="date"] {
    color-scheme: light;
}

/* Form Textarea */
.form-textarea {
    width: 100%;
    min-height: 100px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    transition: all 0.2s;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

.form-textarea::placeholder {
    color: var(--text-tertiary);
    opacity: 0.7;
}

/* Form Select */
.form-select {
    width: 100%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 12px;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

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

/* Form Checkbox */
.form-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-secondary);
    transition: all 0.2s;
    position: relative;
}

.form-checkbox:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.form-checkbox:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.form-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid var(--primary-text-color);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.form-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

/* Form Color Picker */
.form-color-picker {
    width: 80px;
    height: 50px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.form-color-picker:hover {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.form-color-picker:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.15);
}

/* Light theme specific styles */
body.light-theme .form-input,
body.light-theme .form-textarea,
body.light-theme .form-select,
body.light-theme .form-checkbox {
    background: #ffffff;
    border-color: #d1d5db;
    color: #1f2937;
}

body.light-theme .form-input:focus,
body.light-theme .form-textarea:focus,
body.light-theme .form-select:focus,
body.light-theme .form-checkbox:focus {
    border-color: var(--primary-color);
}

body.light-theme .form-input::placeholder,
body.light-theme .form-textarea::placeholder {
    color: #6b7280;
}

/* ========================================
   Fine Form Fields Standardizzati
   ======================================== */

/* ========================================
   ✨ RESPONSIVE MOBILE MIGLIORATO
   ======================================== */

/* Tablet e sotto */
@media (max-width: 1024px) {
    .main {
        padding: 15px;
    }

    .grid {
        gap: 20px;
    }

    .section {
        padding: 12px;
        margin-bottom: 20px;
    }

    .section-header h2 {
        font-size: 18px;
    }
}

/* Mobile landscape e sotto */
@media (max-width: 768px) {
    /* Header ottimizzato - tutti gli elementi su una riga */
    .header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--bg-secondary);
        flex-wrap: nowrap;
        gap: 6px;
        padding: 8px 10px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .header-left {
        flex: 1;
        min-width: 0;
        gap: 8px;
    }

    .header-left h1 {
        font-size: 14px;
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-time {
        font-size: 13px;
        white-space: nowrap;
    }

    .header-actions {
        flex-wrap: nowrap;
        gap: 6px;
        flex-shrink: 0;
    }

    .header::-webkit-scrollbar {
        height: 2px;
    }
    
    /* Bottoni touch-friendly */
    .btn, .btn-today {
        padding: 10px 18px;
        font-size: 14px;
        min-height: 44px;
        white-space: nowrap;
    }
    
    .icon-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }
    
    .icon-btn svg {
        width: 24px;
        height: 24px;
    }
    
    .settings-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
    }
    
    /* Grid e sezioni - Layout verticale forzato */
    .main {
        padding: 8px;
    }

    .section {
        width: 100% !important;
        margin-bottom: 10px;
        padding: 8px;
        margin-left: 0;
        margin-right: 0;
    }

    .section-header {
        padding: 8px 10px;
        cursor: pointer;
    }
    
    .section-header h2 {
        font-size: 16px;
        gap: 8px;
    }
    
    .section-header h2 svg {
        width: 18px;
        height: 18px;
    }
    
    .item-count {
        font-size: 13px;
        padding: 3px 10px;
    }
    
    /* Item cards più compatti */
    .email-item, .task-item, .event-item {
        padding: 10px;
        margin-bottom: 8px;
    }

    .item-title {
        font-size: 14px;
        line-height: 1.4;
    }

    /* Mobile: nascondi action-buttons-row negli eventi, mostra 3-dots */
    .event-item .action-buttons-row {
        display: none !important;
    }

    .event-mobile-menu-btn {
        display: inline-flex;
    }
    
    .item-from, .item-snippet, .event-details, .task-notes {
        font-size: 13px;
        line-height: 1.5;
    }
    
    /* Pulsanti azioni touch-friendly */
    .item-actions {
        gap: 6px;
        margin-top: 8px;
    }
    
    .action-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 10px;
    }
    
    .action-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .btn-link {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 44px;
    }
    
    /* Link rapidi */
    .link-card {
        padding: 14px;
        font-size: 14px;
        min-height: 50px;
    }
    
    /* Popup ottimizzati */
    .postpone-popup-content,
    .followup-popup-content,
    .postit-modal-content {
        width: 95%;
        max-width: 400px;
        padding: 20px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .postpone-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .postpone-option {
        padding: 14px;
        font-size: 14px;
        min-height: 60px;
    }
    
    /* Dropdown menu */
    .dropdown-menu {
        right: 0;
        left: auto;
        min-width: 200px;
        max-width: 90vw;
    }
    
    .dropdown-item {
        padding: 14px 16px;
        font-size: 14px;
        min-height: 50px;
    }
    
    /* Navigation giorni */
    .day-nav {
        display: flex;
        gap: 6px;
    }
    
    .day-nav .icon-btn {
        padding: 8px;
    }
    
    .btn-today {
        padding: 8px 14px;
        font-size: 13px;
    }
}

/* Mobile portrait ottimizzato */
@media (max-width: 480px) {
    /* Grid verticale forzato anche su portrait */
    .section {
        display: inline-block;
        width: 100%;
    }
    
    .header {
        padding: 8px 10px;
    }
    
    .header-left h1 {
        font-size: 14px;
    }
    
    .header-time {
        font-size: 13px;
    }
    
    .header-actions {
        gap: 6px;
    }
    
    .btn, .btn-today {
        padding: 8px 14px;
        font-size: 13px;
        min-height: 40px;
    }
    
    .icon-btn {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }
    
    .icon-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .user-avatar {
        width: 36px;
        height: 36px;
    }
    
    .section-header h2 {
        font-size: 15px;
    }
    
    .item-title {
        font-size: 14px;
    }
    
    .item-from, .item-snippet, .event-details {
        font-size: 12px;
    }
    
    /* Azioni più compatte su schermi piccoli */
    .action-btn {
        min-width: 40px;
        min-height: 40px;
        padding: 8px;
    }
    
    .action-btn svg {
        width: 18px;
        height: 18px;
    }
    
    .btn-link {
        padding: 8px 12px;
        font-size: 12px;
        min-height: 40px;
    }
    
    .postpone-options {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .postpone-option {
        padding: 16px;
    }
    
    /* Day navigation più compatta */
    .day-nav {
        gap: 4px;
    }
    
    .btn-today {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    .section {
        display: inline-block;
        width: 100%;
    }
    
    .header-left h1 {
        font-size: 13px;
    }
    
    .header-actions {
        gap: 4px;
    }
    
    .btn {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .section-header h2 {
        font-size: 14px;
    }
    
    .item-title {
        font-size: 13px;
    }
}

/* ========================================
   Fine CSS Responsive Migliorato
   ======================================== */

/* ========================================
   VIEW SWITCHER & TASKS VIEW
   ======================================== */

/* View Switcher */
.view-switcher {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 0;
    padding: 0;
}

.view-switch-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    height: 44px;
    min-width: 44px;
    opacity: 0.8;
}

.view-switch-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    opacity: 1;
    transform: translateY(-1px);
}

.view-switch-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    opacity: 1;
}

.view-switch-btn svg {
    stroke: currentColor;
    width: 20px;
    height: 20px;
}

/* Tasks View Layout */
.tasks-view {
    display: flex;
    height: calc(100vh - 70px);
    background: var(--bg-primary);
}

/* Tasks Sidebar */
.tasks-sidebar {
    width: 320px;
    background: var(--bg-secondary);
    border-right: 2px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tasks-sidebar-header {
    padding: 20px;
    border-bottom: 2px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tasks-sidebar-header h3 {
    font-size: 18px;
    color: var(--text-primary);
    font-weight: 600;
}

.btn-icon-small {
    background: var(--bg-hover);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.btn-icon-small:hover {
    background: var(--bg-active);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.btn-icon-small svg {
    stroke: var(--text-primary);
}

.tasks-lists {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    padding-bottom: 120px; /* Aggiungi spazio per evitare che l'ultima lista vada sotto */
}

/* Custom scrollbar for tasks lists sidebar */
.tasks-lists::-webkit-scrollbar {
    width: 8px;
}

.tasks-lists::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.tasks-lists::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.tasks-lists::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color-dark);
}

/* Firefox scrollbar */
.tasks-lists {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-secondary);
}

.task-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 6px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid transparent;
    position: relative;
}

.task-list-item:hover {
    background: var(--bg-hover);
}

.task-list-item.active {
    background: var(--bg-active);
    border-left-color: var(--primary-color);
}

/* Pulsante Situazione attuale */
.situazione-attuale-btn {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: none;
    border-left: 4px solid var(--primary-color);
}

.situazione-attuale-btn:hover {
    background: var(--bg-secondary);
}

.situazione-attuale-btn.active {
    background: var(--primary-color);
    /* color is set dynamically via JavaScript based on primary color luminance */
    border-left: 4px solid rgba(255,255,255,0.3);
}

/* Override text color for situazione attuale button when active */
.situazione-attuale-btn.active .task-list-title,
.situazione-attuale-btn.active .task-list-info,
.situazione-attuale-btn.active svg {
    color: inherit !important;
    stroke: currentColor;
}

.task-list-item.dragging {
    opacity: 0.5;
}

.task-list-item.drag-over {
    background: var(--primary-color);
    border-left-color: var(--primary-color);
}

/* Pulsante Apri Google Tasks */
.open-google-tasks-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin-top: 16px;
    background: transparent;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
}

.open-google-tasks-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.open-google-tasks-btn svg {
    flex-shrink: 0;
}

.task-item-full.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.task-item-full.task-highlighted {
    background: var(--bg-secondary) !important;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.subtask-item.subtask-highlighted {
    background: var(--bg-secondary) !important;
    box-shadow: 0 0 0 2px var(--primary-color);
}

/* Animazione lampeggio per navigazione da ricerca */
@keyframes searchResultFlash {
    0%, 100% {
        box-shadow: 0 0 0 3px var(--primary-color);
        background: rgba(255, 107, 53, 0.15);
    }
    50% {
        box-shadow: 0 0 20px 6px var(--primary-color);
        background: rgba(255, 107, 53, 0.35);
    }
}

.task-item-full.search-flash {
    animation: searchResultFlash 0.6s ease-in-out 5;
    position: relative;
    z-index: 10;
}

.subtask-item.search-flash {
    animation: searchResultFlash 0.6s ease-in-out 5;
    position: relative;
    z-index: 10;
}

/* Animazione lampeggio tenue per feedback salvataggio */
@keyframes saveSuccessFlash {
    0% {
        box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.6);
        background: rgba(74, 222, 128, 0.08);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(74, 222, 128, 0.4);
        background: rgba(74, 222, 128, 0.15);
    }
    100% {
        box-shadow: none;
        background: transparent;
    }
}

.task-item-full.save-flash {
    animation: saveSuccessFlash 0.8s ease-out 1;
    position: relative;
}

.subtask-item.save-flash {
    animation: saveSuccessFlash 0.8s ease-out 1;
    position: relative;
}

/* Modalità riordinamento attività */
.reorder-mode .task-item-full.reorder-enabled {
    cursor: grab;
    border-left: 3px solid var(--primary-color);
    user-select: none; /* Disabilita selezione testo durante il drag */
}

.reorder-mode .task-item-full.reorder-enabled:active {
    cursor: grabbing;
}

/* Modalità riordinamento subtask */
.reorder-mode .subtask-item.reorder-enabled {
    cursor: grab;
    border-left: 3px solid var(--primary-color);
    margin-left: -3px;
    user-select: none; /* Disabilita selezione testo durante il drag */
}

.reorder-mode .subtask-item.reorder-enabled:active {
    cursor: grabbing;
}

.subtask-item.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

/* Disabilita tutte le azioni durante la modalità riordinamento */
.reorder-mode .task-item-full .task-checkbox-large,
.reorder-mode .task-item-full .task-due-date,
.reorder-mode .task-item-full .task-add-date,
.reorder-mode .task-item-full .task-add-label,
.reorder-mode .task-item-full .task-label-badge,
.reorder-mode .task-item-full .item-actions,
.reorder-mode .task-item-full .task-accordion-toggle,
.reorder-mode .task-item-full .task-move-buttons,
.reorder-mode .task-item-full .task-attachments,
.reorder-mode .task-item-full .task-expandable-content {
    pointer-events: none;
    opacity: 0.5;
}

/* Non disabilitare il contenuto principale per permettere il drag */
.reorder-mode .task-item-full .task-item-content-full {
    pointer-events: auto;
}

/* Disabilita azioni sui subtask durante riordinamento */
.reorder-mode .subtask-item .subtask-checkbox,
.reorder-mode .subtask-item .subtask-due-date,
.reorder-mode .subtask-item .subtask-add-date,
.reorder-mode .subtask-item .subtask-add-label,
.reorder-mode .subtask-item .subtask-actions,
.reorder-mode .subtask-item .task-move-buttons {
    pointer-events: none;
    opacity: 0.5;
}

/* Permetti drag sul subtask content */
.reorder-mode .subtask-item .subtask-content {
    pointer-events: auto;
}

/* Animazione lampeggiante per pulsante riordinamento attivo */
@keyframes reorderPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.btn-icon-small.reorder-active {
    animation: reorderPulse 1.2s ease-in-out infinite;
    border-radius: 6px;
}

/* Drop target highlight for making task a subtask */
.drop-target-highlight {
    background: var(--primary-color) !important;
    opacity: 0.3;
    border: 2px dashed var(--primary-color) !important;
    box-shadow: inset 0 0 20px rgba(99, 102, 241, 0.3);
    transition: all 0.15s ease;
}

.drop-target-highlight::after {
    content: 'Rilascia per rendere sottoattività';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary-color);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
}

.task-list-drag-handle {
    cursor: grab;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
}

.task-list-drag-handle:active {
    cursor: grabbing;
}

.task-list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.task-list-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* Header that introduces the "Checklists" group in the sidebar */
.task-list-section-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 32px 8px 10px;
    padding: 16px 8px 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-top: 1px solid var(--border-color);
    opacity: 0.85;
}

.task-list-section-header svg {
    flex-shrink: 0;
    stroke: var(--primary-color);
}

/* Inline checklist icon next to a sidebar item that's in checklist mode */
.task-list-item .task-list-checklist-icon {
    margin-right: 4px;
    color: var(--primary-color);
    flex-shrink: 0;
    vertical-align: -2px;
}

/* Header button highlighted when the current list is a checklist */
.btn-icon-small.is-checklist {
    color: var(--primary-color);
}

.task-list-count {
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    white-space: nowrap;
}

/* Task list delete button */
.task-list-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-list-item:hover .task-list-delete-btn {
    opacity: 0.6;
}

.task-list-delete-btn:hover {
    opacity: 1 !important;
    background: var(--bg-hover);
}

.task-list-delete-btn svg {
    stroke: #ef4444;
}

/* Task List Color Indicator */
.task-list-color-indicator {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 8px 0 0 8px;
    flex-shrink: 0;
}

/* Task List Color Button */
.task-list-color-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-list-item:hover .task-list-color-btn {
    opacity: 0.6;
}

.task-list-color-btn:hover {
    opacity: 1 !important;
    background: var(--bg-hover);
}

.task-list-color-btn svg {
    stroke: var(--primary-color);
    fill: none;
}

/* Color Picker Grid */
.color-box {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.color-box:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.color-box.selected {
    border-color: white;
    transform: scale(1.05);
}

/* Tasks Main Area */
.tasks-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tasks-header {
    padding: 12px 30px;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tasks-header-content {
    display: flex;
    align-items: center;
}

.tasks-header h2 {
    font-size: 24px;
    color: var(--text-primary);
    font-weight: 600;
}

.tasks-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

.btn-secondary.active {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border-color: var(--primary-color);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

.tasks-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 30px;
    background: var(--bg-primary);
}

/* Custom scrollbar for tasks container */
.tasks-container::-webkit-scrollbar {
    width: 10px;
}

.tasks-container::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 5px;
}

.tasks-container::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

.tasks-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color-dark);
}

/* Firefox scrollbar */
.tasks-container {
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--bg-primary);
}

.empty-state-tasks {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    text-align: center;
}

.empty-state-tasks p {
    color: var(--text-tertiary);
    font-size: 16px;
    margin-top: 20px;
}

/* Task Item in Tasks View */
.task-item-full {
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 0;
    transition: all 0.2s;
    user-select: text; /* Permetti selezione testo di default */
    touch-action: manipulation;
}

/* Separator spacing between tasks */
.task-item-full + .task-item-full {
    margin-top: 6px;
}

.task-item-full:hover {
    border-color: var(--primary-color);
}

.task-item-full.completed {
    opacity: 0.6;
}

.task-item-full.completed .task-item-title {
    text-decoration: line-through;
}

.task-item-full {
    position: relative;
}

/* Pencil edit icon - always visible, theme-aware color */
.task-edit-pencil {
    opacity: 0.3;
    transition: opacity 0.2s;
    color: var(--text-primary);
}

.task-edit-pencil svg {
    stroke: var(--text-primary);
    fill: none;
}

.task-item-full:hover .task-edit-pencil,
.subtask-item:hover .task-edit-pencil {
    opacity: 0.5;
}

.task-edit-pencil:hover {
    opacity: 0.9;
}

/* Task inline editing */
.task-item-full.editing .task-item-content-full {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Hide notes and expandable content during editing */
.task-item-full.editing .task-item-notes,
.task-item-full.editing .task-expandable-content {
    display: none !important;
}

/* Hide non-editable elements during editing - only show editable form */
.task-item-full.editing .task-accordion-toggle,
.task-item-full.editing .task-accordion-spacer,
.task-item-full.editing .task-checkbox-large,
.task-item-full.editing .task-bookmark-btn {
    display: none !important;
}

/* Same for subtasks */
.task-subtask-item.editing .task-item-notes,
.task-subtask-item.editing .subtask-item-notes {
    display: none !important;
}

/* Hide subtask notes and non-editable elements during inline editing */
.subtask-item.editing .subtask-notes {
    display: none !important;
}

.subtask-item.editing .subtask-checkbox,
.subtask-item.editing .subtask-bookmark-btn,
.subtask-item.editing .subtask-attachments,
.subtask-item.editing .subtask-actions {
    display: none !important;
}

.task-title-edit {
    width: 100%;
    padding: 8px 12px;
    font-size: 15px;
    font-weight: 500;
    border: 2px solid var(--primary-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
}

.task-notes-edit {
    width: 100%;
    min-height: 80px;
    padding: 8px 12px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.task-notes-edit:focus {
    border-color: var(--primary-color);
    outline: none;
}

.task-edit-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-task-save,
.btn-task-cancel {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

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

.btn-task-save:hover {
    opacity: 0.9;
}

.btn-task-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-task-cancel:hover {
    background: var(--bg-hover);
}


/* Align menu button with task title */
.task-item-full .item-actions {
    display: none;
    align-items: center;
    margin-left: auto;
    gap: 6px;
}

.task-item-full:hover .item-actions,
.task-item-full.actions-visible .item-actions {
    display: flex;
}

.task-item-full.editing .item-actions {
    display: none !important;
}

/* Hide subtask actions by default, show on hover */
.subtask-item .subtask-actions {
    display: none !important;
    position: absolute;
    top: 6px;
    right: 0px;
    align-items: center;
}

.subtask-item:hover .subtask-actions,
.subtask-item.actions-visible .subtask-actions,
.task-subtask-item.editing .subtask-actions {
    display: flex !important;
}

/* Hide add label button when editing */
.task-item-full.editing .task-item-meta,
.subtask-item.editing .subtask-meta {
    display: none !important;
}

.task-item-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 0;
}

.task-checkbox-large {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-top: 5px;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    transition: all 0.2s;
    position: relative;
}

.task-checkbox-large:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.task-checkbox-large:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.task-checkbox-large:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Task Bookmark Button */
.task-bookmark-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0.3;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    margin-top: 3px;
    flex-shrink: 0;
    color: var(--text-primary);
}

.task-bookmark-btn svg {
    stroke: var(--text-primary);
}

.task-bookmark-btn:hover {
    opacity: 0.7;
    background: var(--bg-secondary);
}

.task-bookmark-btn.bookmarked {
    opacity: 1;
}

/* Evidenziazione task con segnalibro - solo bordo sinistro colorato */
.task-item-full.bookmarked {
    border: 2px solid transparent;
    border-left: 3px solid var(--bookmark-color, var(--primary-color));
    background: var(--bg-secondary);
}

.task-item-full.bookmarked:hover {
    border: 2px solid var(--bookmark-color, var(--primary-color));
    border-left-width: 3px;
}

/* Nascondi segnalibro in modalità riordino */
.reorder-mode .task-item-full .task-bookmark-btn {
    pointer-events: none;
    opacity: 0.2;
}

/* Stile segnalibro per sottoattività */
.subtask-bookmark-btn {
    padding: 0;
    margin-top: 3px;
    flex-shrink: 0;
}

/* Evidenziazione sottoattività con segnalibro */
.subtask-item.bookmarked {
    border-left: 3px solid var(--bookmark-color, var(--primary-color));
    background: var(--bg-hover);
}

.subtask-item.bookmarked:hover {
    background: var(--bg-active);
}

/* Nascondi segnalibro sottoattività in modalità riordino */
.reorder-mode .subtask-item .task-bookmark-btn {
    pointer-events: none;
    opacity: 0.2;
}

.task-item-content-full {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.task-item-title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: 0;
    word-wrap: break-word;
}

.task-item-notes {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    margin-top: 10px;
    margin-bottom: 10px;
    word-wrap: break-word;
    padding-right: 20px;
    max-width: 95%;
}

/* Paragrafi nelle note */
.task-item-notes p {
    margin: 8px 0;
}

.task-item-notes p:first-child {
    margin-top: 0;
}

.task-item-notes p:last-child {
    margin-bottom: 0;
}

/* Liste nelle note delle attività */
.task-item-notes ul,
.task-item-notes ol {
    margin: 10px 0;
    padding-left: 24px;
}

.task-item-notes ul {
    list-style-type: disc;
}

.task-item-notes ol {
    list-style-type: decimal;
}

.task-item-notes li {
    margin: 4px 0;
    padding: 0;
    line-height: 1.5;
}

.task-item-notes li::marker {
    color: var(--accent-primary);
}

/* Testo formattato */
.task-item-notes strong,
.task-item-notes b {
    color: var(--text-primary);
    font-weight: 600;
}

.task-item-notes em,
.task-item-notes i {
    font-style: italic;
}

/* Codice inline */
.task-item-notes code {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 13px;
}

/* Blocchi di codice */
.task-item-notes pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
    overflow-x: auto;
}

.task-item-notes pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
}

/* Citazioni */
.task-item-notes blockquote {
    border-left: 3px solid var(--accent-primary);
    margin: 12px 0;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.task-item-notes blockquote p {
    margin: 4px 0;
}

/* Link */
.task-item-notes a {
    color: var(--accent-primary);
    text-decoration: none;
}

.task-item-notes a:hover {
    text-decoration: underline;
}

/* Linea orizzontale */
.task-item-notes hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

/* Titoli */
.task-item-notes h1,
.task-item-notes h2,
.task-item-notes h3,
.task-item-notes h4 {
    color: var(--text-primary);
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.task-item-notes h1:first-child,
.task-item-notes h2:first-child,
.task-item-notes h3:first-child,
.task-item-notes h4:first-child {
    margin-top: 0;
}

.task-item-notes h1 { font-size: 1.4em; }
.task-item-notes h2 { font-size: 1.25em; }
.task-item-notes h3 { font-size: 1.1em; }
.task-item-notes h4 { font-size: 1em; }

/* Note delle sottoattività - stessi stili delle note principali */
.subtask-notes {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.subtask-notes p {
    margin: 6px 0;
}

.subtask-notes p:first-child {
    margin-top: 0;
}

.subtask-notes p:last-child {
    margin-bottom: 0;
}

.subtask-notes ul,
.subtask-notes ol {
    margin: 8px 0;
    padding-left: 20px;
}

.subtask-notes ul {
    list-style-type: disc;
}

.subtask-notes ol {
    list-style-type: decimal;
}

.subtask-notes li {
    margin: 3px 0;
    padding: 0;
    line-height: 1.4;
}

.subtask-notes li::marker {
    color: var(--accent-primary);
}

.subtask-notes strong,
.subtask-notes b {
    color: var(--text-primary);
    font-weight: 600;
}

.subtask-notes em,
.subtask-notes i {
    font-style: italic;
}

.subtask-notes code {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 12px;
}

.subtask-notes pre {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 12px;
    margin: 10px 0;
    overflow-x: auto;
}

.subtask-notes pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.subtask-notes blockquote {
    border-left: 2px solid var(--accent-primary);
    margin: 10px 0;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border-radius: 0 6px 6px 0;
    font-style: italic;
}

.subtask-notes a {
    color: var(--accent-primary);
    text-decoration: none;
}

.subtask-notes a:hover {
    text-decoration: underline;
}

/* Task Labels Badges */
.task-labels-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
    margin-top: 4px;
}

.task-label-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.task-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.task-add-label {
    cursor: pointer;
    opacity: 0.5;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 15px;
}

.task-add-label:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.task-add-label svg {
    flex-shrink: 0;
}

.task-due-date,
.task-add-date {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 15px;
    color: var(--text-secondary);
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.task-add-date {
    cursor: pointer;
    opacity: 0.6;
}

.task-add-date:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.task-due-date {
    cursor: pointer;
}

.task-due-date:hover {
    background: var(--bg-hover);
}

.task-due-date svg,
.task-add-date svg {
    flex-shrink: 0;
}

.task-due-date.overdue {
    color: #ef4444;
    font-weight: 600;
}

/* Date Picker Dropdown */
.date-picker-dropdown {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    padding: 16px;
    min-width: 280px;
    max-width: 320px;
}

.date-picker-header {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.date-picker-quick-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.date-picker-option {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 14px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    font-size: 14px;
}

.date-picker-option:hover {
    background: var(--primary-color);
    color: var(--primary-text-color);
    border-color: var(--primary-color);
}

.date-picker-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 12px;
    margin: 12px 0;
    position: relative;
}

.date-picker-divider::before,
.date-picker-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-color);
}

.date-picker-divider::before {
    left: 0;
}

.date-picker-divider::after {
    right: 0;
}

.date-picker-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 12px;
}

.date-picker-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.date-picker-actions {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.date-picker-btn-cancel,
.date-picker-btn-clear {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.date-picker-btn-cancel {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.date-picker-btn-cancel:hover {
    background: var(--bg-primary);
}

.date-picker-btn-clear {
    background: #d32f2f;
    border: 1px solid #d32f2f;
    color: white;
}

.date-picker-btn-clear:hover {
    background: #b71c1c;
    border-color: #b71c1c;
}

/* Mini Calendar */
.mini-calendar-container {
    margin: 12px 0;
}

.mini-calendar {
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 12px;
}

.mini-calendar-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mini-cal-prev,
.mini-cal-next {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mini-cal-prev:hover,
.mini-cal-next:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.mini-cal-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.mini-calendar-grid {
    width: 100%;
}

.mini-cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
}

.mini-cal-header span {
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 4px 0;
}

.mini-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.mini-cal-day {
    text-align: center;
    padding: 6px 2px;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.mini-cal-day:not(.empty):hover {
    background: var(--primary-color);
    color: white;
}

.mini-cal-day.empty {
    cursor: default;
}

.mini-cal-day.today {
    background: var(--bg-secondary);
    font-weight: 700;
    border: 1px solid var(--primary-color);
}

.mini-cal-day.selected {
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.mini-cal-day.past {
    color: var(--text-secondary);
    opacity: 0.6;
}

.mini-cal-day.past:hover {
    opacity: 1;
}

.task-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
}

.task-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.task-attachment:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.task-attachment svg {
    color: var(--primary-color);
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.task-attachment-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Attachment remove button */
.task-attachment-wrapper:hover .remove-attachment-btn {
    display: flex !important;
}

.remove-attachment-btn:hover {
    background: #b71c1c !important;
    transform: scale(1.1);
}

/* Subtasks */
.subtasks-container {
    margin-left: 0;
    margin-top: 14px;
    margin-right: 40px;
    border-left: 3px solid var(--border-color);
    padding-left: 14px;
    padding-top: 4px;
    transition: border-left-color 0.2s;
}

/* Highlight subtasks-container border when hovering over any subtask */
.subtasks-container:has(.subtask-item:hover) {
    border-left-color: var(--primary-color);
}

.subtask-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 10px;
    position: relative;
    border-radius: 6px;
    background: var(--bg-tertiary);
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
    transition: background 0.2s, border-color 0.2s;
    touch-action: manipulation;
}

.subtask-item:last-child {
    margin-bottom: 0;
}

.subtask-item:hover {
    border-color: var(--primary-color);
}

/* Subtask attachments */
.subtask-attachments {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}

.subtask-attachment {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    font-size: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.subtask-attachment:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.subtask-attachment svg {
    color: var(--primary-color);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.subtask-attachment span {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.subtask-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin-top: 4px;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--border-color);
    border-radius: 3px;
    background: var(--bg-primary);
    transition: all 0.2s;
    position: relative;
}

.subtask-checkbox:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.subtask-checkbox:checked {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.subtask-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 0px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.subtask-title {
    flex: 1;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

/* Rimossa evidenziazione hover sul titolo subtask */

.subtask-item.completed .subtask-title {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.subtask-delete-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0;
    transition: opacity 0.2s;
    border-radius: 4px;
}

.subtask-item:hover .subtask-delete-btn {
    opacity: 0.6;
}

.subtask-delete-btn:hover {
    opacity: 1 !important;
    background: var(--bg-hover);
}

.subtask-delete-btn svg {
    stroke: #ef4444;
}

/* Subtask content wrapper */
.subtask-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Subtask collapsed/expanded states */
/* Keep labels and meta (date/labels buttons) always visible (except when editing) */
.subtask-item:not(.editing) .subtask-meta,
.subtask-item:not(.editing) .task-labels-container {
    display: flex !important;
}

/* Hide only notes when collapsed - attachments are always visible */
.subtask-item.subtask-collapsed .subtask-notes {
    display: none !important;
}

.subtask-item:not(.editing) .subtask-attachments {
    display: flex !important;
}

.subtask-item.subtask-expanded:not(.editing) .subtask-notes {
    display: block !important;
}

/* During inline editing, hide all non-editable subtask elements */
.subtask-item.editing .subtask-meta,
.subtask-item.editing .subtask-notes,
.subtask-item.editing .subtask-attachments,
.subtask-item.editing .task-labels-container {
    display: none !important;
}

/* Subtask meta container (labels and date buttons) */
.subtask-meta {
    margin-top: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.subtask-add-label {
    cursor: pointer;
    font-size: 15px;
    opacity: 0.5;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s;
}

.subtask-add-label:hover {
    opacity: 1;
    background: var(--bg-hover);
}

.subtask-add-label svg {
    flex-shrink: 0;
}

/* Subtask date styling */
.subtask-due-date,
.subtask-add-date {
    font-size: 15px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 4px;
    border-radius: 3px;
    width: fit-content;
    transition: all 0.2s;
}

.subtask-due-date:hover,
.subtask-add-date:hover {
    background: var(--bg-hover);
}

.subtask-due-date.overdue {
    color: #ef4444;
}

/* Add subtask button */
.add-subtask-btn {
    background: transparent;
    border: 1px dashed var(--border-color);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}

.add-subtask-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.add-subtask-btn svg {
    stroke: currentColor;
}

/* Accordion Task Styles */
.task-item-full.collapsed {
    cursor: pointer;
}

.task-item-full.collapsed .task-expandable-content {
    display: none;
}

.task-item-full.collapsed:hover {
    border-color: var(--primary-color);
}

.task-accordion-toggle {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    transition: all 0.3s;
}

.task-accordion-toggle:hover {
    background: var(--bg-tertiary);
}

.task-expandable-content {
    animation: slideDown 0.3s ease-out;
    margin-left: 72px; /* Align with task title (checkbox 20px + gap 12px + bookmark 28px + gap 12px) */
}

/* For tasks with accordion toggle or spacer, add extra margin */
.task-item-full:has(.task-accordion-toggle) .task-expandable-content,
.task-item-full:has(.task-accordion-spacer) .task-expandable-content {
    margin-left: 130px; /* Adjust for toggle/spacer + checkbox + bookmark + gaps */
}

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

/* Subtask inline editing */
.subtask-item.editing {
    flex-direction: row;
    align-items: flex-start;
}

.subtask-edit-form {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.subtask-title-edit {
    width: 100%;
    padding: 6px 10px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
}

.subtask-notes-edit {
    width: 100%;
    min-height: 60px;
    padding: 6px 10px;
    font-size: 13px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
}

.subtask-notes-edit:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Template Card */
.template-card {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--primary-color);
}

.template-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.template-card-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

.template-card-description {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 10px;
}

.template-card-actions {
    display: flex;
    gap: 8px;
}

.btn-template-action {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--bg-hover);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.btn-template-action:hover {
    background: var(--bg-active);
}

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

.btn-template-edit:hover {
    background: var(--primary-color-darker);
}

.btn-template-delete {
    background: #ef4444;
    color: white;
}

.btn-template-delete:hover {
    background: #dc2626;
}

/* Mobile floating button for lists */
.mobile-lists-btn {
    display: none;
}

@media (max-width: 768px) {
    .mobile-lists-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        cursor: pointer;
        z-index: 999;
        transition: all 0.3s;
    }

    .mobile-lists-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 6px 16px rgba(0,0,0,0.4);
    }

    .mobile-lists-btn:active {
        transform: scale(0.95);
    }
}

/* Mobile sidebar overlay */
.mobile-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Mobile Responsive for Tasks View */
@media (max-width: 768px) {
    .tasks-view {
        flex-direction: column;
    }

    .tasks-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 350px;
        height: 100vh;
        z-index: 1000;
        border-right: 2px solid var(--border-color);
        border-bottom: none;
        transition: left 0.3s ease;
        overflow-y: auto;
        max-height: none;
    }

    .tasks-sidebar.mobile-open {
        left: 0;
    }

    .tasks-header h2 {
        font-size: 20px;
    }

    .tasks-container {
        padding: 15px;
    }

    .view-switcher {
        margin: 0;
        padding: 0;
    }
}

/* ========================================
   Fine Tasks View CSS
   ======================================== */

/* ========================================
   Toast Notification
   ======================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    max-width: 500px;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
}

.toast.warning {
    border-left-color: #f59e0b;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.success {
    border-left-color: var(--success-color);
}

.toast.info {
    border-left-color: #3b82f6;
}

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

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

.toast.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* Banner suggerimento Add to Home Screen per mobile */
.mobile-home-banner {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    display: none;
    align-items: center;
    gap: 12px;
}

.mobile-home-banner.show {
    display: flex;
}

.mobile-home-banner-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-home-banner-icon svg {
    stroke: var(--text-primary);
}

.mobile-home-banner-text {
    flex: 1;
}

.mobile-home-banner-text h4 {
    margin: 0 0 4px 0;
    color: var(--text-primary);
    font-size: 14px;
}

.mobile-home-banner-text p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.mobile-home-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.mobile-home-banner-btn {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.mobile-home-banner-btn.primary {
    background: var(--primary-color);
    color: white;
}

.mobile-home-banner-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

@media (min-width: 769px) {
    .mobile-home-banner {
        display: none !important;
    }
}

/* ============================================
   Empty State "Tutto Fatto" - Completed View
   ============================================ */

.empty-state-done {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 80px;
    text-align: center;
    width: 100%;
    gap: 8px;
    animation: emptyStateFadeIn 0.6s ease-out;
}

.empty-state-done-illustration {
    position: relative;
    margin-bottom: 12px;
}

.empty-state-done-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 420px;
}

.empty-state-done-title {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.5px;
}

.empty-state-done-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.5;
}

.empty-state-done-motivation {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0;
    font-style: italic;
    line-height: 1.5;
}

.empty-state-done-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.empty-state-done-actions .btn {
    font-size: 15px;
    padding: 12px 28px;
}

/* Animazioni SVG empty state */

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

@keyframes emptyStateCheckDraw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes emptyStateCircleDraw {
    to {
        stroke-dashoffset: 0;
    }
}

@keyframes emptyStateRingSpin {
    from {
        transform-origin: center;
        transform: rotate(0deg);
    }
    to {
        transform-origin: center;
        transform: rotate(360deg);
    }
}

@keyframes emptyStateFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-6px);
    }
}

@keyframes emptyStateParticlePulse {
    0%, 100% {
        opacity: 0.2;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.4);
    }
}

.empty-state-check-circle {
    animation: emptyStateCircleDraw 0.8s ease-out 0.3s forwards;
}

.empty-state-checkmark {
    animation: emptyStateCheckDraw 0.5s ease-out 0.8s forwards;
}

.empty-state-ring-outer {
    animation: emptyStateRingSpin 30s linear infinite;
}

.empty-state-ring-middle {
    animation: emptyStateRingSpin 20s linear infinite reverse;
}

.empty-state-done-illustration {
    animation: emptyStateFloat 4s ease-in-out infinite;
}

.empty-state-particle {
    animation: emptyStateParticlePulse 3s ease-in-out infinite;
}

.empty-state-particle:nth-child(odd) {
    animation-delay: 0.5s;
}

.empty-state-particle:nth-child(3n) {
    animation-delay: 1s;
}

.empty-state-particle:nth-child(4n) {
    animation-delay: 1.5s;
}

/* Responsive empty state */
@media (max-width: 768px) {
    .empty-state-done {
        padding: 40px 16px 60px;
    }

    .empty-state-done-illustration svg {
        width: 140px;
        height: 140px;
    }

    .empty-state-done-title {
        font-size: 26px;
    }

    .empty-state-done-subtitle {
        font-size: 15px;
    }

    .empty-state-done-motivation {
        font-size: 13px;
    }
}
