/* Modern Monotone Theme CSS */

/* ===== CSS VARIABLES - MONOTONE SYSTEM ===== */
:root {
    /* === Monotone Colors === */
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1f1f1f;
    --bg-elevated: #2a2a2a;

    --border-light: #333333;
    --border-active: #555555;

    /* === Text Colors === */
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --text-inverse: #000000;

    /* === Accent Colors (Minimal) === */
    --accent-primary: #ffffff;
    --accent-hover: #e0e0e0;

    /* === Status Colors === */
    --status-success: #4caf50;
    /* Desaturated Green */
    --status-error: #e57373;
    /* Desaturated Red */
    --status-warning: #ffb74d;
    /* Desaturated Orange */

    /* === Spacing === */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* === Border Radius === */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* === Transitions === */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;

    /* === Layout === */
    --panel-width: 350px;
    --header-height: 60px;
}

/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    /* App-like feel */
    font-size: 14px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition-fast);
}

ul {
    list-style: none;
}

input,
button,
select {
    font-family: inherit;
    font-size: inherit;
}

/* ===== UTILITIES ===== */
.text-gradient {
    /* Kept for potential emphasis, but made monotone */
    background: linear-gradient(to right, #fff, #aaa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.slide-up {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ===== LAYOUT COMPONENTS ===== */
.main-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Left Panel (Sidebar) */
.ranking-panel {
    width: var(--panel-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: width 0.1s;
    flex-shrink: 0;
}

.panel-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-secondary);
}

.panel-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Right Panel (Main Content) */
.worldcup-panel {
    flex: 1;
    background-color: var(--bg-primary);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.resize-handle {
    width: 4px;
    cursor: col-resize;
    background-color: transparent;
    transition: background-color var(--transition-fast);
    z-index: 100;
    margin-left: -2px;
    /* Overlap border */
}

.resize-handle:hover,
.resize-handle:active {
    background-color: var(--accent-primary);
}

/* ===== UI ELEMENTS ===== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    gap: 6px;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: var(--text-inverse);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-active);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary);
}

.btn-danger {
    background-color: rgba(229, 115, 115, 0.1);
    border: 1px solid var(--status-error);
    color: var(--status-error);
}

.btn-danger:hover {
    background-color: var(--status-error);
    color: #fff;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: var(--spacing-sm);
}

.input-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

input[type="text"],
input[type="number"],
select {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    width: 100%;
    transition: border-color var(--transition-fast);
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--accent-primary);
    background-color: var(--bg-elevated);
}

/* Cards */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: var(--spacing-sd) var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    background-color: var(--bg-tertiary);
}

.card-body {
    padding: var(--spacing-md);
}

/* Accordion */
.accordion {
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background-color: var(--bg-secondary);
    overflow: hidden;
    margin-bottom: var(--spacing-sm);
}

.accordion-header {
    width: 100%;
    padding: 10px 12px;
    background-color: var(--bg-secondary);
    border: none;
    border-bottom: 1px solid transparent;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color var(--transition-fast);
}

.accordion-header:hover {
    background-color: var(--bg-tertiary);
}

.accordion-header.active {
    background-color: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
}

.accordion-content {
    display: none;
    padding: var(--spacing-md);
    background-color: var(--bg-secondary);
}

.accordion-content.active {
    display: block;
}

/* List Items (Ranking) */
.list-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    gap: 8px;
    transition: background-color var(--transition-fast);
    font-size: 0.9rem;
    min-width: 0;
}

.list-item:hover {
    background-color: var(--bg-tertiary);
}

.list-item:last-child {
    border-bottom: none;
}

.rank-badge {
    font-family: monospace;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 28px;
    text-align: center;
}

.item-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.elo-badge {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--accent-primary);
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
}

.item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.list-item:hover .item-actions {
    opacity: 1;
}

/* Mobile: tap to reveal actions */
@media (max-width: 768px) {
    .list-item {
        gap: 6px;
        padding: 6px 8px;
        font-size: 0.82rem;
        cursor: pointer;
    }

    .list-item .item-actions {
        display: none;
    }

    .list-item.active {
        background-color: var(--bg-tertiary);
    }

    .list-item.active .item-actions {
        display: flex;
        opacity: 1;
    }

    .item-actions .btn-sm {
        padding: 2px 6px;
        font-size: 0.75rem;
    }
}

/* Match Interface */
.match-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: var(--spacing-xl);
}

.match-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.match-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
}

.match-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.match-container {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: var(--spacing-xl);
    width: 100%;
    max-width: 1000px;
}

.versus-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    position: relative;
}

.versus-line {
    width: 1px;
    height: 100%;
    background-color: var(--border-light);
}

.versus-circle {
    position: absolute;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.song-card {
    flex: 1;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal), border-color var(--transition-normal);
    cursor: pointer;
    max-width: 400px;
}

.song-card:hover {
    transform: translateY(-4px);
    border-color: var(--text-secondary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.song-thumbnail-container {
    padding: 0;
    position: relative;
    padding-top: 56.25%;
    /* 16:9 Aspect Ratio */
    background-color: #000;
}

.song-thumbnail {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.song-card:hover .song-thumbnail {
    opacity: 1;
}

.song-info {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
}

.song-title-large {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    line-height: 1.4;
    color: var(--text-primary);
}

.song-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.select-btn-area {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-tertiary);
}

/* Index Page Specifics */
.index-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    text-align: center;
}

.hero-header {
    margin-bottom: 40px;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.hero-desc {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    text-align: left;
}

.playlist-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition-fast);
}

.playlist-card:hover {
    border-color: var(--text-secondary);
    background-color: var(--bg-tertiary);
}

.playlist-card h3 {
    font-size: 1rem;
    margin-bottom: 8px;
    font-weight: 600;
}

.playlist-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.modal-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-weight: 600;
}

.modal-body {
    padding: var(--spacing-md);
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-active);
}

/* Responsive */
@media (max-width: 768px) {

    /* === Variables for mobile === */
    :root {
        --panel-width: 100%;
        --header-height: 50px;
    }

    body {
        overflow: auto;
        /* Allow scroll on mobile */
    }

    /* === Main Layout === */
    .main-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    /* === Sidebar / Ranking Panel === */
    .ranking-panel {
        position: fixed;
        top: 0;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        z-index: 1000;
        border-right: 1px solid var(--border-light);
        transition: left 0.3s ease;
        overflow-y: auto;
    }

    .ranking-panel.mobile-open {
        left: 0;
    }

    /* Mobile sidebar overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 999;
    }

    .mobile-overlay.active {
        display: block;
    }

    /* === Worldcup Panel === */
    .worldcup-panel {
        width: 100%;
        height: auto;
        min-height: 100vh;
        padding-top: var(--header-height);
    }

    /* === Mobile Header === */
    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: var(--header-height);
        background: var(--bg-secondary);
        border-bottom: 1px solid var(--border-light);
        align-items: center;
        padding: 0 var(--spacing-md);
        z-index: 998;
    }

    .mobile-menu-btn {
        display: flex !important;
        width: 44px;
        height: 44px;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        color: var(--text-primary);
        font-size: 1.5rem;
        cursor: pointer;
    }

    .mobile-title {
        flex: 1;
        text-align: center;
        font-size: 1.1rem;
        font-weight: 600;
    }

    /* === Match Area === */
    .match-container {
        flex-direction: column;
        gap: var(--spacing-md);
        padding: var(--spacing-md);
    }

    .song-card {
        width: 100%;
        min-height: 200px;
    }

    .versus-divider {
        width: 100%;
        height: 40px;
        flex-direction: row;
    }

    .versus-line {
        width: 100%;
        height: 1px;
    }

    /* === Buttons - Touch Friendly === */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
        font-size: 1rem;
    }

    .btn-sm {
        min-height: 40px;
        padding: 10px 16px;
    }

    /* === Fast Elo Cards === */
    .fast-elo-card {
        padding: 12px !important;
    }

    .fast-elo-card img {
        width: 70px !important;
        height: 40px !important;
    }

    /* === Song List === */
    .song-list-item {
        padding: var(--spacing-md);
    }

    .song-thumbnail {
        width: 50px;
        height: 50px;
    }

    /* === Accordion === */
    .accordion-header {
        padding: var(--spacing-md);
        min-height: 48px;
    }

    /* === Dialog === */
    .dialog-box {
        width: 95%;
        max-width: 400px;
        max-height: 90vh;
    }

    /* === Index page cards === */
    .playlist-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-md);
    }

    /* === Leaderboard === */
    .leaderboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .match-title {
        font-size: 1.2rem;
    }

    .match-subtitle {
        font-size: 0.85rem;
    }

    .song-card {
        min-height: 160px;
    }

    .fast-elo-card img {
        width: 60px !important;
        height: 34px !important;
    }

    .fast-elo-card {
        padding: 10px !important;
        gap: 8px !important;
    }
}

/* === Mobile Header (hidden on desktop) === */
.mobile-header {
    display: none;
}

.mobile-menu-btn {
    display: none;
}