:root {
    --primary-color: #2563eb; --primary-hover: #1d4ed8;
    --bg-color: #f3f4f6; --card-bg: #ffffff;
    --text-main: #1f2937; --text-muted: #6b7280;
    --border-color: #e5e7eb; --kanban-bg: #e5e7eb;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); }
.screen { display: none; } .screen.active { display: block; }

/* Login */
#login-screen { justify-content: center; align-items: center; height: 100vh; }
#login-screen.active { display: flex; }
.login-card { background: var(--card-bg); padding: 3rem; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); text-align: center; max-width: 400px; width: 90%; }
.login-card h1 { margin-bottom: 1rem; color: var(--primary-color); }
.login-card p { color: var(--text-muted); margin-bottom: 2rem; line-height: 1.5; }
.error-text { color: #dc2626; margin-top: 1rem; font-size: 0.9rem; }

/* Buttons & Inputs */
.primary-btn { background-color: var(--primary-color); color: white; border: none; padding: 0.75rem 1.5rem; border-radius: 6px; font-size: 1rem; font-weight: 500; cursor: pointer; transition: 0.2s; width: 100%; }
.primary-btn:hover { background-color: var(--primary-hover); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.secondary-btn { background-color: transparent; color: var(--text-muted); border: 1px solid var(--border-color); padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; transition: 0.2s; }
.secondary-btn:hover { background-color: #f9fafb; color: var(--text-main); }
.form-input { width: 100%; padding: 0.5rem; margin-top: 0.25rem; margin-bottom: 1rem; border: 1px solid var(--border-color); border-radius: 6px; font-family: inherit; }
.ai-btn { background-color: #fdf4ff; color: #a21caf; border-color: #f0abfc; font-weight: 600; }
.ai-btn:hover { background-color: #fae8ff; color: #86198f; }

/* Layout & Avatars */
.navbar { background: var(--card-bg); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); }
.nav-brand { font-size: 1.25rem; font-weight: 700; }
.user-controls { display: flex; align-items: center; gap: 1rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-color); }
.avatar-small { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; border: 1px solid var(--border-color); vertical-align: middle; }
.dashboard-content { max-width: 1400px; margin: 0 auto; padding: 2rem; height: calc(100vh - 70px); display: flex; flex-direction: column; }
.header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; flex-shrink: 0; }

/* Filters - DYNAMIC GRID FOR ADMINS */
.filter-bar { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 1rem; margin-bottom: 1rem; flex-shrink: 0; transition: all 0.3s ease; }
.filter-bar.admin-mode { grid-template-columns: 1.5fr 1fr 1fr 1fr 1fr; }
.filter-bar .form-input { margin-bottom: 0; }

/* Kanban Board */
.kanban-board { display: flex; gap: 1.5rem; overflow-x: auto; flex-grow: 1; padding-bottom: 1rem; align-items: flex-start; }
.kanban-column { background: var(--kanban-bg); border-radius: 8px; min-width: 300px; width: 300px; display: flex; flex-direction: column; max-height: 100%; }
.column-header { padding: 1rem; font-weight: 600; font-size: 1.1rem; color: #374151; border-bottom: 2px solid #d1d5db; }
.column-cards { padding: 1rem; overflow-y: auto; flex-grow: 1; display: flex; flex-direction: column; gap: 1rem; min-height: 150px; }
.column-cards.drag-over { background: #d1d5db; border-radius: 6px; }

/* --- MATRIX BOARD --- */
.matrix-board { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 1.5rem; flex-grow: 1; min-height: 600px; padding-bottom: 1rem; overflow: hidden; }
.matrix-quadrant { background: var(--card-bg); border-radius: 8px; border: 1px solid var(--border-color); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.quad-header { padding: 1rem; font-weight: 700; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.quad-sub { font-size: 0.75rem; font-weight: 400; opacity: 0.8; }
.quad-cards { padding: 1rem; overflow-y: auto; flex-grow: 1; display: flex; flex-direction: column; gap: 1rem; background: var(--kanban-bg); }

/* Matrix Quadrant Colors */
.quick-wins .quad-header { background-color: #dcfce7; color: #166534; border-bottom-color: #bbf7d0; }
.major-projects .quad-header { background-color: #dbeafe; color: #1e40af; border-bottom-color: #bfdbfe; }
.fill-ins .quad-header { background-color: #f3f4f6; color: #4b5563; border-bottom-color: #e5e7eb; }
.time-sinks .quad-header { background-color: #fee2e2; color: #991b1b; border-bottom-color: #fecaca; }

/* Cards */
.idea-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; box-shadow: 0 1px 3px rgba(0,0,0,0.1); cursor: grab; position: relative; }
.idea-card:active { cursor: grabbing; }
.idea-card.dragging { opacity: 0.5; }
.card-header h3 { font-size: 1rem; margin-bottom: 0.25rem; word-wrap: break-word; padding-right: 2rem; }
.card-date { font-size: 0.75rem; color: var(--text-muted); }
.card-body { color: var(--text-main); font-size: 0.85rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 0.75rem; border-top: 1px solid var(--border-color); }
.delete-btn { position: absolute; top: 0.5rem; right: 0.5rem; background: none; border: none; cursor: pointer; font-size: 1rem; opacity: 0.4; }
.delete-btn:hover { opacity: 1; transform: scale(1.1); }
.edit-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; text-decoration: underline; padding: 0; }
.edit-btn:hover { color: var(--primary-color); }

/* Badges & Attachments */
.badges { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.badge { padding: 0.2rem 0.4rem; border-radius: 4px; font-size: 0.7rem; font-weight: 600; text-transform: uppercase; }
.badge.priority-p0 { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }
.badge.priority-p1 { background: #ffedd5; color: #9a3412; border: 1px solid #fdba74; }
.badge.priority-p2 { background: #e0f2fe; color: #075985; border: 1px solid #7dd3fc; }
.badge.priority-p3 { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }
.badge.category { background: #e0e7ff; color: #3730a3; }
.badge.eta-badge { background: #fef08a; color: #854d0e; border: 1px solid #fde047; }
.badge.eta-overdue { background: #fee2e2; color: #991b1b; border: 1px solid #f87171; }

.attachment-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.attachment-badge { display: inline-flex; align-items: center; gap: 0.25rem; background: #f3f4f6; border: 1px solid var(--border-color); padding: 0.2rem 0.5rem; border-radius: 12px; font-size: 0.75rem; color: var(--text-main); text-decoration: none; }
.attachment-badge:hover { background: #e5e7eb; }

/* Admin Toggle */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; vertical-align: middle; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary-color); }
input:checked + .slider:before { transform: translateX(20px); }
.toggle-label { font-size: 0.9rem; font-weight: 500; margin-left: 0.5rem; vertical-align: middle; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center; z-index: 1000; }
.large-modal { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; max-width: 900px; width: 95%; height: 80vh; padding: 2rem; background: white; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.modal-left { display: flex; flex-direction: column; overflow-y: auto; padding-right: 1rem; border-right: 1px solid var(--border-color); }
.modal-right { display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 1rem; margin-top: auto; padding-top: 1rem;}

/* Comments & Toolbar */
.comments-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.comments-list { flex-grow: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-color); margin-bottom: 1rem; }
.comment { background: #f9fafb; padding: 0.75rem; border-radius: 8px; border: 1px solid var(--border-color); font-size: 0.9rem; }
.comment.ai-comment { background: #fdf4ff; border-color: #f0abfc; }
.comment-author { font-weight: 600; font-size: 0.8rem; margin-bottom: 0.25rem; color: var(--primary-color); display: flex; align-items: center; gap: 0.4rem; }
.comment-text { line-height: 1.4; word-wrap: break-word; white-space: pre-wrap; }
.comment-text a { color: var(--primary-color); text-decoration: underline; }
.add-comment-box { display: flex; flex-direction: column; gap: 0.5rem; }
.add-comment-box textarea { margin-bottom: 0; resize: none; }

.md-toolbar { display: flex; gap: 0.25rem; padding: 0.25rem; background: #f3f4f6; border: 1px solid var(--border-color); border-bottom: none; border-radius: 6px 6px 0 0; }
.md-btn { background: none; border: 1px solid transparent; padding: 0.25rem 0.5rem; font-size: 0.8rem; cursor: pointer; border-radius: 4px; color: var(--text-main); }
.md-btn:hover { background: #e5e7eb; border-color: #d1d5db; }
#new-comment-text { border-top-left-radius: 0; border-top-right-radius: 0; margin-top: 0;}

/* Comment Actions */
.comment-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.25rem; }
.comment-actions { display: flex; gap: 0.5rem; opacity: 0; transition: opacity 0.2s; }
.comment:hover .comment-actions { opacity: 1; }
.comment-actions button { background: none; border: none; font-size: 0.75rem; color: var(--text-muted); cursor: pointer; text-decoration: underline; padding: 0; }
.comment-actions button:hover { color: var(--primary-color); }
.comment-footer { display: flex; justify-content: flex-end; margin-top: 0.25rem; }
.edited-flag { font-size: 0.65rem; color: #9ca3af; font-style: italic; }

/* Markdown Formatting */
.comment-text p { margin-bottom: 0.5rem; }
.comment-text p:last-child { margin-bottom: 0; }
.comment-text ul, .comment-text ol { margin-left: 1.5rem; margin-bottom: 0.5rem; }
.comment-text li { margin-bottom: 0.25rem; }
.comment-text strong { font-weight: 600; color: var(--text-main); }

@media (max-width: 1400px) and (min-width: 769px) { .kanban-column { min-width: 240px; width: 24%; } }
@media (max-width: 768px) {
    .navbar { flex-direction: column; align-items: stretch; gap: 1rem; }
    .user-controls { justify-content: space-between; }
    .dashboard-content { padding: 1rem; }
    .filter-bar { grid-template-columns: 1fr; }
    .filter-bar.admin-mode { grid-template-columns: 1fr; } /* Keeps it clean on mobile */
    .kanban-column { min-width: 280px; width: 280px; }
    
    /* Responsive Matrix */
    .matrix-board { grid-template-columns: 1fr; grid-template-rows: auto; overflow-y: auto; }
    .matrix-quadrant { min-height: 300px; }

    .large-modal { grid-template-columns: 1fr; height: 95vh; overflow-y: auto; padding: 1.5rem; }
    .modal-left { border-right: none; border-bottom: 1px solid var(--border-color); padding-right: 0; padding-bottom: 1.5rem; margin-bottom: 1.5rem; overflow-y: visible; }
    .modal-right { overflow-y: visible; }
    .form-row { grid-template-columns: 1fr; }
}

/* Toast Notifications */
.toast-container { position: fixed; bottom: 2rem; right: 2rem; display: flex; flex-direction: column; gap: 1rem; z-index: 9999; }
.toast { background: white; border-left: 4px solid #a21caf; box-shadow: 0 10px 25px rgba(0,0,0,0.2); border-radius: 8px; padding: 1.5rem; min-width: 300px; max-width: 450px; display: flex; flex-direction: column; gap: 0.75rem; animation: slideIn 0.3s ease-out; max-height: 85vh; }
.toast-header { display: flex; justify-content: space-between; align-items: center; font-weight: 700; color: var(--text-main); font-size: 1.1rem; flex-shrink: 0; }
.toast-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 0; margin-top: -0.5rem; margin-right: -0.5rem; }
.toast-close:hover { color: #dc2626; }
.toast-body { color: var(--text-main); font-size: 0.9rem; line-height: 1.5; overflow-y: auto; padding-right: 0.5rem; }
.toast-body p { margin-bottom: 0.5rem; }
.toast-body p:last-child { margin-bottom: 0; }
.toast-body ul, .toast-body ol { margin-left: 1.5rem; margin-bottom: 0.5rem; }
.toast-body strong { color: var(--text-main); font-weight: 700; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Processing Animation */
@keyframes pulse-opacity {
    0% { opacity: 0.5; }
    50% { opacity: 0.9; }
    100% { opacity: 0.5; }
}
.processing-card {
    animation: pulse-opacity 2s infinite ease-in-out;
    background-color: #f8fafc;
}