* {
    box-sizing: border-box;
}

/* --- Variables & Thèmes --- */
:root {
    --bg-color: #121212;
    --text-color: #f1f1f1;
    --header-bg: #1e1e1e;
    --border-color: #333;
    --card-bg: #1e1e1e;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --accent-color: #007bff;
    --primary-color: #1a73e8;
    --danger-color: #ef4444;
}

body.light-mode {
    --bg-color: #f4f7f6;
    --text-color: #333;
    --header-bg: #ffffff;
    --border-color: #e0e0e0;
    --card-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.05);
}

/* Custom Checkbox */
input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    background-color: var(--bg-color);
    margin: 0;
    font: inherit;
    color: currentColor;
    width: 1.15em;
    height: 1.15em;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    /* Rounded corners */
    display: grid;
    place-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="checkbox"]::before {
    content: "";
    width: 0.65em;
    height: 0.65em;
    transform: scale(0);
    transition: 120ms transform ease-in-out;
    box-shadow: inset 1em 1em white;
    transform-origin: center;
    clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}

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

input[type="checkbox"]:checked::before {
    transform: scale(1);
}

.danger-text {
    color: var(--danger-color) !important;
}

/* --- Styles de Base et Header --- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 0.5rem;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.2s ease;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

header h1:hover {
    color: var(--primary-color);
}

.edit-icon {
    font-size: 1.1rem;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--primary-color);
}

header h1:hover .edit-icon {
    opacity: 0.7;
}

header h1:active .edit-icon {
    transform: scale(0.9);
}

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

button,
.io-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    font-size: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-sizing: border-box;
    vertical-align: middle;
    line-height: 1;
    transition: all 0.2s ease;
}

button:hover,
.io-btn:hover {
    background-color: var(--border-color);
}

.icon-only-btn {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    border-radius: 4px;
    transition: background-color 0.2s;
}

.icon-only-btn:hover {
    background-color: var(--border-color);
}

.icon-only-btn .material-symbols-outlined {
    font-size: 1.25rem;
    opacity: 0.8;
}

/* --- Kanban Board --- */
main {
    flex-grow: 1;
}

#kanban-board {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem;
    overflow-x: auto;
    align-items: flex-start;
}

.workflow-column {
    flex: 0 0 320px;
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 12rem);
    min-width: 280px;
}

.workflow-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    cursor: move;
    border-radius: 12px 12px 0 0;
    transition: border-left-color 0.3s ease;
}

.workflow-header.locked {
    cursor: default;
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgb(198 175 80 / 30%) 10px, rgb(198 175 80 / 30%) 20px);
}

.workflow-header h3 {
    margin: 0;
}

.task-list {
    min-height: 100px;
    padding: 1rem;
    overflow-y: auto;
}

/* --- Menu de gestion des colonnes --- */
.workflow-actions {
    position: relative;
    z-index: 5;
}

.workflow-menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.workflow-menu-btn .material-symbols-outlined {
    pointer-events: none;
    /* Prevent icon from stealing mouse events */
}

.workflow-menu-btn:hover {
    background-color: var(--border-color);
}

.workflow-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 10;
    display: none;
    flex-direction: column;
    padding: 0.5rem;
    width: 180px;
}

.workflow-menu.visible {
    display: flex;
}

.workflow-menu button {
    background: none;
    border: none;
    text-align: left;
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
}

.workflow-menu button .material-symbols-outlined {
    font-size: 20px;
    color: inherit;
}

.workflow-menu button.delete {
    color: var(--danger-color);
}

.workflow-menu button:hover {
    background-color: var(--border-color);
}

/* --- Custom Scrollbars --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #444;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* --- Tâches --- */
.task-card {
    background-color: var(--bg-color);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    cursor: grab;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    border-left: 5px solid;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-color);
}

.task-actions {
    position: absolute;
    top: 5px;
    right: 5px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 5;
}

.task-card:hover .task-actions {
    opacity: 1;
}

.task-card-action-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.task-card-action-btn:hover {
    background: var(--border-color);
}

.task-card-action-btn.delete-btn:hover {
    background: #fee2e2;
    color: var(--danger-color);
    border-color: #fecaca;
}

.task-card-action-btn .material-symbols-outlined {
    font-size: 16px;
}



.task-card h4 {
    margin: 0 0 0.5rem;
    padding-right: 20px;
}

.task-card p {
    margin: 0;
    font-size: 0.9em;
    opacity: 0.8;
}

.task-tags-display {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 4px 0 8px 0;
}

.tag-pill-small {
    font-size: 0.65rem;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    display: inline-block;
    font-weight: 500;
    line-height: 1;
}

.task-custom-field-small {
    font-size: 0.75rem;
    margin-top: 4px;
    opacity: 0.8;
}

/* Drag & Drop Placeholder */
.sortable-ghost {
    opacity: 0.4;
    background: var(--border-color);
}

/* --- Footer --- */
#app-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-color);
    background-color: var(--header-bg);
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-left a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 500;
}

.footer-left a.author-link {
    color: inherit;
    font-weight: inherit;
}

.footer-left span {
    font-size: 0.9em;
    opacity: 0.8;
}

.footer-right.io-buttons {
    display: flex;
    gap: 1rem;
}

/* --- Boutons IO & Actions --- */
.io-btn,
.action-btn {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.io-btn:hover,
.action-btn:hover {
    background-color: #155ab0;
    border-color: #155ab0;
}

.danger-btn {
    background-color: var(--danger-color);
}

.danger-btn:hover {
    background-color: #c0392b;
}

.secondary-btn {
    background-color: #6b7280;
    color: white;
    border-color: #6b7280;
}

.secondary-btn:hover {
    background-color: #4b5563;
    border-color: #4b5563;
}

/* --- Modales --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1000;
}

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

.modal-content {
    background: var(--bg-color);
    padding: 2rem;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

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

.modal-content h2 {
    margin-top: 0;
}

.modal-content label {
    display: block;
    margin: 1rem 0 0.5rem;
}

.modal-content input,
.modal-content textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    color: var(--text-color);
    border-radius: 8px;
}

.modal-actions {
    margin-top: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    border-top: none !important;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 0;
}

/* --- Task Modal Custom Styles --- */
.task-modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
}

.modal-header-custom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-color);
    gap: 1rem;
    /* Added gap effectively */
}

.modal-title-input {
    font-size: 1.2rem;
    /* Adjusted size */
    font-weight: bold;
    border: 1px solid transparent;
    /* Placeholder for alignment */
    background: transparent;
    flex-grow: 1;
    /* Take available space */
    padding: 0.5rem;
    color: var(--text-color);
    border-radius: 6px;
    transition: border-color 0.2s, background-color 0.2s;
    height: 42px;
    /* Fixed height to match select */
    box-sizing: border-box;
}

.modal-title-input:hover {
    background-color: var(--card-bg);
}

.modal-title-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--card-bg);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    /* Prevent shrinking */
}

.column-select {
    padding: 0 2rem 0 0.5rem;
    /* Right padding for arrow */
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    max-width: 200px;
    height: 42px;
    /* Matched height */
    box-sizing: border-box;
    cursor: pointer;
}

/* Better Color Input */
input[type="color"]#task-color-input {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    width: 100%;
    /* Full width */
    height: 50px;
    /* Taller */
    padding: 0;
    margin: 0;
    cursor: pointer;
    background: none;
    border-radius: 8px;
    overflow: hidden;
}

input[type="color"]#task-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]#task-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.relative-close {
    position: static;
    font-size: 1.5rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    width: 32px;
}

.modal-body-scroll {
    padding: 1.5rem;
    overflow-y: auto;
    flex-grow: 1;
}

.section-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 1.5rem 0;
}

/* Tags Styles */
.tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0;
}

.circular-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circular-btn.primary {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.circular-btn.primary:hover {
    background-color: #155ab0;
}

.tag-picker {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow-color);
    margin-top: 5px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 100;
    width: 250px;
}

.tags-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.tag-picker.hidden {
    display: none;
}

.tag-picker h4 {
    margin: 0;
    font-size: 0.9rem;
}

.available-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 100px;
    overflow-y: auto;
}

.tag-option {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: white;
    cursor: pointer;
    border: 2px solid transparent;
    opacity: 0.8;
}

.tag-option:hover {
    opacity: 1;
    border-color: rgba(0, 0, 0, 0.2);
}

.tag-pill {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.1em;
    padding: 0;
    line-height: 1;
    opacity: 0.7;
}

.tag-remove:hover {
    opacity: 1;
}

.tag-picker-divider {
    font-size: 0.8rem;
    opacity: 0.6;
    text-align: center;
    margin: 0.25rem 0;
}

.create-tag-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.field-type-select {
    width: 80px;
}

.small-input {
    padding: 0.4rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    flex-grow: 1;
}

.color-input-small {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 34px;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    overflow: hidden;
    border-radius: 6px;
}

.color-input-small::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-small::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.small-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

/* Custom Fields Styles */
.custom-fields-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.custom-field-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    position: relative;
}

.custom-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.custom-field-remove {
    color: var(--danger-color);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.custom-field-remove:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

.custom-field-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

.full-width {
    width: 100%;
}

.modal-actions {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0;
    background-color: var(--bg-color);
}

/* --- Icônes Google --- */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    color: var(--text-color);
    vertical-align: middle;
}

/* --- Notifications système --- */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.notification-error {
    border-left: 4px solid var(--danger-color);
}

.notification-success {
    border-left: 4px solid #22c55e;
}

.notification-info {
    border-left: 4px solid var(--primary-color);
}

.notification-icon {
    font-size: 1.2rem;
}

.notification-message {
    font-size: 0.9rem;
    color: var(--text-color);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

/* --- Drag and Drop Import --- */
.drag-over {
    position: relative;
}

.drag-over::before {
    content: "📋 Glissez votre fichier .kanban ici pour l'importer";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(26, 115, 232, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 10000;
    pointer-events: none;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- Responsive Design --- */

/* Tablettes et petits écrans (768px et moins) */
@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    header h1 {
        font-size: 1.1rem;
    }

    .controls {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: center;
    }

    #kanban-board {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        overflow-x: visible;
    }

    .workflow-column {
        flex: 1 1 auto;
        max-height: none;
        min-height: 200px;
    }

    .workflow-header {
        padding: 0.5rem 0.75rem;
    }

    .task-list {
        padding: 0.75rem;
    }

    #app-footer {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        text-align: center;
    }

    .footer-left {
        flex-direction: column;
        gap: 0.25rem;
    }

    .io-buttons {
        flex-direction: column;
        width: 100%;
        gap: 0.5rem;
    }

    .io-btn {
        width: 100%;
        justify-content: center;
    }

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

    .modal-actions {
        flex-direction: column;
        gap: 0.5rem;
    }

    .modal-actions button {
        width: 100%;
    }

    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Smartphones (480px et moins) */
@media (max-width: 480px) {
    header {
        padding: 0.5rem;
    }

    header h1 {
        font-size: 1rem;
    }

    .controls button {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    #kanban-board {
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .workflow-column {
        border-radius: 8px;
    }

    .workflow-header {
        padding: 0.5rem;
    }

    .workflow-header h3 {
        font-size: 0.9rem;
    }

    .task-list {
        padding: 0.5rem;
    }

    .task-card {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
        border-radius: 6px;
    }

    .task-card h4 {
        font-size: 0.9rem;
        margin-bottom: 0.25rem;
    }

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

    .workflow-menu {
        width: 150px;
        right: -50px;
    }

    .workflow-menu button {
        padding: 0.5rem;
        font-size: 0.9rem;
    }

    #app-footer {
        padding: 0.75rem 0.5rem;
    }

    .footer-left span {
        font-size: 0.8rem;
    }

    .modal-content {
        padding: 1rem;
        border-radius: 8px;
    }

    .modal-content h2 {
        font-size: 1.1rem;
    }

    .modal-content input,
    .modal-content textarea {
        padding: 0.5rem;
        font-size: 1rem;
    }

    .modal-close-btn {
        top: 8px;
        right: 12px;
        font-size: 1.5rem;
    }

    button,
    .io-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }
}

/* Très petits écrans (320px et moins) */
@media (max-width: 320px) {
    header {
        padding: 0.25rem;
    }

    header h1 {
        font-size: 0.9rem;
    }

    #kanban-board {
        padding: 0.25rem;
        gap: 0.5rem;
    }

    .workflow-column {
        border-radius: 6px;
    }

    .task-card {
        padding: 0.5rem;
        border-radius: 4px;
    }

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

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

    .modal-content {
        margin: 0.5rem;
        padding: 0.75rem;
    }

    .workflow-menu {
        width: 130px;
        font-size: 0.8rem;
    }
}

/* Mode paysage sur mobile */
@media (max-width: 768px) and (orientation: landscape) {
    #kanban-board {
        flex-direction: row;
        overflow-x: auto;
        padding: 0.75rem;
    }

    .workflow-column {
        flex: 0 0 250px;
        max-height: calc(100vh - 8rem);
    }

    header {
        flex-direction: row;
        padding: 0.5rem 1rem;
    }

    .controls {
        flex-direction: row;
    }
}

/* --- Authentication & Collaboration Styles --- */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: none;
    /* Controlled by JS */
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

body.auth-mode header,
body.auth-mode footer {
    display: none !important;
}

.auth-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 24px;
    width: 90%;
    max-width: 420px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    text-align: center;
    position: relative;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

/* Custom Select Styling */
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem !important;
    cursor: pointer;
}

.small-select,
.role-select {
    padding: 0.4rem 2rem 0.4rem 0.75rem !important;
    font-size: 0.75rem;
    font-weight: 700;
    height: 32px !important;
    width: auto !important;
    min-width: 100px;
    border-radius: 8px;
    background-position: right 0.6rem center;
    background-size: 0.75rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
}

.role-select:hover {
    border-color: var(--primary-color);
    background-color: var(--card-bg);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow-color);
}

.role-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.2);
}

.role-select[data-role="admin"] {
    border-color: rgba(239, 68, 68, 0.4);
    background-color: rgba(239, 68, 68, 0.1);
    color: #ef4444 !important;
}

.role-select[data-role="editor"] {
    border-color: rgba(26, 115, 232, 0.4);
    background-color: rgba(26, 115, 232, 0.1);
    color: var(--primary-color) !important;
}

.role-select[data-role="reader"] {
    border-color: rgba(148, 163, 184, 0.4);
    background-color: rgba(148, 163, 184, 0.1);
    color: #94a3b8 !important;
}

.role-select option {
    background-color: var(--card-bg);
    color: var(--text-color);
    text-transform: none;
    letter-spacing: normal;
}

.role-badge {
    padding: 0 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    height: 32px;
    box-sizing: border-box;
    border: 1px solid transparent;
}

.role-badge.owner {
    background-color: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border-color: rgba(245, 158, 11, 0.4);
}

.delete-user-btn {
    background-color: transparent !important;
    color: var(--danger-color) !important;
    border: 1px solid var(--danger-color) !important;
    padding: 4px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.delete-user-btn:hover {
    background-color: var(--danger-color) !important;
    color: white !important;
}

.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-info strong {
    font-size: 0.95rem;
}

.user-info small {
    font-size: 0.8rem;
    opacity: 0.6;
}

.assignee-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.assignee-avatar-small {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
}

.task-assignee-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: bold;
    border: 2px solid var(--card-bg);
    margin-left: -8px;
}

.task-assignee-avatar:first-child {
    margin-left: 0;
}

.task-assignees-display {
    display: flex;
    margin-top: 0.5rem;
}

/* Modal Enhancements */
.modal-overlay {
    z-index: 1000;
}

#setup-modal {
    z-index: 10001;
    /* Above auth overlay */
}

/* --- Settings Menu --- */
.settings-container {
    position: relative;
}

.settings-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    min-width: 240px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    padding: 0.6rem;
    z-index: 1000;
    backdrop-filter: blur(12px);
    transform-origin: top right;
    transition: all 0.2s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.settings-menu.hidden {
    display: none;
    opacity: 0;
    transform: scale(0.95) translateY(-5px);
    pointer-events: none;
}

.settings-header {
    padding: 0.8rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    text-align: left;
    /* Ensure text alignment */
    align-items: flex-start;
    /* Align flex items to the left */
}

.settings-header strong {
    font-size: 1rem;
    color: var(--text-color);
    letter-spacing: -0.01em;
}

.settings-header small {
    font-size: 0.8rem;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.settings-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0.5rem;
    opacity: 0.6;
}

.settings-item {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    /* Explicitly align content to the start */
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-color);
    font-size: 0.95rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.settings-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(4px);
}

body.light-mode .settings-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.settings-item .material-symbols-outlined {
    font-size: 20px;
    width: 24px;
    /* Fixed width for icon alignment */
    text-align: center;
    opacity: 0.7;
}

.settings-item.danger-text {
    color: var(--danger-color);
}

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

.settings-item.danger-text .material-symbols-outlined {
    color: var(--danger-color);
}

.action-btn {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.6rem 1.25rem;
    border-radius: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
}

.action-btn:hover {
    transform: translateY(-2px);
    background: var(--primary-color);
    color: white;
    box-shadow: 0 6px 16px rgba(26, 115, 232, 0.4);
}

.action-btn:active {
    transform: translateY(0);
}

.action-btn .material-symbols-outlined {
    font-size: 20px;
}

.circular-btn {
    width: 42px;
    height: 42px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-color);
    opacity: 0.7;
    transition: all 0.2s ease;
}

.circular-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1) !important;
}

.circular-btn.rotate-hover:hover {
    transform: rotate(30deg);
}

body.light-mode .circular-btn:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}

.circular-btn .material-symbols-outlined {
    font-size: 24px;
}

/* User Management Styles */
.user-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.user-row:last-child {
    border-bottom: none;
}

.user-info {
    display: flex;
    flex-direction: column;
}