/* =============================================
   Radio Recorder - Blue Light / Dark UI
   ============================================= */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121c;
    --bg-tertiary: #1a1a28;
    --bg-card: rgba(18, 18, 28, 0.75);
    --bg-card-hover: rgba(26, 26, 40, 0.85);

    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    --text-primary: #e8e8ee;
    --text-secondary: #9898a8;
    --text-muted: #5a5a6e;

    --accent-blue: #2563eb;
    --accent-blue-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.12);
    --accent-purple: #2563eb;
    --accent-pink: #ec4899;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-orange: #f59e0b;

    --kbs-color: #3b82f6;
    --mbc-color: #10b981;
    --sbs-color: #f43f5e;
    --ebs-color: #f59e0b;
    --cbs-color: #8b5cf6;
    --tbs-color: #06b6d4;
    --bbs-color: #f97316;
    --obs-color: #84cc16;
    --ytn-color: #e11d48;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);

    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color-scheme: dark;
}

:root[data-theme="light"] {
    --bg-primary: #f4f7fb;
    --bg-secondary: rgba(255, 255, 255, 0.92);
    --bg-tertiary: #eaf0f8;
    --bg-card: rgba(255, 255, 255, 0.94);
    --bg-card-hover: #ffffff;
    --border: rgba(15, 23, 42, 0.10);
    --border-hover: rgba(37, 99, 235, 0.28);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
    color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* =============================================
   Header
   ============================================= */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(74, 158, 255, 0.4));
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.theme-toggle {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 17px;
}

.theme-toggle:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

:root[data-theme="light"] .header-logo { filter: drop-shadow(0 0 8px rgba(37, 99, 235, 0.2)); }
:root[data-theme="light"] .header,
:root[data-theme="light"] .tabs { box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04); }
:root[data-theme="light"] .file-group-header:hover,
:root[data-theme="light"] .file-item:hover,
:root[data-theme="light"] .stats-file-item:hover { background: rgba(37, 99, 235, 0.05); }
:root[data-theme="light"] .file-item,
:root[data-theme="light"] .stats-file-item { border-color: rgba(15, 23, 42, 0.07); }
:root[data-theme="light"] .live-player-bar { background: rgba(255, 255, 255, 0.96); }
:root[data-theme="light"] .modal-overlay { background: rgba(15, 23, 42, 0.35); }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border);
}

.user-name {
    font-size: 13px;
    color: var(--text-secondary);
}

/* =============================================
   Tabs
   ============================================= */
.tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab.active {
    background: rgba(74, 158, 255, 0.12);
    color: var(--accent-blue);
}

/* =============================================
   Content
   ============================================= */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 22px;
    font-weight: 600;
}

/* =============================================
   Cards
   ============================================= */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

/* =============================================
   Station Cards
   ============================================= */
.network-group h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 24px 0 12px;
    padding-left: 4px;
}

.network-group h3.kbs { color: var(--kbs-color); }
.network-group h3.mbc { color: var(--mbc-color); }
.network-group h3.sbs { color: var(--sbs-color); }

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

.station-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
}

.station-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.station-dot {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    flex-shrink: 0;
}

.station-dot.kbs { background: rgba(59, 130, 246, 0.15); color: var(--kbs-color); }
.station-dot.mbc { background: rgba(16, 185, 129, 0.15); color: var(--mbc-color); }
.station-dot.sbs { background: rgba(244, 63, 94, 0.15); color: var(--sbs-color); }

.station-info { flex: 1; min-width: 0; }

.station-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.station-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.station-status.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
}

.station-status.offline { background: var(--accent-red); }
.station-status.testing {
    background: var(--accent-orange);
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* =============================================
   Schedule List
   ============================================= */
.schedule-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    transition: var(--transition);
}

.schedule-item:hover {
    border-color: var(--border-hover);
}

.schedule-item.disabled {
    opacity: 0.4;
}

.schedule-time {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 80px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.schedule-info { flex: 1; }

.schedule-label {
    font-size: 15px;
    font-weight: 500;
}

.schedule-details {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.schedule-days {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}

.day-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(74, 158, 255, 0.1);
    color: var(--accent-blue);
}

.schedule-actions {
    display: flex;
    gap: 6px;
}

/* =============================================
   Recording Status
   ============================================= */
.quick-record {
    margin-bottom: 20px;
}

.quick-record-form {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.quick-record-form .input { flex: 1; }
.quick-record-form input[type="number"] { max-width: 80px; }

.recording-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    position: relative;
    overflow: hidden;
}

.recording-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(239, 68, 68, 0.08);
    transition: width 0.5s linear;
}

.rec-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent-red);
    flex-shrink: 0;
    animation: rec-pulse 1.5s ease-in-out infinite;
    position: relative;
    z-index: 1;
}

@keyframes rec-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.rec-info {
    flex: 1;
    position: relative;
    z-index: 1;
}

.rec-name { font-weight: 600; }
.rec-time { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.rec-progress {
    width: 120px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.rec-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-red), var(--accent-orange));
    border-radius: 3px;
    transition: width 1s linear;
}

/* =============================================
   File List
   ============================================= */
.file-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 6px;
    transition: var(--transition);
}

.file-item:hover {
    border-color: var(--border-hover);
}

.file-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.file-info { flex: 1; min-width: 0; }

.file-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.file-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* 인라인 오디오 플레이어 */
.audio-player {
    width: 100%;
    margin-top: 8px;
    height: 32px;
    border-radius: 8px;
}

audio::-webkit-media-controls-panel {
    background: var(--bg-tertiary);
}

/* =============================================
   Buttons
   ============================================= */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-sm { padding: 6px 14px; font-size: 13px; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    color: white;
}
.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(74, 158, 255, 0.3);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: white;
}
.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.3);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-icon {
    padding: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* =============================================
   Form Elements
   ============================================= */
.input {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: var(--transition);
    width: 100%;
}

.input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.15);
}

select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239898a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.day-selector {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.day-chip {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: var(--transition);
    user-select: none;
}

.day-chip input { display: none; }

.day-chip:has(input:checked) {
    background: rgba(74, 158, 255, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.setting-row {
    margin-bottom: 12px;
}

.setting-row label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.feed-url-row {
    display: flex;
    gap: 8px;
}

.feed-url-row .input {
    flex: 1;
    font-size: 12px;
    font-family: monospace;
}

/* =============================================
   Modal
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.visible {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal {
    width: 100%;
    max-width: 480px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 18px; }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* =============================================
   Toast
   ============================================= */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    font-size: 14px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    min-width: 280px;
}

.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error { border-left: 3px solid var(--accent-red); }
.toast.info { border-left: 3px solid var(--accent-blue); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* =============================================
   Utility
   ============================================= */
.text-muted { color: var(--text-muted); font-size: 13px; }
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .header { padding: 12px 16px; }
    .header-title { font-size: 16px; }
    .user-name { display: none; }
    .tabs { padding: 8px 16px; gap: 2px; }
    .tab { padding: 8px 14px; font-size: 13px; }
    .content { padding: 16px; }
    .station-grid { grid-template-columns: 1fr; }
    .quick-record-form { flex-wrap: wrap; }
    .form-row { grid-template-columns: 1fr; }
    .schedule-item { flex-wrap: wrap; }
    .schedule-time { min-width: auto; }
    .modal { margin: 16px; }
    .live-station-grid { grid-template-columns: 1fr; }
}

/* =============================================
   Live Player Bar (fixed bottom)
   ============================================= */
.live-player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 500;
    background: rgba(12, 12, 22, 0.95);
    backdrop-filter: blur(24px);
    border-top: 1px solid rgba(74, 158, 255, 0.3);
    padding: 12px 24px;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.4);
    padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.live-player-bar.visible {
    display: flex;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.live-player-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.live-badge {
    padding: 3px 8px;
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: white;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 1px;
    border-radius: 4px;
    flex-shrink: 0;
    animation: live-blink 2s ease-in-out infinite;
}

@keyframes live-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.live-station-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

/* 음파 애니메이션 */
.live-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.3s;
}

.live-wave.playing {
    opacity: 1;
}

.live-wave span {
    display: block;
    width: 3px;
    border-radius: 3px;
    background: var(--accent-blue);
    animation: wave-bar 1.2s ease-in-out infinite;
}

.live-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.live-wave span:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.live-wave span:nth-child(3) { height: 24px; animation-delay: 0.2s; }
.live-wave span:nth-child(4) { height: 16px; animation-delay: 0.3s; }
.live-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }

@keyframes wave-bar {
    0%, 100% { transform: scaleY(0.4); }
    50% { transform: scaleY(1); }
}

.live-play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    box-shadow: 0 0 16px rgba(74, 158, 255, 0.4);
}

.live-play-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 24px rgba(74, 158, 255, 0.6);
}

.live-stop-btn {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.live-control-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.live-control-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.live-stop-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* =============================================
   Live Station Grid
   ============================================= */
.live-station-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.live-station-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.live-station-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(74, 158, 255, 0.03));
    opacity: 0;
    transition: opacity 0.3s;
}

.live-station-card:hover {
    border-color: rgba(74, 158, 255, 0.4);
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(74, 158, 255, 0.1);
}

.live-station-card:hover::before { opacity: 1; }

.live-station-card.playing {
    border-color: rgba(74, 158, 255, 0.6);
    background: rgba(74, 158, 255, 0.06);
    box-shadow: 0 0 24px rgba(74, 158, 255, 0.15);
}

.live-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.live-icon.kbs { background: rgba(59, 130, 246, 0.15); color: var(--kbs-color); }
.live-icon.mbc { background: rgba(16, 185, 129, 0.15); color: var(--mbc-color); }
.live-icon.sbs { background: rgba(244, 63, 94, 0.15); color: var(--sbs-color); }

.live-info {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.live-name {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.live-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.live-action {
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(74, 158, 255, 0.1);
    color: var(--accent-blue);
    font-size: 14px;
    transition: var(--transition);
}

.live-station-card:hover .live-action {
    background: rgba(74, 158, 255, 0.2);
    transform: scale(1.1);
}

.live-station-card.playing .live-action {
    background: rgba(74, 158, 255, 0.25);
    animation: action-pulse 2s ease-in-out infinite;
}

@keyframes action-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 158, 255, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(74, 158, 255, 0); }
}

/* content padding adjustment when player bar is visible */
.content.player-visible {
    padding-bottom: 100px;
}

/* safe area support for iOS */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .content.player-visible {
        padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
}

/* =============================================
   Toggle Switch
   ============================================= */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 28px;
    transition: var(--transition);
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: var(--transition);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-color: var(--accent-blue);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
    background-color: white;
}

/* Ad detection card */
.ad-detection-card {
    margin-bottom: 16px;
    border-left: 3px solid var(--accent-purple);
}

.ad-detection-card h3 {
    margin: 0;
    font-size: 15px;
}

/* =============================================
   File Management
   ============================================= */
.file-summary {
    font-size: 13px;
    color: var(--text-muted);
    padding: 8px 0 12px;
}

.file-group {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.file-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.file-group-header:hover { background: rgba(255,255,255,0.04); }

.file-group-arrow {
    font-size: 11px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.file-group.collapsed .file-group-arrow { transform: rotate(-90deg); }
.file-group.collapsed .file-group-body { display: none; }

.file-group-date {
    font-weight: 600;
    font-size: 14px;
}

.file-group-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.file-group-body {
    border-top: 1px solid var(--border);
}

.file-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    transition: var(--transition);
}

.file-item:last-child { border-bottom: none; }
.file-item:hover { background: rgba(255,255,255,0.02); }

.file-item.clean-file {
    border-left: 3px solid var(--accent-green);
}

.checkbox-wrap {
    display: flex;
    align-items: center;
    padding-top: 2px;
    cursor: pointer;
}

.checkbox-wrap input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Bulk Action Bar */
.file-search-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto auto auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 12px;
}

.file-search-result {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.bulk-action-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    gap: 12px;
}

.bulk-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.bulk-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.bulk-action-bar:not(.has-selection) .bulk-buttons {
    opacity: 0.4;
    pointer-events: none;
}

@media (max-width: 768px) {
    /* 전체 레이아웃 */
    .header {
        padding: 14px 18px;
    }
    
    .header h1 {
        font-size: 20px;
    }

    .content {
        padding: 16px;
        padding-bottom: 160px; /* 플레이어 바와 탭 높이 고려하여 충분히 여백 지정 */
    }

    /* 탭 네비게이션 (모바일에서 가로 스크롤 가능하게) */
    .tabs {
        padding: 4px 12px;
        gap: 6px;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .tabs::-webkit-scrollbar {
        display: none;
    }
    
    .tab {
        padding: 12px 16px;
        font-size: 14px;
        flex-shrink: 0;
    }

    /* 방송국 그리드 - 모바일에서 1열로 (이름이 길어 2열 시 잘림) */
    .station-grid, .live-station-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .live-station-card {
        padding: 16px 18px;
        min-height: auto;
    }

    .live-name, .station-name {
        font-size: 16px;
    }

    .live-sub, .station-meta {
        font-size: 13px;
    }

    /* 플레이어 바 - 모바일에서 레이아웃 조정 */
    .live-player-bar {
        padding: 14px 20px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        flex-direction: column;
        align-items: center;
        gap: 14px;
    }

    .live-player-info {
        width: 100%;
        justify-content: center;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        padding-bottom: 10px;
    }

    .live-station-name {
        font-size: 17px;
    }

    .live-player-controls {
        width: 100%;
        justify-content: space-around;
    }

    /* 파일 목록 - 정보와 액션 분리 */
    .file-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 16px;
    }
    
    .file-info {
        width: 100%;
    }

    .file-name {
        font-size: 15px;
    }

    .file-meta {
        font-size: 13px;
    }

    .file-actions {
        width: 100%;
        justify-content: flex-end;
        padding-top: 10px;
        border-top: 1px solid rgba(255,255,255,0.05);
        gap: 8px;
    }

    /* 모달 조정 */
    .modal {
        width: 94%;
        margin: 20px auto;
        max-height: 85vh;
        overflow-y: auto;
    }

    .modal-header h3 {
        font-size: 20px;
    }

    /* 입력창 포커싱 시 줌인 현상 방지하기 위해 최소 16px 강제 */
    .input, select.input, .form-group input, .form-group select {
        font-size: 16px !important;
        padding: 12px 14px;
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .day-selector {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .day-chip {
        flex: 1;
        min-width: 65px;
        padding: 10px 0;
        font-size: 14px;
        text-align: center;
        justify-content: center;
    }

    .schedule-label {
        font-size: 16px;
    }

    .schedule-details {
        font-size: 13px;
    }

    /* 버튼 터치 영역 확보 */
    .btn {
        padding: 12px 18px;
        font-size: 15px;
        min-height: 46px;
    }

    .btn-sm {
        padding: 8px 16px;
        font-size: 14px;
        min-height: 38px;
    }

    .bulk-action-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px;
    }

    .file-search-bar {
        grid-template-columns: 1fr 1fr;
    }

    .file-search-bar .input,
    .file-search-result {
        grid-column: 1 / -1;
    }
    
    .bulk-info {
        font-size: 14px;
    }

    .bulk-buttons {
        justify-content: space-between;
        gap: 8px;
    }
    
    .bulk-buttons .btn {
        flex: 1;
    }
}

/* =============================================
   Calendar View
   ============================================= */
.calendar-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-top: 12px;
}

.calendar-grid-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(90px, auto);
    gap: 6px;
}

.calendar-day {
    background-color: var(--bg-base);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px;
    display: flex;
    flex-direction: column;
    min-height: 90px;
    position: relative;
    box-sizing: border-box;
}

.calendar-day.today {
    border-color: var(--accent-blue);
    background-color: rgba(59, 130, 246, 0.05);
}

.calendar-day.other-month {
    opacity: 0.25;
}

.calendar-day-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.calendar-day.today .calendar-day-num {
    color: var(--accent-blue);
}

.calendar-events {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    max-height: 110px;
    scrollbar-width: none;
}

.calendar-events::-webkit-scrollbar {
    display: none;
}

.calendar-event {
    font-size: 10px;
    padding: 2px 4px;
    border-radius: 4px;
    color: #ffffff;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 2px;
    transition: transform 0.1s;
    user-select: none;
}

.calendar-event:hover {
    transform: scale(1.03);
    filter: brightness(1.1);
}

.calendar-event:active {
    transform: scale(0.97);
}

/* Station/Network specific colors */
.event-kbs { background-color: #2563eb; }
.event-sbs { background-color: #ea580c; }
.event-mbc { background-color: #059669; }
.event-ebs { background-color: #7c3aed; }
.event-tbs { background-color: #e11d48; }
.event-cbs { background-color: #0284c7; }
.event-wbs { background-color: #65a30d; }
.event-cpbc { background-color: #c026d3; }
.event-default { background-color: #4b5563; }

/* Responsive adjustments for Calendar */
@media (max-width: 768px) {
    .calendar-grid {
        grid-auto-rows: minmax(70px, auto);
        gap: 4px;
    }
    
    .calendar-day {
        min-height: 70px;
        padding: 4px;
    }

    .calendar-day-num {
        font-size: 11px;
    }

    .calendar-event {
        font-size: 9px;
        padding: 1px 2px;
    }
}

/* =============================================
   Calendar Day Click & Details list styling
   ============================================= */
.calendar-day {
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.calendar-day:hover {
    border-color: rgba(74, 158, 255, 0.4);
    background-color: rgba(255, 255, 255, 0.02);
}

.calendar-day.selected {
    border-color: var(--accent-blue);
    background-color: rgba(74, 158, 255, 0.08);
    box-shadow: 0 0 12px rgba(74, 158, 255, 0.2);
}

.calendar-details-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-top: 24px;
    animation: fadeIn 0.3s ease;
}

/* =============================================
   Stats Tab - summary and accordion
   ============================================= */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

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

.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stats-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow);
}

.stats-card.expanded {
    border-color: rgba(74, 158, 255, 0.3);
}

.stats-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.stats-station-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.stats-network-badge {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stats-arrow {
    font-size: 12px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.stats-card.expanded .stats-arrow {
    transform: rotate(180deg);
}

.stats-card-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.stats-meta-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stats-meta-label {
    font-size: 11px;
    color: var(--text-muted);
}

.stats-meta-val {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.stats-file-list {
    border-top: 1px solid var(--border);
    padding-top: 12px;
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    scrollbar-width: thin;
}

.stats-file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.02);
}

.stats-file-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.04);
}

.stats-file-item.clean-file {
    border-left: 3px solid var(--accent-green);
}

.stats-file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
