/* ══════════════════════════════════════
   KANBAN BOARD – To-Do Liste
   ══════════════════════════════════════ */

/* ── Back Button (inline in header) ── */
.kanban-back-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-grey);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.35rem 0.7rem;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.2s, color 0.2s, transform 0.15s;
    white-space: nowrap;
}

.kanban-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    transform: translateX(-2px);
}

.kanban-back-btn i {
    font-size: 0.75rem;
}

.kanban-profile-area {
    display: flex;
    align-items: center;
}

/* ── Layout (override global _layout.css) ── */
main {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 0.5rem !important;
    padding: 0.75rem 1.5rem !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Header ── */
.kanban-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    flex-shrink: 0;
    gap: 1rem;
}

.kanban-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.kanban-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.kanban-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.kanban-add-col-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    padding: 0.4rem 0.9rem;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background 0.2s, transform 0.2s;
    white-space: nowrap;
}

.kanban-add-col-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-2px);
}

/* ── Board ── */
.kanban-board {
    display: flex;
    gap: 1rem;
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.5rem;
    scroll-behavior: smooth;
}

/* scrollbar */
.kanban-board::-webkit-scrollbar {
    height: 6px;
}

.kanban-board::-webkit-scrollbar-track {
    background: transparent;
}

.kanban-board::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}

/* ── Column ── */
.kanban-column {
    position: relative;
    min-width: 280px;
    max-width: 320px;
    flex: 0 0 280px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--card-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 180px);
    transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.kanban-column.drag-over {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(162, 76, 255, 0.25), 0 10px 30px rgba(0, 0, 0, 0.3);
}

.kanban-column.col-dragging {
    opacity: 0.4;
    transform: scale(0.97);
}

/* Column drop indicator (vertical line between columns) */
.col-drop-indicator {
    width: 3px;
    min-height: 100px;
    background: var(--primary);
    border-radius: 2px;
    flex-shrink: 0;
    align-self: stretch;
}

/* ── Column Header ── */
.kanban-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.kanban-col-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    margin: -0.15rem -0.4rem;
    transition: border-color 0.2s;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.kanban-col-title:hover {
    border-color: rgba(255, 255, 255, 0.2);
}

.kanban-col-title-input {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    margin: -0.15rem -0.4rem;
    outline: none;
    flex: 1;
    min-width: 0;
    font-family: inherit;
}

.kanban-col-count {
    font-size: 0.75rem;
    color: var(--text-grey);
    background: rgba(255, 255, 255, 0.06);
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.kanban-col-delete {
    background: none;
    border: none;
    color: var(--text-grey);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.2rem 0.4rem;
    margin-left: 0.3rem;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.kanban-col-delete:hover {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.1);
}

/* ── Task List (scrollable) ── */
.kanban-tasks {
    flex: 1;
    overflow-y: auto;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 40px;
}

.kanban-tasks::-webkit-scrollbar {
    width: 4px;
}

.kanban-tasks::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
}

/* drop placeholder */
.kanban-tasks.drag-active {
    min-height: 60px;
}

/* ── Task Card ── */
.kanban-task {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.65rem 0.75rem;
    cursor: grab;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s, border-color 0.15s;
    user-select: none;
}

.kanban-task:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.kanban-task:active {
    cursor: grabbing;
}

.kanban-task.dragging {
    opacity: 0.4;
    transform: scale(0.96);
}

.kanban-task-text {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
}

.kanban-task-text-input {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--primary);
    border-radius: 6px;
    padding: 0.15rem 0.4rem;
    outline: none;
    font-family: inherit;
    resize: none;
    min-height: 1.8rem;
}

.kanban-task-delete {
    background: none;
    border: none;
    color: var(--text-grey);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    transition: color 0.2s;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.kanban-task:hover .kanban-task-delete {
    opacity: 1;
}

.kanban-task-delete:hover {
    color: #ff4d4d;
}

/* ── Add Task (bottom of column) ── */
.kanban-add-task {
    padding: 0.5rem 0.6rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.kanban-add-task-form {
    display: flex;
    gap: 0.4rem;
}

.kanban-add-task-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-color);
    padding: 0.4rem 0.6rem;
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.kanban-add-task-input::placeholder {
    color: var(--text-grey);
    font-size: 0.8rem;
}

.kanban-add-task-input:focus {
    border-color: var(--primary);
}

.kanban-add-task-btn {
    background: var(--primary);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: transform 0.15s, opacity 0.15s;
    flex-shrink: 0;
}

.kanban-add-task-btn:hover {
    transform: scale(1.08);
}

/* ── Drop Indicator ── */
.drop-indicator {
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
    margin: -0.1rem 0;
    transition: opacity 0.15s;
}

/* ── Sync Indicator (reused) ── */
.sync-indicator {
    font-size: 1rem;
    opacity: 0.6;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.sync-indicator.synced {
    color: #4ade80;
    opacity: 0.8;
}

.sync-indicator.syncing {
    color: var(--primary);
    opacity: 1;
}

.sync-indicator.syncing i {
    animation: spin-sync 1s linear infinite;
}

.sync-indicator.offline {
    color: var(--text-grey);
    opacity: 0.5;
    position: relative;
}

.sync-indicator.offline::after {
    content: '';
    position: absolute;
    left: -1px;
    top: 50%;
    width: calc(100% + 2px);
    height: 2px;
    background: var(--text-grey);
    transform: rotate(-45deg);
}

@keyframes spin-sync {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ── Confirm Modal ── */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-dialog {
    padding: 1.5rem 2rem;
    text-align: center;
    max-width: 340px;
    width: 90%;
}

.confirm-dialog p {
    margin-bottom: 1.2rem;
    font-size: 1rem;
}

.confirm-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.confirm-actions .btn {
    min-width: 90px;
}

.btn-danger {
    background-color: #e74c3c !important;
    border-color: #c0392b !important;
    color: #fff;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    html, body {
        height: auto;
        overflow-y: auto;
    }

    main {
        padding: 0.5rem;
        height: auto;
        overflow: visible;
    }

    .kanban-board {
        flex-direction: column;
        flex: none;
        overflow-x: hidden;
        overflow-y: visible;
        height: fit-content;
        padding-bottom: 2rem;
        align-items: stretch;
    }

    .kanban-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .kanban-header h2 {
        font-size: 1.2rem;
    }

    .kanban-column {
        min-width: 100%;
        max-width: 100%;
        flex: none;
        max-height: none;
        height: fit-content;
    }

    .kanban-tasks {
        flex: none;
        height: fit-content;
        max-height: none;
        overflow-y: visible;
    }

    /* Hide resize handles on mobile */
    .kanban-col-resize-handle {
        display: none;
    }
}

@media (max-width: 480px) {
    .kanban-header-left {
        width: 100%;
        justify-content: space-between;
    }

    .kanban-back-btn span {
        display: none;
    }

    #add-column-btn span {
        display: none;
    }

    .kanban-list-selector {
        flex: 1;
        justify-content: center;
    }

    .kanban-list-title-input {
        width: 100%;
        font-size: 1.1rem;
    }

    .kanban-task-delete {
        opacity: 1;
    }

    .kanban-add-task-btn {
        min-width: 44px;
        min-height: 44px;
    }

    .settings-dialog {
        max-height: 85dvh;
        overflow-y: auto;
    }

    .kanban-header-actions {
        gap: 0.4rem;
    }
}

/* ── Task Content Wrapper ── */
.kanban-task-content {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    width: 100%;
}

/* ── Links within Tasks ── */
.kanban-task-text a {
    color: #a29bfe;
    text-decoration: underline;
    position: relative;
    z-index: 10;
    /* Ensure links are clickable above the task click handler */
}

.kanban-task-text a:hover {
    color: #ffffff;
}

/* ── Subtasks Container ── */
.kanban-task {
    flex-direction: column;
    /* Stack content and subtasks */
    gap: 0;
}

.kanban-subtasks {
    width: 100%;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    animation: slideDown 0.2s ease-out;
}

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

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

/* ── Subtask List ── */
.subtask-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.85);
}

.subtask-item input[type="checkbox"] {
    appearance: none;
    width: 14px;
    height: 14px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.subtask-item input[type="checkbox"]:checked {
    background: var(--primary);
    border-color: var(--primary);
}

.subtask-item input[type="checkbox"]:checked::after {
    content: '✔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    color: white;
}

.subtask-text {
    flex: 1;
    word-break: break-word;
    transition: color 0.2s, text-decoration 0.2s;
}

.subtask-text.completed {
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.4);
}

.subtask-delete {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 0.1rem;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
}

.subtask-item:hover .subtask-delete {
    opacity: 1;
}

.subtask-delete:hover {
    color: #ff4d4d;
}

/* ── Add Subtask Form ── */
.subtask-add-form {
    display: flex;
    gap: 0.3rem;
    margin-top: 0.2rem;
}

.subtask-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    outline: none;
}

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

.subtask-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.subtask-add-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: background 0.2s;
}

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

/* ── Resize Handle ── */
.kanban-col-resize-handle {
    position: absolute;
    top: 0;
    right: -5px;
    width: 10px;
    height: 100%;
    cursor: ew-resize;
    z-index: 10;
    display: flex;
    justify-content: center;
}

.kanban-col-resize-handle:hover::after {
    content: '';
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.3);
}

/* ── List Dropdown ── */
.kanban-list-selector {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.kanban-list-btn {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0.5rem;
    border-radius: 8px;
    transition: background 0.2s;
}

.kanban-list-btn:hover {
    background: rgba(255, 255, 255, 0.08);
}

.kanban-list-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: 12px;
    min-width: 220px;
    margin-top: 0.5rem;
    padding: 0.5rem;
    display: none;
    flex-direction: column;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: fadeIn 0.2s ease;
}

.kanban-list-dropdown.show {
    display: flex;
}

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

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

.kanban-list-item {
    padding: 0.6rem 0.8rem;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.kanban-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.kanban-list-item.active {
    background: rgba(162, 76, 255, 0.15);
    background: rgba(var(--primary-rgb, 162, 76, 255), 0.15);
    color: var(--primary);
}

.kanban-list-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0.3rem 0;
}

.kanban-list-add {
    color: var(--primary);
    font-weight: 600;
}

.kanban-list-title-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0 0.4rem;
    outline: none;
    width: auto;
    min-width: 100px;
}

/* ── Settings Button ── */
.kanban-settings-btn {
    background: none;
    border: none;
    color: var(--text-grey);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s, transform 0.2s;
    margin-left: 0.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kanban-settings-btn:hover {
    color: var(--text-color);
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(30deg);
}

/* ── Settings Modal Customization ── */
.settings-dialog {
    width: 95%;
    max-width: 500px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.settings-dialog h3 {
    margin: 0;
    font-size: 1.2rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.settings-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.settings-group label {
    font-size: 0.85rem;
    color: var(--text-grey);
    font-weight: 500;
}

.settings-input,
.settings-select {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-color);
    padding: 0.6rem;
    border-radius: 8px;
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.settings-input:focus,
.settings-select:focus {
    border-color: var(--primary);
}

.settings-select option {
    background: #2d3436;
    /* Fallback dark bg */
    color: white;
}

/* ── Color Swatches ── */
.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.1);
}

.color-swatch.active {
    border-color: white;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Custom Color Picker Styling */
.custom-color-wrapper {
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    overflow: hidden;
}

.custom-color-wrapper i {
    pointer-events: none;
    font-size: 0.9rem;
}

.custom-color-wrapper input[type="color"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
    top: 0;
    left: 0;
}

/* ── Font Settings Classes ── */
body.font-serif {
    font-family: 'Merriweather', 'Georgia', serif !important;
}

body.font-serif .kanban-header h2,
body.font-serif button,
body.font-serif input,
body.font-serif select,
body.font-serif textarea {
    font-family: 'Merriweather', 'Georgia', serif !important;
}

body.font-mono {
    font-family: 'Fira Code', 'Courier New', monospace !important;
    letter-spacing: -0.5px;
}

body.font-mono .kanban-header h2,
body.font-mono button,
body.font-mono input,
body.font-mono select,
body.font-mono textarea {
    font-family: 'Fira Code', 'Courier New', monospace !important;
}

body.font-cursive {
    font-family: 'Patrick Hand', 'Comic Sans MS', cursive !important;
}

body.font-cursive .kanban-header h2,
body.font-cursive button,
body.font-cursive input,
body.font-cursive select,
body.font-cursive textarea {
    font-family: 'Patrick Hand', 'Comic Sans MS', cursive !important;
}