:root {
    /* --- Light Mode (Default) --- */
    --bg-color: #eef2f5;
    --text-main: #4a5568;
    --text-light: #a0aec0;
    --primary: #667eea;
    --primary-soft: #c3dafe;
    --danger: #fc8181;
    --success: #68d391;
    --card-bg: #eef2f5;
    --guide-border: rgba(160, 174, 192, 0.3);
    
    /* Neumorphic Shadows - Light */
    --shadow-light: -6px -6px 14px rgba(255, 255, 255, 0.7);
    --shadow-dark: 6px 6px 10px rgba(163, 177, 198, 0.6);
    --shadow-pressed: inset 4px 4px 8px rgba(163, 177, 198, 0.6), inset -4px -4px 8px rgba(255, 255, 255, 0.7);
    --shadow-float: 8px 8px 20px rgba(163, 177, 198, 0.5);

    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-fam: 'Nunito', sans-serif;
}

/* --- Dark Mode Variables --- */
body.dark-mode {
    --bg-color: #1a202c;
    --text-main: #e2e8f0;
    --text-light: #718096;
    --primary: #7f9cf5;
    --primary-soft: #4c51bf;
    --card-bg: #2d3748;
    --guide-border: rgba(255, 255, 255, 0.1);

    --shadow-light: -4px -4px 10px rgba(255, 255, 255, 0.05);
    --shadow-dark: 4px 4px 10px rgba(0, 0, 0, 0.3);
    --shadow-pressed: inset 3px 3px 6px rgba(0, 0, 0, 0.4), inset -2px -2px 5px rgba(255, 255, 255, 0.05);
    --shadow-float: 5px 5px 15px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body {
    margin: 0;
    font-family: var(--font-fam);
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Layout */
#app { display: flex; flex-direction: column; height: 100vh; }

/* Top Bar */
.top-bar {
    display: flex; align-items: center; padding: 10px 20px;
    background: var(--bg-color); z-index: 10;
    transition: background-color 0.3s;
}
.logo-area { display: flex; align-items: center; gap: 10px; margin-right: 20px; color: var(--primary); }
.project-tabs-container { display: flex; gap: 10px; overflow-x: auto; padding: 5px; max-width: 50%; scrollbar-width: none; }

.tab {
    padding: 8px 16px; border-radius: var(--radius-lg); border: none;
    background: var(--bg-color); color: var(--text-main); font-weight: 700;
    cursor: pointer; box-shadow: var(--shadow-light), var(--shadow-dark);
    transition: all 0.2s ease; white-space: nowrap; position: relative; padding-right: 30px;
}
.tab.active { color: var(--primary); box-shadow: var(--shadow-pressed); }
.tab-delete { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: 0.5; cursor: pointer; }
.tab-delete:hover { opacity: 1; color: var(--danger); }
.spacer { flex: 1; }
.global-actions { display: flex; gap: 15px; }

/* Buttons */
button { font-family: var(--font-fam); border: none; cursor: pointer; transition: transform 0.1s; }
button:active { transform: scale(0.95); }
.btn-primary {
    background: var(--primary); color: white; padding: 10px 20px;
    border-radius: var(--radius-lg); font-weight: 700;
    box-shadow: 4px 4px 10px rgba(102, 126, 234, 0.4);
    display: flex; align-items: center; gap: 5px;
}
.icon-btn {
    width: 40px; height: 40px; border-radius: 50%; background: var(--bg-color);
    box-shadow: var(--shadow-light), var(--shadow-dark);
    display: flex; align-items: center; justify-content: center; color: var(--text-main);
    transition: background-color 0.3s, box-shadow 0.3s;
}
.icon-btn:hover { color: var(--primary); }
.icon-btn:active { box-shadow: var(--shadow-pressed); }

/* Controls */
.controls-bar { padding: 10px 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.search-box {
    display: flex; align-items: center; background: var(--bg-color);
    padding: 5px 15px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pressed); flex: 1; max-width: 300px;
    transition: background-color 0.3s;
}
.search-box input { border: none; background: transparent; padding: 5px; width: 100%; font-weight: 600; color: var(--text-main); }
.filters { display: flex; gap: 10px; align-items: center; }
select {
    padding: 8px; border-radius: var(--radius-md); border: none;
    background: var(--bg-color); box-shadow: var(--shadow-light), var(--shadow-dark);
    font-weight: 600; color: var(--text-main); cursor: pointer;
    transition: background-color 0.3s, color 0.3s;
}

/* Toggle Switch */
.toggle-switch { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle-switch input { display: none; }
.slider {
    width: 40px; height: 20px; background: #cbd5e0; border-radius: 20px;
    position: relative; box-shadow: inset 2px 2px 5px rgba(0,0,0,0.1); transition: 0.3s;
}
.slider::before {
    content: ""; position: absolute; width: 16px; height: 16px; background: white;
    border-radius: 50%; top: 2px; left: 2px; transition: 0.3s; box-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(20px); }
body.dark-mode .slider { background: #4a5568; box-shadow: inset 2px 2px 5px rgba(0,0,0,0.5); }

/* Workspace */
#workspace {
    flex: 1; position: relative; overflow: auto; /* Enable scrolling */
    background-image: radial-gradient(#cbd5e0 1px, transparent 1px);
    background-size: 20px 20px;
    transition: background-image 0.3s;
    scroll-behavior: smooth; /* Soft scroll */
}
body.dark-mode #workspace {
    background-image: radial-gradient(#4a5568 1px, transparent 1px);
}

.board-surface { 
    height: 2000px; 
    position: relative; 
    transition: width 0.3s; /* Smooth resize of canvas */
}

/* Zone Guides */
.zone-guide {
    position: absolute; border: 3px dashed var(--guide-border); border-radius: var(--radius-lg);
    display: flex; justify-content: center; align-items: center; font-size: 3rem; font-weight: 800;
    color: var(--guide-border); pointer-events: none; z-index: 0;
}
/* Positions are relative to project offset now */
.zone-todo { top: 80px; left: 50px; width: 400px; height: 80vh; }
.zone-doing { top: 80px; left: 500px; width: 400px; height: 80vh; }
.zone-done { top: 80px; left: 950px; width: 400px; height: 80vh; border-color: var(--success); color: rgba(104, 211, 145, 0.2); }

/* Infinite Mode Headers */
.project-region-title {
    position: absolute; top: 10px; left: 50px;
    font-size: 2.5rem; font-weight: 800; color: var(--primary);
    opacity: 0.5; pointer-events: none;
    white-space: nowrap;
}

/* Task Card */
.task-card {
    width: 260px; position: absolute; background: var(--card-bg);
    border-radius: var(--radius-lg); padding: 15px; box-shadow: var(--shadow-float);
    cursor: default; transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
    display: flex; flex-direction: column; gap: 8px;
    border: 2px solid rgba(255,255,255,0.5); z-index: 1;
}
body.dark-mode .task-card { border: 2px solid rgba(255,255,255,0.05); }

.task-card:hover { z-index: 100 !important; transform: translateY(-2px); }
.task-card.dragging { opacity: 0.9; transform: scale(1.05) rotate(2deg); z-index: 1000 !important; }
.pin {
    position: absolute; top: -12px; left: 50%; transform: translateX(-50%); width: 16px; height: 16px;
    background: #e53e3e; border-radius: 50%; box-shadow: 2px 2px 5px rgba(0,0,0,0.3); z-index: 2;
}

.card-header { display: flex; justify-content: space-between; align-items: flex-start; cursor: grab; }
.card-title { font-weight: 800; font-size: 1.1rem; line-height: 1.2; color: var(--text-main); }
.card-menu-btn { cursor: pointer; opacity: 0.5; color: var(--text-main); }
.card-menu-btn:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 0.7rem; padding: 2px 8px; border-radius: 10px; background: rgba(0,0,0,0.05); font-weight: 600; color: var(--text-main); }
body.dark-mode .chip { background: rgba(255,255,255,0.1); }

.chip.priority-high { color: var(--danger); background: #fed7d7; }
.chip.priority-medium { color: #d69e2e; background: #fefcbf; }
.chip.priority-low { color: var(--success); background: #c6f6d5; }
body.dark-mode .chip.priority-high { background: rgba(252, 129, 129, 0.2); }
body.dark-mode .chip.priority-medium { background: rgba(214, 158, 46, 0.2); }
body.dark-mode .chip.priority-low { background: rgba(104, 211, 145, 0.2); }

.task-desc { font-size: 0.9rem; color: var(--text-light); white-space: pre-wrap; }
.card-footer { margin-top: auto; display: flex; justify-content: space-between; align-items: center; font-size: 0.8rem; color: var(--text-light); }
.status-check {
    width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--text-light);
    display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s;
}
.status-check:hover { background: rgba(0,0,0,0.05); }
.status-check.is-done { background: var(--success); border-color: var(--success); color: white; }

/* List View */
.list-container { width: 100%; height: 100%; overflow-y: auto; padding: 20px; background: var(--bg-color); transition: background-color 0.3s; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 15px; color: var(--text-light); border-bottom: 2px solid var(--text-light); opacity: 0.5; }
td { padding: 15px; border-bottom: 1px solid rgba(160,174,192,0.2); color: var(--text-main); }
tr:hover { background: rgba(255,255,255,0.1); }

/* Modals */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(26, 32, 44, 0.8); backdrop-filter: blur(4px);
    display: flex; justify-content: center; align-items: center; z-index: 2000;
    opacity: 1; transition: opacity 0.3s;
}
.hidden { display: none; opacity: 0; pointer-events: none; }
.modal {
    background: var(--bg-color); padding: 30px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-float); width: 90%; max-width: 500px;
    animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: background-color 0.3s, color 0.3s;
}
.mini-modal { max-width: 300px; text-align: center; }
@keyframes popUp { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 700; font-size: 0.9rem; color: var(--text-main); }
.form-row { display: flex; gap: 15px; }
.form-row .form-group { flex: 1; }
input, textarea, select {
    width: 100%; padding: 10px; border-radius: var(--radius-md); border: none;
    background: var(--bg-color); box-shadow: var(--shadow-pressed);
    font-family: var(--font-fam); color: var(--text-main);
}
.color-picker { display: flex; gap: 10px; }
.color-dot { width: 25px; height: 25px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-dot.selected { border-color: var(--text-main); transform: scale(1.1); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-text { background: transparent; color: var(--text-main); font-weight: 600; padding: 10px 15px; }
.btn-text:hover { background: rgba(0,0,0,0.05); border-radius: var(--radius-md); }
body.dark-mode .btn-text:hover { background: rgba(255,255,255,0.05); }
.btn-danger { background: var(--danger); color: white; padding: 8px 20px; border-radius: var(--radius-lg); }

/* Toggle Group (Settings) */
.toggle-group { display: flex; gap: 10px; background: var(--bg-color); padding: 4px; border-radius: var(--radius-md); box-shadow: var(--shadow-pressed); }
.btn-toggle {
    flex: 1; padding: 8px; border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 600;
    background: transparent; color: var(--text-light); box-shadow: none;
}
.btn-toggle.active { background: var(--bg-color); color: var(--primary); box-shadow: var(--shadow-light), var(--shadow-dark); }

/* Toast */
#toast-container { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; }
.toast {
    background: #2d3748; color: white; padding: 12px 24px; border-radius: 50px;
    margin-top: 10px; box-shadow: 0 10px 15px rgba(0,0,0,0.2); display: flex; align-items: center; gap: 15px;
    animation: slideUp 0.3s ease;
}
.toast-undo { color: var(--primary-soft); cursor: pointer; font-weight: bold; text-decoration: underline; }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* Mobile */
@media (max-width: 600px) {
    .controls-bar { flex-direction: column; align-items: stretch; }
    .filters { flex-wrap: wrap; }
    .zone-guide { display: none; }
    .project-region-title { display: none; } /* Hide big labels on mobile */
    .board-surface { width: 100vw !important; height: auto; min-height: 100vh; padding-bottom: 100px; }
    .task-card { position: relative !important; margin: 10px auto; width: 90%; left: auto !important; top: auto !important; }
}