/* === CSS Variables === */
:root {
    --primary: #374151;
    --primary-light: #4b5563;
    --primary-dark: #1f2937;
    --accent: #13445d;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
    --priority-low: #3b82f6;
    --priority-medium: #f59e0b;
    --priority-high: #ef4444;
    --status-todo: #6b7280;
    --status-inprogress: #3b82f6;
    --status-done: #22c55e;
    --font: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

[data-theme="dark"] {
    --primary: #e5e7eb;
    --primary-light: #d1d5db;
    --primary-dark: #f9fafb;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.3);
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* === Auth Pages === */
.auth-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.auth-left {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-right {
    flex: 1;
    display: none;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #1a5a7a);
    color: white;
    padding: 3rem;
}

@media (min-width: 768px) {
    .auth-right { display: flex; }
}

.auth-right-content {
    max-width: 400px;
    text-align: center;
}

.auth-right-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.auth-right-content p {
    font-size: 1.1rem;
    opacity: 0.9;
    line-height: 1.6;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
}

.auth-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.auth-card .subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

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

.form-group label {
    display: block;
    font-weight: 500;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(19, 68, 93, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: #165a78; }

.btn-full { width: 100%; padding: 0.75rem; }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-hover); }

.btn-danger {
    background: var(--error);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }
.btn-icon { padding: 0.4rem; line-height: 1; }

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.auth-footer a { color: var(--accent); font-weight: 500; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.85rem;
    display: none;
}
.alert-error { background: #fef2f2; color: var(--error); border: 1px solid #fecaca; }
[data-theme="dark"] .alert-error { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); }

/* === App Header === */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.header-titles {
    display: flex;
    flex-direction: column;
}

.header-title {
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text);
    letter-spacing: -0.01em;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

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

.profile-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.85rem;
}
.profile-btn:hover { background: var(--bg-hover); }

.profile-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
    z-index: 200;
}

.profile-dropdown.open { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-divider { border-top: 1px solid var(--border); margin: 0.25rem 0; }
.dropdown-item.danger { color: var(--error); }

/* === Toolbar === */
.toolbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
}
.search-box input:focus { outline: none; border-color: var(--accent); }

.search-box svg {
    position: absolute;
    left: 0.6rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--text-muted);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group select {
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.8rem;
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}

.view-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.view-toggle button {
    padding: 0.45rem 0.75rem;
    border: none;
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.8rem;
    transition: all 0.15s;
}
.view-toggle button:not(:last-child) { border-right: 1px solid var(--border); }
.view-toggle button.active {
    background: var(--accent);
    color: white;
}

.toolbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* === Main Content === */
.main-content {
    padding: 1.5rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* === Kanban Board === */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    min-height: 400px;
}

@media (max-width: 900px) {
    .kanban-board { grid-template-columns: 1fr; }
}

.kanban-column {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem;
    min-height: 200px;
    transition: background 0.2s;
}

.kanban-column.drag-over {
    background: rgba(19, 68, 93, 0.05);
    border-color: var(--accent);
}

.column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.column-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.column-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
}

.column-todo .column-dot { background: var(--status-todo); }
.column-inprogress .column-dot { background: var(--status-inprogress); }
.column-done .column-dot { background: var(--status-done); }

.column-count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
}

.column-tasks {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 50px;
}

/* === Task Card === */
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
    cursor: grab;
    transition: all 0.2s;
    position: relative;
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.task-card.dragging {
    opacity: 0.5;
    transform: rotate(2deg);
}

.task-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.task-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    flex: 1;
    word-break: break-word;
}

.task-card-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.task-card:hover .task-card-actions { opacity: 1; }

.task-card-actions button {
    width: 24px; height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
}
.task-card-actions button:hover { background: var(--bg-hover); color: var(--text); }

.task-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.priority-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    text-transform: uppercase;
}
.priority-low { background: rgba(59,130,246,0.1); color: var(--priority-low); }
.priority-medium { background: rgba(245,158,11,0.1); color: var(--priority-medium); }
.priority-high { background: rgba(239,68,68,0.1); color: var(--priority-high); }

.project-tag {
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    border: 1px solid;
    font-weight: 500;
}

.deadline-tag {
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.2rem;
}
.deadline-tag.overdue { color: var(--error); font-weight: 600; }

.subtask-progress {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--success);
    border-radius: 2px;
    transition: width 0.3s;
}

/* === List View === */
.list-view { display: none; }
.list-view.active { display: block; }
.kanban-view.active { display: grid; }

.list-table {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.list-row {
    display: grid;
    grid-template-columns: auto 1fr 100px 80px 120px 100px 50px;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
    transition: background 0.15s;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-hover); }

.list-header {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg);
}
.list-header:hover { background: var(--bg); }

.status-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    text-align: center;
}
.status-todo { background: rgba(107,114,128,0.1); color: var(--status-todo); }
.status-inprogress { background: rgba(59,130,246,0.1); color: var(--status-inprogress); }
.status-done { background: rgba(34,197,94,0.1); color: var(--status-done); }

.status-check {
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.status-check:hover { border-color: var(--accent); }
.status-check.checked {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

/* === Stats Panel === */
.stats-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* === Modals === */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    width: 28px; height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    font-size: 1.2rem;
}
.modal-close:hover { background: var(--bg-hover); }

.modal-body { padding: 1.5rem; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}

/* === Subtasks in modal === */
.subtask-list {
    margin-top: 0.75rem;
}

.subtask-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
}

.subtask-item input[type="checkbox"] {
    width: 16px; height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.subtask-item .subtask-text { flex: 1; }
.subtask-item .subtask-text.done { text-decoration: line-through; color: var(--text-muted); }

.subtask-item .delete-subtask {
    opacity: 0;
    transition: opacity 0.15s;
    cursor: pointer;
    color: var(--text-muted);
    border: none;
    background: transparent;
    font-size: 0.9rem;
}
.subtask-item:hover .delete-subtask { opacity: 1; }

.project-select-row {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.project-select-row select { flex: 1; }

.btn-inline-add {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-inline-add:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.inline-new-project {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    margin-top: 0.5rem;
}

.inline-new-project input[type="text"] {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
}

.inline-new-project input[type="color"] {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
}

.add-subtask-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.add-subtask-row input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
}

/* === Empty states === */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.empty-state svg { width: 40px; height: 40px; margin-bottom: 0.5rem; opacity: 0.4; }
.empty-state p { font-size: 0.85rem; }

/* === Theme toggle === */
.theme-toggle {
    width: 32px; height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
}
.theme-toggle:hover { background: var(--bg-hover); }

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Project colors in modals === */
.color-picker {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.15s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text); }

/* === Import/Export buttons === */
.menu-btn {
    position: relative;
}

.menu-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    display: none;
    z-index: 50;
}

.menu-dropdown.open { display: block; }

.menu-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    font-size: 0.8rem;
    color: var(--text);
    cursor: pointer;
}
.menu-dropdown-item:hover { background: var(--bg-hover); }

/* === Responsive === */
@media (max-width: 640px) {
    .toolbar { padding: 0.5rem 1rem; }
    .main-content { padding: 1rem; }
    .search-box { max-width: 100%; }
    .filter-group { flex-wrap: wrap; }
    .stats-panel { grid-template-columns: repeat(2, 1fr); }
    .list-row { grid-template-columns: auto 1fr 80px 50px; }
    .list-row > :nth-child(5),
    .list-row > :nth-child(6) { display: none; }
}
