:root {
    /* Color Palette - Vibrant Sky Blue */
    --primary: #009dff;
    --primary-light: rgba(0, 157, 255, 0.12);
    --primary-medium: rgba(0, 157, 255, 0.2);
    --primary-dark: #007acd;
    --accent: #00d4ff;

    --bg-app: #f0f7fc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-column: rgba(224, 240, 255, 0.65);

    --text-main: #0b1a30;
    --text-secondary: #263c5a;
    --text-muted: #5e7696;
    --text-light: #8b9fb6;

    --border-color: #dbeafe;
    --border-light: #eff6ff;
    --shadow-sm: 0 2px 4px rgba(0, 106, 255, 0.04);
    --shadow-md: 0 6px 16px rgba(0, 106, 255, 0.06);
    --shadow-lg: 0 16px 32px rgba(0, 106, 255, 0.08);

    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Colori di stato molto saturi e vivaci */
    --status-todo: #f59e0b;
    /* Giallo/Ambra vivace */
    --status-in-progress: #009dff;
    /* Azzurro cielo saturo */
    --status-completed: #10b981;
    /* Verde smeraldo brillante */

    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Sora', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-app);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    display: flex;
    height: 100vh;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: var(--space-xl) var(--space-lg);
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    position: relative;
}

.logo-icon::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 11px;
    height: 11px;
    background: white;
    border-radius: 2px;
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.section-header h2 {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-light);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.projects-list {
    list-style: none;
    margin-top: var(--space-xs);
}

/* ===================== PROJECT ITEMS ===================== */
.project-item {
    border-radius: var(--radius-sm);
    cursor: grab;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-secondary);
    margin-bottom: 2px;
    padding: 4px 6px;
    font-size: 0.88rem;
}

.project-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    color: var(--text-light);
    padding: 2px;
    border-radius: 4px;
    transition: all 0.15s;
    flex-shrink: 0;
    touch-action: none;
    opacity: 0.35;
}

.project-item:hover .project-drag-handle {
    opacity: 1;
}

.project-drag-handle:hover {
    color: var(--primary);
}

.project-drag-handle i {
    width: 14px;
    height: 14px;
}

.project-item.project-dragging {
    opacity: 0.3;
}

.project-item.drag-insert-above {
    position: relative;
}

.project-item.drag-insert-above::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(0, 157, 255, 0.4);
    z-index: 5;
}

.project-item.drag-insert-below {
    position: relative;
}

.project-item.drag-insert-below::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(0, 157, 255, 0.4);
    z-index: 5;
}

.project-priority {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 700;
    background: var(--border-light);
    color: var(--text-light);
    flex-shrink: 0;
}

.project-priority.priority-1 {
    background: linear-gradient(135deg, #00d4ff, #009dff);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(0, 157, 255, 0.4);
}

.project-priority.priority-2 {
    background: linear-gradient(135deg, #3b82f6, #007acd);
    color: #ffffff;
}

.project-priority.priority-3 {
    background: linear-gradient(135deg, #64748b, #263c5a);
    color: #ffffff;
}

.project-link {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    min-width: 0;
}

.project-link span {
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.3;
}

.project-item-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.project-item:hover .project-item-actions {
    opacity: 1;
}

.project-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.project-item.active {
    background-color: var(--primary-medium);
    color: var(--primary);
    font-weight: 600;
}

.project-item i {
    width: 16px;
    height: 16px;
}

/* ===================== MAIN CONTENT ===================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-xl) 2.5rem;
    overflow-y: auto;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
}

#active-project-name {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text-main);
}

.project-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ===================== KANBAN BOARD ===================== */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-lg);
    flex: 1;
}

.column {
    background-color: var(--bg-column);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    padding: var(--space-md);
    min-height: 400px;
    transition: background-color 0.2s ease, border 0.2s ease;
    border: 2px dashed transparent;
}

.column.drag-over {
    background-color: var(--primary-light);
    border-color: var(--primary);
}

.column-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: var(--space-md);
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border-color);
}

.column-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}

.count {
    background: var(--bg-card);
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.status-dot.todo {
    background-color: var(--status-todo);
}

.status-dot.in-progress {
    background-color: var(--status-in-progress);
}

.status-dot.completed {
    background-color: var(--status-completed);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    flex: 1;
}

/* ===================== TASK CARD ===================== */
.task-card {
    background: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    cursor: grab;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s, border-color 0.15s;
    position: relative;
    user-select: none;
}

.task-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.task-card.dragging {
    opacity: 0.3;
    cursor: grabbing;
}

.task-card h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
}

.task-header {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.task-priority {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 1px;
}

.task-card.drag-insert-above {
    position: relative;
}

.task-card.drag-insert-above::before {
    content: '';
    position: absolute;
    top: calc(-0.3rem - 1px);
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.task-card.drag-insert-below {
    position: relative;
}

.task-card.drag-insert-below::after {
    content: '';
    position: absolute;
    bottom: calc(-0.3rem - 1px);
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 1px;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
}

.task-card p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.task-actions {
    margin-top: 0.75rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1.15rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
    background: white;
    transition: all 0.15s;
    color: var(--text-secondary);
}

.btn:hover:not(:disabled) {
    background-color: var(--bg-app);
}

.btn.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}

.btn.primary-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

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

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 5px;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.edit-task-btn {
    color: var(--primary);
}

.edit-task-btn:hover {
    background: var(--primary-light);
}

.task-move-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 7px;
    font-size: 0.75rem;
    border-radius: 5px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 26px;
    min-height: 26px;
}

.task-move-btn:hover {
    background: var(--primary);
    color: white;
}

.task-move-btn i {
    width: 13px;
    height: 13px;
}

.delete-btn {
    color: #ef4444 !important;
}

.delete-btn:hover {
    background: #fef2f2 !important;
    color: #dc2626 !important;
}

/* ===================== MODALS ===================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(6px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: var(--space-xl);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from {
        transform: scale(0.96);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal h3 {
    margin-bottom: var(--space-lg);
    font-size: 1.15rem;
    color: var(--text-main);
}

.modal input,
.modal textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-md);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    color: var(--text-main);
}

.modal input:focus,
.modal textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.modal textarea {
    height: 90px;
    resize: none;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ===================== ANIMATIONS ===================== */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Touch Drag Clone */
.touch-drag-clone {
    border: 2px solid var(--primary) !important;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.25) !important;
    transform: rotate(1.5deg) scale(1.02);
    transition: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================== MOBILE TOP BAR ===================== */
.mobile-top-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.mobile-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.mobile-logo span {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
}

.mobile-top-spacer {
    width: 36px;
}

.mobile-menu-btn {
    background: none;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.mobile-menu-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.35);
    backdrop-filter: blur(3px);
    z-index: 9;
}

.sidebar-overlay.active {
    display: block;
}

/* Close sidebar button - hidden on desktop */
.close-sidebar-btn {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

/* ===================== RESPONSIVE ===================== */

/* Tablet (< 1024px) */
@media (max-width: 1024px) {
    .main-content {
        padding: var(--space-lg);
    }

    .kanban-board {
        gap: var(--space-md);
    }

    #active-project-name {
        font-size: 1.5rem;
    }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    body {
        overflow-y: auto;
        overflow-x: hidden;
        height: auto;
    }

    #app {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .mobile-top-bar {
        display: flex;
    }

    .close-sidebar-btn {
        display: flex;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        height: 100vh;
        height: 100dvh;
        width: 280px;
        transition: left 0.3s ease;
        box-shadow: none;
        z-index: 50;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
        box-shadow: var(--shadow-lg);
    }

    .top-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        margin-bottom: var(--space-md);
        padding-top: 0;
    }

    .main-content {
        padding: 0.75rem;
        padding-top: 4.5rem;
    }

    .current-project-info {
        min-width: 0;
    }

    #active-project-name {
        font-size: 1.1rem;
        overflow-wrap: break-word;
    }

    .user-actions {
        width: 100%;
    }

    .user-actions .btn {
        width: 100%;
        justify-content: center;
        padding: 0.65rem;
        font-size: 0.88rem;
    }

    .kanban-board {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        flex: none;
    }

    .column {
        min-height: auto;
        padding: 0.75rem;
        border-radius: var(--radius-md);
    }

    .column-header {
        margin-bottom: 0.6rem;
        padding-bottom: 0.5rem;
    }

    .task-card {
        padding: 0.75rem;
    }

    .task-card h4 {
        font-size: 0.82rem;
    }

    .task-card p {
        font-size: 0.75rem;
    }

    .task-actions {
        margin-top: 0.5rem;
    }

    .task-list {
        gap: 0.5rem;
    }

    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
        padding: var(--space-lg);
    }

    .modal h3 {
        font-size: 1.05rem;
        margin-bottom: var(--space-md);
    }

    .modal input,
    .modal textarea {
        font-size: 16px;
        /* Forza 16px su mobile per NON far zoomare iOS */
        padding: 0.6rem;
    }

    .modal textarea {
        height: 70px;
    }

    .project-item-actions {
        opacity: 1;
    }

    .project-drag-handle {
        opacity: 0.6;
    }

    .task-card:hover {
        transform: none;
    }

    .task-move-btn {
        min-width: 34px;
        min-height: 34px;
        padding: 5px 9px;
        border-radius: 7px;
    }

    .task-move-btn i {
        width: 15px;
        height: 15px;
    }

    .task-actions {
        gap: 0.3rem;
        flex-wrap: wrap;
    }

    .sidebar-footer {
        margin-top: auto;
        padding-top: 1rem;
    }
}

/* Small mobile (< 400px) */
@media (max-width: 400px) {
    .top-bar {
        padding-top: 3.5rem;
    }

    #active-project-name {
        font-size: 1rem;
    }

    .project-priority {
        width: 20px;
        height: 20px;
        font-size: 0.65rem;
    }

    .user-actions .btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
}