/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f4f8;
    color: #1e293b;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

#app {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* ===== LOGIN ===== */
.login-container {
    max-width: 400px;
    margin: 5rem auto;
    background: white;
    padding: 2.5rem 2rem;
    border-radius: 1.5rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.login-container h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #0f172a;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.4rem;
    font-size: 0.9rem;
    color: #475569;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    font-size: 1rem;
    background: white;
    transition: border 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.2);
}

.btn {
    display: inline-block;
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-align: center;
    background: #e2e8f0;
    color: #1e293b;
}

.btn.primary {
    background: #2563eb;
    color: white;
}
.btn.primary:hover {
    background: #1d4ed8;
}
.btn.secondary {
    background: #e2e8f0;
    color: #1e293b;
}
.btn.secondary:hover {
    background: #cbd5e1;
}
.btn.outline {
    background: transparent;
    border: 1px solid #cbd5e1;
}
.btn.outline:hover {
    background: #f1f5f9;
}
.btn:active {
    transform: scale(0.96);
}

.btn-sm {
    padding: 0.45rem 1rem;
    font-size: 0.85rem;
    border-radius: 0.6rem;
}

.btn-open, .btn-settings {
    background: none;
    border: none;
    font-size: 0.9rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
    line-height: 1;
}
.btn-open:hover {
    background: #e0f2fe;
}
.btn-settings:hover {
    background: #f1f5f9;
}

.error-message {
    color: #dc2626;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    text-align: center;
}
.hint {
    text-align: center;
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 1rem;
}

/* ===== HEADER ===== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0 1rem 0;
    flex-wrap: wrap;
    gap: 0.5rem;
}

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

.header-left h2 {
    font-weight: 600;
    font-size: 1.5rem;
    color: #0f172a;
}

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

.role-badge {
    background: #dbeafe;
    color: #1e40af;
    padding: 0.2rem 0.8rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
}

.btn-logout-inline {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #64748b;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    line-height: 1.4;
}
.btn-logout-inline:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

/* ===== TOOLBAR ===== */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #e2e8f0;
}

.toolbar-settings-group {
    position: relative;
}

.toolbar-settings-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.3rem;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 180px;
    overflow: hidden;
    z-index: 200;
}

.toolbar-settings-dropdown.active {
    display: block;
}

.toolbar-dropdown-item {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    border: none;
    background: none;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    color: #1e293b;
    transition: background 0.15s;
}

.toolbar-dropdown-item:hover {
    background: #f1f5f9;
}

/* ===== BOARD ===== */
.board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.column {
    background: #f8fafc;
    border-radius: 1rem;
    padding: 1rem;
    min-height: 80px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.column[data-status="urgent"] {
    background: #f8fafc;
}

.column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.column-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #0f172a;
}

.column-header .count {
    background: #e2e8f0;
    padding: 0.15rem 0.6rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 50px;
}

/* ===== TASK CARD ===== */
.task-card {
    background: white;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    border-left: 4px solid #94a3b8;
    cursor: grab;
    transition: background 0.2s, box-shadow 0.2s;
    position: relative;
}

.task-card:hover {
    background: #f1f5f9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.task-card .task-delegate-arrow {
    position: absolute;
    top: 0.4rem;
    right: 0.5rem;
    font-size: 1rem;
    color: #3b82f6;
    font-weight: 700;
    line-height: 1;
}

.task-card.priority-high {
    border-left-color: #ef4444;
}
.task-card.priority-medium {
    border-left-color: #f59e0b;
}
.task-card.priority-low {
    border-left-color: #22c55e;
}

.task-card .task-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
    word-break: break-word;
}

.task-card .task-meta {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.3rem;
}

.task-card .task-actions-row1 {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.task-card .task-actions-row2 {
    display: flex;
    justify-content: space-evenly;
    gap: 0.5rem;
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid #f1f5f9;
}

.task-card .task-actions-row1 button,
.task-card .task-actions-row2 button {
    background: none;
    border: none;
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s;
}

.task-card .btn-done {
    background: #dcfce7;
    color: #166534;
}
.task-card .btn-done:hover {
    background: #bbf7d0;
}
.task-card .btn-delegate {
    background: #dbeafe;
    color: #1e40af;
}
.task-card .btn-delegate:hover {
    background: #bfdbfe;
}
.task-card .btn-restore {
    background: #fef3c7;
    color: #92400e;
}
.task-card .btn-restore:hover {
    background: #fde68a;
}
.task-card .btn-delete {
    background: #fee2e2;
    color: #b91c1c;
}
.task-card .btn-delete:hover {
    background: #fecaca;
}

.task-card .assignee {
    font-weight: 500;
    color: #2563eb;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}


.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 1.5rem;
    max-width: 90vw;
    width: 100%;
    padding: 2rem;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.close-modal {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: #94a3b8;
    transition: color 0.2s;
}
.close-modal:hover {
    color: #0f172a;
}

/* ===== MOBILE BAR ===== */
.mobile-bar {
    display: none;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .board {
        grid-template-columns: 1fr;
        padding-bottom: 4.5rem;
    }
    .toolbar {
        display: none;
    }
    .mobile-bar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #e2e8f0;
        border-top: 1px solid #d1d5db;
        padding: 0.5rem 1rem;
        z-index: 100;
    }
    .mobile-bar-btn {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        border: none;
        background: transparent;
        font-size: 1.4rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s;
    }
    .mobile-bar-btn:hover {
        background: rgba(0,0,0,0.08);
    }
    .mobile-bar-btn-main {
        width: 34px;
        height: 34px;
        border-radius: 50%;
        background: transparent;
        color: #1e40af;
        font-size: 1.1rem;
        box-shadow: none;
    }
    .mobile-bar-btn-main:hover {
        background: rgba(30,64,175,0.08);
    }
    .mobile-bar-btn-group {
        position: relative;
    }
    .mobile-settings-dropdown {
        display: none;
        position: absolute;
        bottom: 56px;
        right: 0;
        background: white;
        border-radius: 0.75rem;
        box-shadow: 0 4px 20px rgba(0,0,0,0.15);
        min-width: 180px;
        overflow: hidden;
        z-index: 200;
    }
    .mobile-settings-dropdown.active {
        display: block;
    }
    .mobile-dropdown-item {
        display: block;
        width: 100%;
        padding: 0.75rem 1rem;
        border: none;
        background: none;
        font-size: 0.9rem;
        text-align: left;
        cursor: pointer;
        color: #1e293b;
        transition: background 0.15s;
    }
    .mobile-dropdown-item:hover {
        background: #f1f5f9;
    }
    .app-header {
        flex-direction: row;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }
    .header-left {
        justify-content: flex-start;
        flex-wrap: nowrap;
        min-width: 0;
        overflow: hidden;
    }
    .header-left h2 {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }
    .header-right {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .login-container {
        margin: 2rem 1rem;
        padding: 1.5rem;
    }
    .modal-content {
        padding: 1.5rem;
    }
    .toast-container {
        top: auto;
        bottom: 5rem;
        right: 0.75rem;
        left: 0.75rem;
    }
    .toast {
        max-width: 100%;
    }
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    background: #1e293b;
    color: white;
    padding: 0.8rem 1.2rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    pointer-events: auto;
    animation: toastIn 0.4s ease-out;
    max-width: 350px;
}
.toast.toast-new-task {
    border-left: 4px solid #3b82f6;
}
.toast.toast-delegated {
    border-left: 4px solid #f59e0b;
}
.toast.toast-exit {
    animation: toastOut 0.3s ease-in forwards;
}
.toast-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}
.toast-body {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}
.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toast-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ===== UTILITY ===== */
.dragging {
    opacity: 0.5;
    transform: scale(0.98);
}

.drag-over {
    background: #e0f2fe;
    border: 2px dashed #3b82f6;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 8px;
}

/* ===== USER LIST ===== */
.user-row {
    padding: 0.6rem 0;
    border-bottom: 1px solid #e2e8f0;
}
.user-row-view {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.user-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid rgba(0,0,0,0.1);
}
.user-row-view span:not(.user-color-dot) {
    flex: 1;
}
.user-row-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}

/* ===== COLOR PICKER ===== */
.color-picker-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.color-picker-row input[type="color"] {
    width: 40px;
    height: 36px;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    cursor: pointer;
    padding: 2px;
}
.color-preview {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}
.color-presets {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}
.color-preset-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.1s;
    padding: 0;
}
.color-preset-btn:hover {
    border-color: #1e293b;
    transform: scale(1.15);
}
