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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2d3748;
    background: #f7fafc;
    min-height: 100vh;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Header */
.header {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-title h1 {
    color: #1a202c;
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.header-subtitle {
    margin: 0.25rem 0 0 0;
    font-size: 0.9rem;
    color: #6b7280;
}

/* New: container for subtitle + external links */
.header-links {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 0.35rem;
}

.official-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
}

.official-link:hover {
    text-decoration: underline;
}

/* GitHub button styling */
.github-btn {
    --gh-bg: #111827;
    --gh-bg-hover: #1f2937;
    --gh-bg-active: #000000;
    --gh-border: #1f2937;
    --gh-focus: rgba(59,130,246,0.55);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--gh-bg);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.75rem;
    line-height: 1;
    font-weight: 600;
    padding: 0.55rem 0.85rem 0.55rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--gh-border);
    box-shadow: 0 1px 2px rgba(0,0,0,0.15), 0 0 0 1px rgba(255,255,255,0.05) inset;
    transition: background .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.github-btn:hover {
    background: var(--gh-bg-hover);
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.05) inset;
}

.github-btn:active {
    background: var(--gh-bg-active);
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) inset;
}

.github-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--gh-focus), 0 1px 2px rgba(0,0,0,0.25);
}

.github-btn:focus:not(:focus-visible) {
    outline: none;
}

.github-btn:active .github-icon {
    transform: scale(0.92);
}

.github-icon {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    transition: transform .18s ease;
    color: currentColor;
}

@media (prefers-reduced-motion: reduce) {
    .github-btn, .github-icon { transition: none; }
}

@media (prefers-color-scheme: dark) {
    body { background: #0f172a; color: #e2e8f0; }
    .header { background: #1e293b; border-color: #334155; }
    .progress-section, .filters, .card { background: #1e293b; border-color: #334155; }
    .github-btn { --gh-bg:#0f172a; --gh-bg-hover:#1e293b; --gh-bg-active:#020617; --gh-border:#334155; }
    .official-link { color: #60a5fa; }
}

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

/* Progress section */
.progress-section {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: var(--header-height, 85px); /* stick below header */
    z-index: 90;
}

.progress-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.progress-text {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    min-width: 200px;
}

.progress-bar-container {
    flex: 1;
    max-width: 400px;
    min-width: 200px;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background: #f3f4f6;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    border: 1px solid #e5e7eb;
}

.progress-fill {
    height: 100%;
    background: #10b981;
    transition: width 0.4s ease;
    border-radius: 10px;
}

/* Autosave toggle */
.autosave-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.autosave-toggle input[type="checkbox"] {
    margin: 0;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Filters (scrolls with content) */
.filters {
    background: #ffffff;
    border-bottom: 1px solid #e2e8f0;
    padding: 1rem 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filters-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-container {
    flex: 1;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #ffffff;
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

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

.filter-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #374151;
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
    background: #ffffff;
    transition: all 0.2s ease;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Unified focus styles */
.search-input:focus,
.filter-select:focus,
.notes-textarea:focus,
.btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-input:focus,
.filter-select:focus,
.notes-textarea:focus {
    border-color: #3b82f6;
}

/* Default focus for status selects (when no status class) */
.status-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

/* Main content */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

/* Sidebar */
.card { /* shared panel style */
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sidebar {
    padding: 1.5rem;
    height: fit-content;
}

.sidebar h2 {
    color: #1f2937;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.category-list {
    list-style: none;
}

.category-item {
    margin-bottom: 0.5rem;
}

.category-button {
    display: block;
    width: 100%;
    padding: 0.875rem 1rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    color: #4b5563;
}

.category-button:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.category-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.category-button.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

/* Checklist area */
.checklist-area {
    margin-top: 0;
}

.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Checklist items */
.checklist-item {
    padding: 1.5rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.checklist-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: #e5e7eb;
    transition: background-color 0.2s ease;
}

.checklist-item.status-done::before {
    background: #10b981;
}

.checklist-item.status-in_progress::before {
    background: #f59e0b;
}

.checklist-item.status-blocked::before {
    background: #ef4444;
}

.checklist-item.status-not_started::before {
    background: #6b7280;
}

.checklist-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.checklist-item.status-done {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.checklist-item.status-done:hover {
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

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

.item-info {
    flex: 1;
}

.item-id {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.checklist-item.status-done .item-id {
    color: #059669;
}

.item-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.5;
}

.checklist-item.status-done .item-title {
    color: #065f46;
}

.item-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 180px;
}

/* Objectives & reference */
.item-meta {
    margin: 0 0 1rem 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #4b5563;
}
.item-objectives {
    list-style: disc inside;
    margin: 0 0 0.5rem 0;
    padding: 0;
}
.item-objectives li + li { margin-top: 0.25rem; }
.item-ref-link {
    display: inline-block;
    font-weight: 600;
    color: #2563eb;
    text-decoration: none;
}
.item-ref-link:hover { text-decoration: underline; }

/* Status-specific styling for selects - using classes instead of attributes */
.status-select {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    background: #ffffff;
    transition: all 0.2s ease;
    cursor: pointer;
}

.status-select.status-done {
    background: #10b981;
    color: white;
    border-color: #10b981;
}

.status-select.status-done:focus {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

.status-select.status-in_progress {
    background: #f59e0b;
    color: white;
    border-color: #f59e0b;
}

.status-select.status-in_progress:focus {
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.status-select.status-blocked {
    background: #ef4444;
    color: white;
    border-color: #ef4444;
}

.status-select.status-blocked:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3);
}

.status-select.status-not_started {
    background: #6b7280;
    color: white;
    border-color: #6b7280;
}

.status-select.status-not_started:focus {
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.3);
}

.notes-textarea {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    background: #ffffff;
    transition: all 0.2s ease;
}



.notes-textarea::placeholder {
    color: #9ca3af;
    font-style: italic;
}

/* Error message */
.error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ef4444;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    max-width: 350px;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    font-weight: 500;
}

.error-message.show {
    transform: translateX(0);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #6b7280;
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: #374151;
    font-size: 1.25rem;
    font-weight: 600;
}

.empty-state p {
    font-size: 0.95rem;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 4rem 2rem;
    color: #6b7280;
    font-size: 0.95rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .header-links { align-items: center; }

    .header-controls {
        justify-content: center;
    }

    .filters-content {
        flex-direction: column;
        align-items: stretch;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding-top: 1rem;
    }

    .sidebar {
        order: 2;
    }

    .checklist-area {
        order: 1;
    }

    .item-header {
        flex-direction: column;
        align-items: stretch;
    }

    .item-controls {
        min-width: auto;
        flex-direction: row;
        gap: 1rem;
    }

    .status-select {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .header-content,
    .filters-content,
    .main-content {
        padding: 0 0.75rem;
    }

    .checklist-item {
        padding: 1.25rem;
    }

    .sidebar {
        padding: 1.25rem;
    }

    .btn {
        padding: 0.625rem 1.25rem;
        font-size: 0.85rem;
    }
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 1rem;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-content {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.2s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1) translateY(0);
}

.modal-header {
    padding: 1.5rem 1.5rem 0 1.5rem;
    border-bottom: 1px solid #f3f4f6;
}

.modal-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #dc2626;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
    line-height: 1.6;
}

.modal-body p {
    margin: 0 0 1rem 0;
    color: #374151;
}

.modal-body p:last-child {
    margin-bottom: 0;
}

.warning-list {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.warning-list p {
    margin: 0 0 0.5rem 0;
    font-weight: 600;
    color: #dc2626;
}

.warning-list ul {
    margin: 0;
    padding-left: 1.5rem;
    color: #7f1d1d;
}

.warning-list li {
    margin-bottom: 0.25rem;
}

.recommendation {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.recommendation p {
    margin: 0;
    color: #0c4a6e;
}

.final-warning {
    text-align: center;
    font-size: 0.95rem;
    color: #dc2626 !important;
    padding: 0.75rem;
    background: #fef2f2;
    border-radius: 6px;
    border: 1px solid #fecaca;
}

.modal-footer {
    padding: 0 1.5rem 1.5rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

.modal-footer .btn {
    min-width: 100px;
}

/* Modal responsive */
@media (max-width: 640px) {
    .modal-content {
        margin: 1rem;
        border-radius: 8px;
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .modal-footer .btn {
        width: 100%;
    }
}

/* Scroll-to-top button */
.scroll-top-btn {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    background: #e5e7eb;
    color: #374151;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: all 0.25s ease;
    z-index: 500;
}

.scroll-top-btn:hover {
    background: #d1d5db;
    box-shadow: 0 3px 6px rgba(0,0,0,0.12);
}

.scroll-top-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.35);
}

.scroll-top-btn.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* High contrast / forced colors */
@media (forced-colors: active) {
    .github-btn {
        forced-color-adjust: auto;
        background: ButtonFace;
        color: ButtonText;
        border-color: ButtonText;
    }
    .github-btn:hover { background: Highlight; color: HighlightText; }
}

/* Dark mode preference */
@media (prefers-color-scheme: dark) {
    .github-btn {
        --gh-bg: #1f2428;
        --gh-bg-hover: #30363d;
        --gh-bg-active: #161b22;
        --gh-border: #30363d;
        color: #f0f6fc;
    }
}
