/* style.css - Pastel Light Theme & Melon-like layout */
:root {
    --bg-color-start: #f8fafc;
    --bg-color-end: #f1f5f9;
    --ink: #0f172a;
    --muted: #475569;
    --card-bg: rgba(255, 255, 255, 0.55);
    --card-border: rgba(255, 255, 255, 0.7);
    --border-glass: rgba(15, 23, 42, 0.08);
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-accent: #8b5cf6; /* Pastel violet */
    
    --melon-green: #05c93c;
    --badge-up: #fee2e2;
    --badge-up-text: #ef4444;
    --badge-down: #e0f2fe;
    --badge-down-text: #0284c7;
    --badge-new: #f3e8ff;
    --badge-new-text: #9333ea;
    --badge-keep: #f1f5f9;
    --badge-keep-text: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Plus Jakarta Sans', 'Outfit', 'Noto Sans KR', sans-serif;
    color: var(--ink);
    min-height: 100vh;
    background-color: #f3f4f6;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(219, 234, 254, 0.6) 0%, transparent 45%),
        radial-gradient(circle at 90% 10%, rgba(252, 231, 243, 0.5) 0%, transparent 40%),
        radial-gradient(circle at 50% 80%, rgba(220, 252, 231, 0.4) 0%, transparent 50%),
        radial-gradient(circle at 20% 60%, rgba(243, 232, 255, 0.5) 0%, transparent 40%);
    background-attachment: fixed;
    display: flex;
    justify-content: center;
    padding: 24px 12px;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.012;
    z-index: 9999;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3e%3cfilter id='noise'%3e%3cfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3e%3c/filter%3e%3crect width='100%25' height='100%25' filter='url(%23noise)'/%3e%3c/svg%3e");
}

/* Container */
.container {
    width: 100%;
    max-width: 720px; /* Wider for desktop, but scales well for mobile */
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    z-index: 2;
}

/* Glassmorphism card */
.glass {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.04);
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.25rem 1rem 0.25rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.header-logo {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.logo-accent {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    color: transparent;
    background: linear-gradient(135deg, #7c3aed, #db2777);
    -webkit-background-clip: text;
    background-clip: text;
}

.logo-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.system-time {
    font-size: 1rem;
    font-weight: 700;
    color: var(--muted);
    background: rgba(15, 23, 42, 0.04);
    padding: 0.4rem 0.9rem;
    border-radius: 30px;
    border: 1px solid rgba(15, 23, 42, 0.05);
}

/* Meta info grid */
.meta-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.meta-card {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 0.25rem;
    border-radius: 16px;
    align-items: flex-start;
}

.meta-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--muted);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
}

.meta-value.highlight {
    color: #7c3aed;
}

/* Sections */
.section-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--ink);
    padding-left: 0.25rem;
}

.section-title .bullet {
    width: 5px;
    height: 1.1rem;
    background: linear-gradient(to bottom, #7c3aed, #db2777);
    border-radius: 3px;
    display: inline-block;
}

/* Melon-like live entries chart table */
.entries-chart {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--card-border);
}

.chart-header {
    display: flex;
    background: rgba(15, 23, 42, 0.02);
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.col-rank { width: 15%; text-align: center; }
.col-info { width: 65%; padding-left: 0.5rem; }
.col-change { width: 20%; text-align: center; }

.chart-row {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-glass);
    background: rgba(255, 255, 255, 0.2);
    transition: background-color 0.2s ease;
}

.chart-row:last-child {
    border-bottom: none;
}

.chart-row:hover {
    background: rgba(255, 255, 255, 0.6);
}

/* Rank column (Melon Style) */
.rank-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rank-num {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--ink);
    line-height: 1;
}

.rank-text {
    font-size: 0.6rem;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 2px;
}

/* Info column (Melon Style) */
.song-box {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    min-width: 0;
}

.album-img {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.song-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.song-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.song-artist {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Change column (Melon Style) */
.badge-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.badge {
    padding: 0.3rem 0.65rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    letter-spacing: 0.02em;
}

.badge.up {
    background-color: var(--badge-up);
    color: var(--badge-up-text);
}

.badge.down {
    background-color: var(--badge-down);
    color: var(--badge-down-text);
}

.badge.new {
    background-color: var(--badge-new);
    color: var(--badge-new-text);
}

.badge.keep {
    background-color: var(--badge-keep);
    color: var(--badge-keep-text);
}

/* Empty / Loading states */
.empty-state, .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    color: var(--muted);
    gap: 0.75rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.15);
}

.empty-state i {
    font-size: 2.2rem;
    color: rgba(15, 23, 42, 0.15);
}

.loading-state i {
    font-size: 1.8rem;
    color: var(--text-accent);
}

/* History table (Pastel styling) */
.history-table-container {
    overflow-x: auto;
    border: 1px solid var(--card-border);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.history-table th, .history-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-glass);
}

.history-table th {
    background: rgba(15, 23, 42, 0.02);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-table td {
    color: var(--ink);
}

.history-table tr:last-child td {
    border-bottom: none;
}

.history-table tbody tr {
    background: rgba(255, 255, 255, 0.15);
    transition: background-color 0.2s ease;
}

.history-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.45);
}

.text-center { text-align: center !important; }
.text-light { color: var(--muted); }

/* Footer */
footer {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.song-title-link, .history-song-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s ease;
}

.song-title-link:hover, .history-song-link:hover {
    color: var(--text-accent);
}
/* Collapsible Accordion Layout */
.collapsible-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.1rem 1.25rem;
    cursor: pointer;
}

.toggle-icon {
    font-size: 1rem;
    color: var(--muted);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.accordion-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.accordion-content.show {
    max-height: 3000px;
    opacity: 1;
    padding-top: 0.25rem;
}

.accordion-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

/* Platform Styles */
.platform-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.platform-title {
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 0.25rem;
    color: var(--text-accent);
}

.platform-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    object-fit: contain;
    margin-right: 6px;
}

/* Custom Platform Filter Tabs */
.platform-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    outline: none;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.25);
}

.tab-btn.active {
    background: var(--text-accent);
    color: #fff;
    border-color: var(--text-accent);
    box-shadow: 0 0 8px rgba(186, 104, 200, 0.35);
}

.tab-icon {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    object-fit: contain;
}

.platform-badge {
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
}

.platform-badge.melon { background-color: #00cd3c; }
.platform-badge.genie { background-color: #00a2ed; }
.platform-badge.flo { background-color: #5700ff; }
.platform-badge.vibe { background-color: #ff0050; }
.platform-badge.bugs { background-color: #ff3b30; }

/* Filter Bar Styling */
.filter-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.9rem 1.25rem;
    align-items: center;
    background: rgba(15, 23, 42, 0.3) !important;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-select {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: var(--ink);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    transition: border-color 0.2s;
    outline: none;
}

.filter-select:hover, .filter-select:focus {
    border-color: var(--text-accent);
}

.update-time-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-accent);
    margin-left: 8px;
    font-family: 'Outfit', sans-serif;
}

.provider-info {
    font-size: 0.7rem;
    color: var(--muted);
    margin-left: 6px;
    font-weight: 500;
    opacity: 0.8;
}

.platform-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    transition: opacity 0.2s;
}
.platform-link:hover {
    opacity: 0.8;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    body {
        padding: 12px 6px;
    }
    
    .container {
        gap: 1rem;
    }
    
    header {
        padding-bottom: 0.75rem;
    }
    
    .logo-accent {
        font-size: 1.4rem;
    }
    
    .meta-section {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }
    
    .meta-card {
        padding: 0.65rem;
        border-radius: 12px;
    }
    
    .meta-label {
        font-size: 0.6rem;
    }
    
    .meta-value {
        font-size: 0.8rem;
    }
    
    /* Chart columns scaling */
    .col-rank { width: 20%; }
    .col-info { width: 55%; }
    .col-change { width: 25%; }
    
    .chart-row {
        padding: 0.75rem 0.5rem;
    }
    
    .album-img {
        width: 2.8rem;
        height: 2.8rem;
    }
    
    .song-title {
        font-size: 0.9rem;
    }
    
    .song-artist {
        font-size: 0.75rem;
    }
    
    .rank-num {
        font-size: 1.15rem;
    }
    
    .badge {
        padding: 0.25rem 0.45rem;
        font-size: 0.7rem;
    }
    
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    .filter-group {
        justify-content: space-between;
    }
    .provider-info {
        display: block;
        width: 100%;
        margin-left: 0 !important;
        padding-left: 11px;
        margin-top: 2px;
    }
}

/* Melon Toggle Switch styles */
.melon-toggle-group {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.35);
    backdrop-filter: blur(12px);
    border-radius: 30px;
    padding: 3px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.melon-toggle-group .toggle-btn {
    background: none;
    border: none;
    outline: none;
    color: rgba(15, 15, 15, 0.55); /* Readable dark text for inactive buttons */
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.melon-toggle-group .toggle-btn:hover {
    color: #050505;
}

.melon-toggle-group .toggle-btn.active {
    background: #02bf74; /* Standard Melon green */
    color: #050505 !important; /* Keep black text active */
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(2, 191, 116, 0.4);
}
