/* Reset and base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.container {
    padding: 12px;
    overflow-x: hidden;
}

header h1 {
    font-size: 1.4rem;
    color: #1a1a1a;
    margin: 0;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

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

.session-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: #888;
}

.session-email {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    color: #6366f1;
    text-decoration: none;
    font-size: 0.8rem;
    white-space: nowrap;
}

.logout-btn:hover {
    text-decoration: underline;
}

/* ==================== */
/* LOGIN PAGE           */
/* ==================== */

.login-container {
    display: block;
}

.login-main {
    max-width: 420px;
    margin: 40px auto 0;
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.login-main h2 {
    font-size: 1.3rem;
    margin-bottom: 8px;
    color: #1a1a1a;
}

.login-subtitle {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.login-form input[type="email"] {
    padding: 14px 16px;
    font-size: 1rem;
    border-radius: 10px;
    border-width: 2px;
}

.login-form input[type="email"]:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.login-form .btn {
    margin-top: 8px;
    padding: 14px;
    font-size: 1rem;
    border-radius: 10px;
}

.login-notice {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
}

.login-error {
    background: #fee2e2;
    color: #dc2626;
}

.login-success {
    background: #d1fae5;
    color: #065f46;
    padding: 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.view-toggle {
    display: flex;
    gap: 4px;
    background: #e5e5e5;
    padding: 4px;
    border-radius: 8px;
}

.view-btn {
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.85rem;
    color: #666;
    background: transparent;
    transition: all 0.2s;
}

.view-btn:hover {
    color: #333;
}

.view-btn.active {
    background: white;
    color: #333;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

main, .sidebar {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.sidebar h2 {
    font-size: 0.9rem;
    margin-bottom: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Forms - all inputs full width on mobile */
.add-todo {
    margin-bottom: 20px;
}

.form-row, .form-details {
    display: block;
    width: 100%;
}

.form-row > *, .form-details > * {
    display: block;
    width: 100%;
    margin-bottom: 10px;
}

input[type="text"],
input[type="date"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e5e5;
    border-radius: 8px;
    font-size: 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: white;
}

select {
    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='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #6366f1;
}

/* Buttons */
.btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    background: #e5e5e5;
    color: #333;
    text-align: center;
}

.btn-primary {
    background: #6366f1;
    color: white;
}

.btn-small {
    width: auto;
    padding: 10px 14px;
    font-size: 0.9rem;
}

/* Filters */
.filters {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e5e5e5;
}

.filter-buttons {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.filter-btn {
    flex: 1;
    padding: 10px 6px;
    border: none;
    background: #f0f0f0;
    color: #666;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.8rem;
    text-align: center;
}

.filter-btn.active {
    background: #6366f1;
    color: white;
}

.sort-options select {
    width: 100%;
}

.search-box {
    margin-top: 10px;
    flex-basis: 100%;
}

.search-box input {
    width: 100%;
    box-sizing: border-box;
}

/* Todo items */
.todo-list ul {
    list-style: none;
}

.todo-item {
    background: #fafafa;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
}

.todo-item.completed {
    opacity: 0.6;
}

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

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

.todo-checkbox {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border: 2px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.todo-item.completed .todo-checkbox {
    background: #6366f1;
    border-color: #6366f1;
}

.todo-item.completed .todo-checkbox::after {
    content: '\2713';
    color: white;
    font-size: 14px;
}

.todo-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.todo-title {
    font-weight: 500;
    word-break: break-word;
}

.todo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    font-size: 0.75rem;
}

.todo-category-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.todo-board-status {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
}

.todo-item--high {
    border-left: 3px solid #ef4444;
}

.todo-due {
    color: #888;
}

.todo-due.overdue {
    color: #ef4444;
}

.todo-priority {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.priority-low { background: #d1fae5; color: #059669; }
.priority-medium { background: #fef3c7; color: #d97706; }
.priority-high { background: #fee2e2; color: #dc2626; }

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

.todo-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    background: #e5e5e5;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85rem;
    color: #555;
}

.todo-actions .delete-btn:hover {
    background: #fee2e2;
    color: #dc2626;
}

.empty-message {
    text-align: center;
    color: #999;
    padding: 30px 10px;
}

/* Categories */
#categories {
    list-style: none;
    margin-bottom: 12px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
}

.category-item.active {
    background: #f0f0ff;
}

.category-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.category-name {
    flex: 1;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.category-count {
    font-size: 0.8rem;
    color: #999;
}

.category-delete {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #999;
    padding: 4px;
    font-size: 1.1rem;
}

.add-category {
    display: flex;
    gap: 8px;
    align-items: center;
}

.add-category input[type="text"] {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

.add-category input[type="color"] {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    padding: 12px;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 16px;
    font-size: 1.2rem;
}

.form-group {
    margin-bottom: 14px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    margin-bottom: 0;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

/* ==================== */
/* DESKTOP STYLES 769px+ */
/* ==================== */
@media (min-width: 769px) {
    .container {
        display: grid;
        grid-template-columns: 1fr 280px;
        grid-template-rows: auto 1fr;
        gap: 20px;
        max-width: 1200px;
        margin: 0 auto;
        padding: 20px;
    }

    header {
        grid-column: 1 / -1;
    }

    header h1 {
        font-size: 2rem;
    }

    main, .sidebar {
        padding: 24px;
        margin-bottom: 0;
    }

    .form-row {
        display: flex;
        flex-direction: row;
        gap: 12px;
        align-items: center;
    }

    .form-row > * {
        margin-bottom: 0;
    }

    .form-row input[type="text"] {
        flex: 1;
        width: auto;
    }

    .form-row .btn {
        width: auto;
    }

    .form-details {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 12px;
    }

    .form-details > * {
        flex: 1;
        min-width: 120px;
        margin-bottom: 0;
    }

    .filters {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: center;
    }

    .filter-buttons {
        margin-bottom: 0;
        width: auto;
    }

    .filter-btn {
        flex: none;
        padding: 8px 16px;
        font-size: 0.9rem;
    }

    .sort-options {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .sort-options select {
        width: auto;
        min-width: 160px;
    }

    .todo-item {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        gap: 12px;
    }

    .todo-item-header {
        flex: 1;
        min-width: 0;
        margin-bottom: 0;
    }

    .todo-actions {
        width: auto;
        opacity: 0;
        transition: opacity 0.2s;
    }

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

    .todo-actions button {
        flex: none;
        background: transparent;
        padding: 6px 12px;
    }

    .modal-actions {
        flex-direction: row;
        justify-content: flex-end;
    }

    .modal-actions .btn {
        width: auto;
    }
}

/* ==================== */
/* BOARD VIEW STYLES    */
/* ==================== */

.board-container {
    padding: 24px;
    min-height: 100vh;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.board-container header {
    margin-bottom: 24px;
}

.board-container header h1 {
    font-size: 1.75rem;
    font-weight: 600;
}

.board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
    min-height: calc(100vh - 140px);
    align-items: start;
}

.board-column {
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.board-column[data-status="todo"] {
    background: rgba(219, 234, 254, 0.6);
    border-color: rgba(147, 197, 253, 0.3);
}

.board-column[data-status="discuss"] {
    background: rgba(237, 233, 254, 0.6);
    border-color: rgba(196, 181, 253, 0.3);
}

.board-column[data-status="active"] {
    background: rgba(220, 252, 231, 0.6);
    border-color: rgba(134, 239, 172, 0.3);
}

.board-column[data-status="tracking"] {
    background: rgba(255, 237, 213, 0.6);
    border-color: rgba(253, 186, 116, 0.3);
}

.board-column[data-status="onhold"] {
    background: rgba(254, 243, 199, 0.6);
    border-color: rgba(253, 224, 71, 0.3);
}

.board-column.drag-over {
    background: rgba(99, 102, 241, 0.15);
    border-color: #6366f1;
}

.column-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.column-header h2 {
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

.column-count {
    font-weight: 500;
    color: #94a3b8;
}

.column-cards {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
    min-height: 60px;
}

.column-empty {
    color: #94a3b8;
    font-size: 0.85rem;
    text-align: center;
    padding: 24px 12px;
    font-style: italic;
}

.board-card {
    position: relative;
    padding: 6px;
    cursor: grab;
    transition: transform 0.15s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.board-card[data-description]:hover::after {
    content: attr(data-description);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    background: #1e293b;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    line-height: 1.4;
    white-space: pre-wrap;
    max-width: 220px;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.board-card.dragging::after {
    display: none;
}

.board-card:hover {
    transform: translateX(4px);
}

.board-card:active {
    cursor: grabbing;
}

.board-card.dragging {
    opacity: 0.4;
}

.card-complete-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    color: #64748b;
    font-size: 0.85rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.card-complete-btn:hover {
    background: #6366f1;
    color: white;
}

.card-bubble {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    word-break: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.board-card:hover .card-bubble {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

/* High priority dot on board cards */
.board-card[data-priority="high"]::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    z-index: 1;
    pointer-events: none;
}

/* Board category filter bar */
.board-filter-bar {
    margin-bottom: 16px;
}

.board-filter-bar select {
    width: auto;
    min-width: 180px;
    background-color: white;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #1e293b;
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 9999;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.toast--visible {
    opacity: 1;
    transform: translateY(0);
}

/* Board mobile message */
@media (max-width: 768px) {
    .board {
        display: none;
    }

    .board-container::after {
        content: "Board view is designed for desktop. Please use List view on mobile.";
        display: block;
        text-align: center;
        padding: 48px 24px;
        color: #64748b;
        background: white;
        border-radius: 16px;
        margin-top: 24px;
        font-size: 0.95rem;
    }
}
