/* PECC (Paint Every Car Challenge) styles */

/* Header section */
section.pecc-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: 16px;
    color: white;
}

.pecc-header h1 {
    font-size: 2.5em;
    margin: 0 0 10px 0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.pecc-header .subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin: 0;
}

/* Controls section */
section.pecc-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--hover-bg);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.control-group select,
.control-group input {
    padding: 12px;
    padding-right: 40px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1em;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.3s;
    min-height: 48px;
    min-width: 200px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.control-group select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
}

@media (prefers-color-scheme: dark) {
    .control-group select {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b0b0b0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    }
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* Loading indicator */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    font-size: 1.2em;
    color: var(--text-secondary);
}

/* Error message */
.error-message {
    background: var(--error-bg);
    border: 2px solid var(--error-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    color: white;
    font-weight: 600;
}

/* Section titles */
.section-title {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

/* Stats summary row */
.stats-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-badge {
    padding: 8px 16px;
    background: var(--hover-bg);
    border-radius: 20px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.stat-badge strong {
    color: var(--text-primary);
}

/* Leaderboard section */
.pecc-leaderboard {
    margin-bottom: 40px;
}

.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    background: var(--hover-bg);
    border-color: var(--accent-primary);
}

.leaderboard-item .rank {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-tertiary);
    min-width: 35px;
    text-align: center;
}

/* Gold, silver, bronze for top 3 */
.leaderboard-item:nth-child(1) .rank { color: #FFD700; }
.leaderboard-item:nth-child(2) .rank { color: #C0C0C0; }
.leaderboard-item:nth-child(3) .rank { color: #CD7F32; }

.leaderboard-item .user-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
}

.leaderboard-item .user-link:hover {
    color: var(--accent-primary);
}

.leaderboard-item .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.leaderboard-item .user-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-item .first-count {
    font-weight: 700;
    color: var(--accent-primary);
    white-space: nowrap;
}

/* Progress section (user view) */
.pecc-progress {
    margin-bottom: 40px;
}

.progress-summary {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 25px 30px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: 16px;
    color: white;
    flex-wrap: wrap;
}

.progress-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-user .user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.progress-user .user-name {
    font-size: 1.4em;
    font-weight: 700;
}

.progress-stats {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.progress-stat {
    text-align: center;
}

.progress-stat .value {
    font-size: 2em;
    font-weight: 700;
    display: block;
    line-height: 1.1;
}

.progress-stat .label {
    font-size: 0.85em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.progress-bar-container {
    flex: 1;
    min-width: 200px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: white;
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Car list section */
.pecc-car-list {
    margin-bottom: 40px;
}

.car-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Two-column layout for user progress */
.car-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.car-column {
    min-width: 0;
}

.column-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

.column-title svg {
    width: 20px;
    height: 20px;
}

.column-title.done-title {
    color: #22c55e;
    border-bottom-color: #22c55e;
}

.column-title.done-title svg {
    stroke: #22c55e;
    stroke-width: 3;
    fill: none;
}

.column-title.todo-title {
    color: var(--text-tertiary);
    border-bottom-color: var(--border-color);
}

.column-title.todo-title svg {
    stroke: var(--text-tertiary);
    stroke-width: 2;
    fill: none;
}

.empty-column {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
    background: var(--hover-bg);
    border-radius: 8px;
}

.car-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 16px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    transition: all 0.2s ease;
}

.car-item:hover {
    background: var(--hover-bg);
}

/* Claimed/painted status */
.car-item.claimed,
.car-item.painted {
    border-left-color: #22c55e;
}

.car-item.unclaimed,
.car-item.not-painted {
    border-left-color: var(--border-color);
    opacity: 0.7;
}

.car-item.unclaimed:hover,
.car-item.not-painted:hover {
    opacity: 1;
}

/* Legacy car styling */
.car-item.legacy {
    background: var(--hover-bg);
}

.car-item.legacy .car-name {
    color: var(--text-secondary);
}

/* Car status icon */
.car-status {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.car-status svg {
    width: 20px;
    height: 20px;
}

.icon-check {
    stroke: #22c55e;
    stroke-width: 3;
    fill: none;
}

.icon-x {
    stroke: var(--text-tertiary);
    stroke-width: 2;
    fill: none;
}

/* Car info */
.car-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.car-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.car-type-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.car-type-badge.road {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

.car-type-badge.oval {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.legacy-badge {
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7em;
    font-weight: 600;
    background: rgba(107, 114, 128, 0.15);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

/* First painter info (registry view) */
.first-painter-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.first-painter {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--text-primary);
}

.first-painter:hover {
    color: var(--accent-primary);
}

.first-painter .user-avatar-sm {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.first-painter .painter-name {
    font-weight: 500;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.claim-date {
    font-size: 0.8em;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.no-painter {
    color: var(--text-tertiary);
    font-style: italic;
    font-size: 0.9em;
}

/* Paint meta (user view - count + date) */
.paint-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.paint-count {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.paint-date {
    font-size: 0.8em;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 1.1em;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .pecc-header h1 {
        font-size: 1.8em;
    }

    .pecc-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group select,
    .control-group input {
        width: 100%;
        min-width: unset;
    }

    .leaderboard-grid {
        grid-template-columns: 1fr;
    }

    .progress-summary {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    .progress-stats {
        justify-content: center;
    }

    .progress-bar-container {
        width: 100%;
    }

    .car-columns {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .car-item {
        flex-wrap: wrap;
    }

    .car-info {
        flex-basis: 100%;
        order: 1;
    }

    .car-status {
        order: 0;
    }

    .first-painter,
    .paint-count {
        order: 2;
        margin-left: 39px;
    }
}
