/* Pico CSS overrides */

:root {
    --pico-font-size: 87.5%;  /* Makes base font smaller (14px) */
    --pico-font-size-base: 14px; /* Base font size for rem calculations */
    --pico-primary: hsl(210, 100%, 40%);
    --pico-primary-background: hsl(210, 100%, 95%);
    --pico-primary-border: hsl(210, 100%, 85%);
    --pico-primary-underline: hsl(210, 100%, 85%);
    --pico-primary-hover: hsl(210, 100%, 90%);
    --pico-primary-hover-background: hsl(210, 100%, 85%);
    --pico-primary-hover-border: hsl(210, 100%, 75%);
    --pico-primary-hover-underline: hsl(210, 100%, 75%);
    --pico-primary-focus: hsl(210, 100%, 90%);
    --pico-primary-inverse: hsl(0, 0%, 100%);
    --status-open: hsl(120, 25%, 90%);
    --status-open-dark: hsl(120, 25%, 20%);
    --status-in-progress: hsl(45, 100%, 90%);
    --status-in-progress-dark: hsl(45, 100%, 30%);
    --status-closed: hsl(0, 50%, 90%);
    --status-closed-dark: hsl(0, 50%, 25%);
    --dense-spacing: 0.5rem;
    
    /* Lane colors */
    --lane-open: hsl(120, 25%, 25%);
    --lane-in-progress: hsl(45, 100%, 35%);
    --lane-closed: hsl(0, 50%, 30%);
}

body {
    background-color: var(--pico-background-color);
}

/* Stats table */
.stats-table {
    margin-bottom: var(--pico-spacing);
    font-size: 0.9rem;
}

.stats-table thead th {
    text-align: center;
    font-weight: 600;
    padding: 0.5rem;
}

.stats-table tbody td {
    text-align: center;
    font-size: 1.1rem;
    font-weight: 500;
    padding: 0.5rem;
}

.stats-table .stats-link {
    text-decoration: none;
    color: var(--pico-primary);
    display: block;
    padding: 0.25rem;
    border-radius: var(--pico-border-radius);
    transition: background-color 0.2s ease, font-weight 0.2s ease;
}

.stats-table .stats-link:hover {
    background-color: var(--pico-primary-hover-background);
}

.stats-table .stats-link.active {
    font-weight: 700;
    background-color: var(--pico-primary-background);
    color: var(--pico-primary);
    border: 2px solid var(--pico-primary);
}

[data-theme="dark"] .stats-table .stats-link.active {
    background-color: var(--pico-primary-background);
    color: var(--pico-primary);
}

/* Header layout */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--pico-spacing);
}

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

.theme-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-control label {
    margin: 0;
    font-weight: var(--pico-font-weight);
    color: var(--pico-color);
}

.theme-control select {
    width: auto;
    margin-bottom: 0;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    min-width: 8rem;
}

#shutdown-btn {
    margin-bottom: 0;
    padding: 0.5rem 1rem;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-wrap: wrap;
    }

    .theme-control {
        flex: 1;
        min-width: 200px;
    }

    #shutdown-btn {
        flex-shrink: 0;
    }
}

[data-theme="dark"] {
    --pico-primary: hsl(210, 100%, 60%);
    --pico-primary-background: hsl(210, 100%, 10%);
    --pico-primary-border: hsl(210, 100%, 20%);
    --pico-primary-underline: hsl(210, 100%, 20%);
    --pico-primary-hover: hsl(210, 100%, 15%);
    --pico-primary-hover-background: hsl(210, 100%, 20%);
    --pico-primary-hover-border: hsl(210, 100%, 30%);
    --pico-primary-hover-underline: hsl(210, 100%, 30%);
    --pico-primary-focus: hsl(210, 100%, 15%);
    --pico-primary-inverse: hsl(0, 0%, 0%);
    --status-open: hsl(120, 25%, 15%);
    --status-open-dark: hsl(120, 25%, 85%);
    --status-in-progress: hsl(45, 100%, 15%);
    --status-in-progress-dark: hsl(45, 100%, 85%);
    --status-closed: hsl(0, 50%, 15%);
    --status-closed-dark: hsl(0, 50%, 85%);
    
    /* Lane colors for dark theme */
    --lane-open: hsl(120, 25%, 85%);
    --lane-in-progress: hsl(45, 100%, 85%);
    --lane-closed: hsl(0, 50%, 85%);
}

body {
    background-color: var(--pico-background-color);
}

main {
    padding: var(--pico-block-spacing-vertical) var(--pico-block-spacing-horizontal);
}

.label {
    background-color: var(--pico-code-background-color);
    color: var(--pico-code-color);
    padding: 0.2rem 0.5rem;
    margin-right: 0.5rem;
    border-radius: var(--pico-border-radius);
    font-size: 0.8rem;
}

.status-open { background-color: var(--status-open); color: var(--status-open-dark); }
[data-theme="dark"] .status-open { background-color: var(--status-open); color: var(--status-open-dark); }
.status-in-progress { background-color: var(--status-in-progress); color: var(--status-in-progress-dark); }
[data-theme="dark"] .status-in-progress { background-color: var(--status-in-progress); color: var(--status-in-progress-dark); }
.status-closed { background-color: var(--status-closed); color: var(--status-closed-dark); }
[data-theme="dark"] .status-closed { background-color: var(--status-closed); color: var(--status-closed-dark); }

.card {
    box-shadow: var(--pico-box-shadow);
    transition: box-shadow 0.2s ease;
}
.card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
[data-theme="dark"] .card:hover {
    box-shadow: 0 4px 8px rgba(255,255,255,0.1);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--dense-spacing);
}

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

/* Kanban lanes */
.kanban {
    display: flex;
    gap: var(--dense-spacing);
    overflow-x: auto;
}

.lane {
    flex: 1;
    min-width: 300px;
    background-color: var(--pico-background-color);
    border: 1px solid var(--pico-border-color);
    border-radius: var(--pico-border-radius);
    padding: var(--pico-block-spacing);
}

.lane h3 {
    margin-top: 0;
    color: var(--lane-open); /* Default, override per lane */
}

.lane-open h3 { color: var(--lane-open); }
.lane-in-progress h3 { color: var(--lane-in-progress); }
.lane-closed h3 { color: var(--lane-closed); }

@media (max-width: 768px) {
    .kanban {
        flex-direction: column;
    }
}

/* Timeline */
.timeline {
    position: relative;
    list-style: none;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--pico-border-color);
}

.timeline li {
    position: relative;
    margin-bottom: 1rem;
    padding-left: 1rem;
}

.timeline li::before {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 0.5rem;
    width: 0.75rem;
    height: 0.75rem;
    background-color: var(--event-created);
    border-radius: 50%;
}

.timeline li h4 {
    margin: 0;
    font-size: 1rem;
}

.timeline li p {
    margin: 0.25rem 0;
    color: var(--pico-muted-color);
}

@media (max-width: 768px) {
    .timeline {
        padding-left: 1.5rem;
    }
    .timeline::before {
        left: 0.75rem;
    }
    .timeline li::before {
        left: -1.25rem;
    }
}

#graph {
    width: 100%;
    height: 600px;
    border: var(--pico-border-width) solid var(--pico-border-color);
    border-radius: var(--pico-border-radius);
}

/* Issue action controls */
.issue-actions {
    margin-bottom: var(--pico-spacing);
    padding: var(--pico-spacing);
    background-color: var(--pico-card-background-color);
    border-radius: var(--pico-border-radius);
    border: 1px solid var(--pico-border-color);
}

.issue-actions .grid {
    gap: 1rem;
}

.issue-actions label {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

.issue-actions select,
.issue-actions button {
    margin-bottom: 0;
}

/* Labels container */
.labels-container {
    margin-bottom: 1rem;
}

.label {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background-color: var(--pico-code-background-color);
    color: var(--pico-code-color);
    padding: 0.2rem 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: var(--pico-border-radius);
    font-size: 0.8rem;
}

.label-remove {
    background: none;
    border: none;
    color: inherit;
    padding: 0 0.25rem;
    margin: 0;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.label-remove:hover {
    opacity: 1;
}

.label-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.label-form input {
    flex: 1;
    margin-bottom: 0;
}

.label-form button {
    margin-bottom: 0;
    white-space: nowrap;
}

/* Comment form */
.comment-form {
    margin-top: 1rem;
}

.comment-form textarea {
    margin-bottom: 0.5rem;
}

.comment-form button {
    margin-bottom: 0;
}

/* Notes section */
details {
    margin-bottom: var(--pico-spacing);
}

details summary {
    cursor: pointer;
    font-weight: 600;
}

details form {
    margin-top: 1rem;
}

details textarea {
    margin-bottom: 0.5rem;
}

/* Close dialog */
dialog {
    max-width: 500px;
}

dialog header button {
    margin-bottom: 0;
}

dialog footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

dialog footer button {
    margin-bottom: 0;
}

/* Required field indicator */
.required {
    color: var(--pico-del-color);
    font-weight: bold;
}

/* HTMX loading states */
.htmx-request {
    opacity: 0.6;
    pointer-events: none;
}

.htmx-request::after {
    content: " (loading...)";
    font-size: 0.8rem;
    color: var(--pico-muted-color);
}
