/* =========================================
   1. CSS VARIABLES (THEME ENGINE)
   ========================================= */
:root {
    /* Light Theme (Default) */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    
    /* Brand Colors */
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    
    /* Status Colors */
    --status-completed: #10b981; /* Emerald Green */
    --status-progress: #f59e0b;  /* Amber */
    --status-pending: #94a3b8;   /* Slate Gray */

    /* Shadows & Transitions */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --transition-fast: 0.2s ease;
}

/* Dark Theme Overrides */
html[data-theme="dark"] {
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.4);
}

/* =========================================
   2. GLOBAL RESET & TYPOGRAPHY
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
    overflow-x: hidden;
}

h1, h2, h3 {
    font-weight: 800;
    letter-spacing: -0.5px;
}

.hidden { display: none !important; }

/* =========================================
   3. APP LAYOUT (DASHBOARD)
   ========================================= */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- SIDEBAR --- */
.sidebar {
    width: 260px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 3rem;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links li, .nav-links a {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.nav-links li:hover, .nav-links a:hover {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
}

.nav-links li.active {
    background-color: var(--accent-blue);
    color: white;
}

/* --- SIDEBAR PROGRESS WIDGET --- */
.sidebar-stats {
    margin-top: auto;
    background-color: var(--bg-main);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.sidebar-stats h4 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar {
    height: 100%;
    background-color: var(--status-completed);
    width: 0%; /* JS will update this */
    transition: width 0.5s ease-in-out;
}

#progress-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* --- MAIN CONTENT AREA --- */
.main-content {
    flex: 1;
    margin-left: 260px; /* Offset for fixed sidebar */
    padding: 2rem 4rem;
}

/* --- TOP BAR (THEME & ADMIN) --- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.icon-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all var(--transition-fast);
    margin-left: 10px;
}

.icon-btn:hover {
    background: var(--border-color);
}

.admin-locked { color: var(--text-secondary); }
.admin-unlocked { color: var(--status-completed); border-color: var(--status-completed); }

/* =========================================
   4. VIEWS & CARDS
   ========================================= */
.view-section {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-banner {
    margin-bottom: 3rem;
}

.welcome-banner h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.welcome-banner p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.section-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-color);
}

/* --- GRID LAYOUT --- */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
}

/* --- THE PROJECT CARD --- */
.card {
    background-color: var(--bg-surface);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border-top: 5px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

/* Status Indicators */
.card.completed { border-top-color: var(--status-completed); }
.card.in_progress { border-top-color: var(--status-progress); }
.card.pending { border-top-color: var(--status-pending); opacity: 0.7; }

.card-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.week-badge {
    background-color: var(--bg-main);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--accent-blue);
}

.difficulty-badge {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.card .description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

/* Tech Stack Tags */
.tech-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.tech-tag {
    font-family: 'Fira Code', monospace;
    font-size: 0.75rem;
    background-color: var(--bg-main);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.card-actions a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.card-actions a:hover { text-decoration: underline; }

/* Status Dropdown */
.status-dropdown {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    outline: none;
}

.status-dropdown:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* =========================================
   5. ADMIN MODAL & LOADER
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: var(--bg-surface);
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    position: relative;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.modal-content h2 { margin-bottom: 10px; }
.modal-content p { color: var(--text-secondary); margin-bottom: 20px; font-size: 0.95rem; }

.modal-content input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-main);
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1rem;
}

.primary-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.primary-btn:hover { background: var(--accent-blue-hover); }

.close-modal {
    position: absolute;
    top: 15px; right: 15px;
    background: none; border: none;
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.error-text { color: #ef4444 !important; margin-top: 10px; }

.loader {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 1.2rem;
    font-weight: 600;
}

/* =========================================
   6. RESPONSIVE DESIGN (MOBILE)
   ========================================= */
@media (max-width: 900px) {
    .app-container { flex-direction: column; }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        padding: 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .main-content {
        margin-left: 0;
        padding: 1.5rem;
    }
    
    .nav-links { flex-direction: row; flex-wrap: wrap; }
    .nav-links li { flex: 1; text-align: center; justify-content: center; }
}

/* =========================================
   7. DOCUMENTATION (PHASES.HTML) LAYOUT
   ========================================= */
.docs-container {
    display: flex;
    gap: 3rem;
    align-items: flex-start;
}

.docs-toc {
    width: 250px;
    position: sticky;
    top: 20px;
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.docs-toc h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.docs-toc ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.docs-toc a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.95rem;
    transition: color var(--transition-fast);
}

.docs-toc a:hover {
    color: var(--accent-blue);
}

.docs-content {
    flex: 1;
    background: var(--bg-surface);
    padding: 3rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.doc-section { margin-bottom: 1rem; }
.doc-section h1 { font-size: 2rem; margin-bottom: 0.5rem; color: var(--accent-blue); }
.doc-section h3 { font-size: 1.3rem; margin: 2rem 0 1rem 0; }
.doc-section p { color: var(--text-secondary); line-height: 1.6; margin-bottom: 1rem; }

.doc-divider {
    border: 0;
    height: 1px;
    background: var(--border-color);
    margin: 3rem 0;
}

/* Beautiful Code Blocks */
.code-block {
    background: #1e293b; /* Always dark for code */
    border-radius: 8px;
    padding: 1.2rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.code-block pre { margin: 0; }
.code-block code {
    font-family: 'Fira Code', monospace;
    color: #e2e8f0;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Inline Code Elements */
p code, li code {
    font-family: 'Fira Code', monospace;
    background: var(--bg-main);
    color: var(--accent-blue);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid var(--border-color);
}

/* Documentation Tables */
.doc-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
}

.doc-table th, .doc-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.doc-table th {
    background-color: var(--bg-main);
    font-weight: 600;
    color: var(--text-primary);
}

.doc-table tr:hover { background-color: rgba(59, 130, 246, 0.05); }

.doc-list {
    margin-left: 1.5rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

/* Mobile Responsive */
@media (max-width: 1000px) {
    .docs-container { flex-direction: column; }
    .docs-toc { width: 100%; position: static; margin-bottom: 2rem; }
    .docs-content { padding: 1.5rem; }
}

/* =========================================
   8. FILTER BAR OVERRIDES
   ========================================= */
.filter-bar {
    margin-bottom: 2rem;
}

#phase-filter {
    padding: 12px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    min-width: 250px;
    transition: all var(--transition-fast);
    /* Soft shadow to match the cards */
    box-shadow: var(--shadow-sm); 
}

#phase-filter:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Ensure the dropdown list options also match the theme */
#phase-filter option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    padding: 10px;
}

/* --- Phase Selector Sidebar Styles --- */
.phase-selector-nav {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.phase-selector-nav h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    letter-spacing: 1px;
}

.phase-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.phase-link {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.phase-link:hover {
    background: var(--bg-main);
    color: var(--accent-blue);
}

.phase-link.active-phase {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent-blue);
    font-weight: 700;
    border-left: 3px solid var(--accent-blue);
}

/* Animation for content swap */
.animated-in {
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    opacity: 0.2;
}