@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700&family=Instrument+Sans:wght@400;500;600;700&family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --bg: linear-gradient(90deg, #fef6f0 0%, #fdf2fd 100%);
  --card-bg: #fff;
  --card-shadow: 0 1px 21px rgba(0,0,0,0.08);
  --card-radius: 19px;
  --text-primary: #000;
  --text-secondary: #444;
  --text-muted: #777;
  --accent-purple: #7C4DFF;
  --accent-pink: #FF48BC;
  --accent-cyan: #0ED7FF;
  --accent-red: #FF2A2A;
  --accent-green: #00C853;
  --border: rgba(0,0,0,0.06);
  --sidebar-w: 250px;
}

html, body { height: 100%; width: 100%; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Instrument Sans', 'Inter', sans-serif;
  background: linear-gradient(90deg, #fef6f0 0%, #fdf2fd 100%);
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--card-bg);
  box-shadow: 1px 0 20px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: relative;
  z-index: 30;
}

.sidebar-logo {
  padding: 22px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo .tmc-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: contain;
}

.sidebar-logo h1 {
  font-family: 'Lexend', sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.sidebar-logo .tmc-sub {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  display: block;
  margin-top: -1px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 12px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: #f8f6fc; color: var(--text-primary); }
.nav-item.active {
  background: #f0eaff;
  color: var(--accent-purple);
  font-weight: 600;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: #fafafa;
  margin-bottom: 10px;
}

.sidebar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-avatar img { width: 100%; height: 100%; object-fit: cover; }

.sidebar-user-info { overflow: hidden; }
.sidebar-username {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-handle {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-copy {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
}

/* ── Main Content ── */
.main {
  flex: 1;
  min-height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(90deg, rgba(254,246,240,0.85) 0%, rgba(253,242,253,0.85) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.topbar h2 {
  font-family: 'Lexend', sans-serif;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 4px;
}
.mobile-menu-btn svg { width: 22px; height: 22px; }

.content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Views ── */
.view { display: none; }
.view.active { display: block; }

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 24px;
  margin-bottom: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 28px rgba(0,0,0,0.1);
}

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

.card-title {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.1);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 20px; height: 20px; color: #fff; }

.stat-icon.purple { background: linear-gradient(135deg, #7C4DFF, #536DFE); }
.stat-icon.pink { background: linear-gradient(135deg, #FF48BC, #FF6EC7); }
.stat-icon.cyan { background: linear-gradient(135deg, #0ED7FF, #00B4D8); }
.stat-icon.green { background: linear-gradient(135deg, #00C853, #69F0AE); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}

.stat-value {
  font-family: 'Lexend', sans-serif;
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* ── Now Playing Card ── */
.now-playing-card {
  background: linear-gradient(135deg, #faf8ff, #fff5fb);
  border: none;
}

.np-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

.np-art {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.np-art svg { width: 24px; height: 24px; color: #fff; position: relative; z-index: 1; }

.np-art::before {
  content: '';
  position: absolute;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, rgba(255,255,255,0.15), transparent);
  animation: spin 6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.np-meta h3 {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
}
.np-meta p { font-size: 14px; color: var(--text-secondary); margin-top: 2px; }

.np-controls {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.station-meta {
  text-align: right;
  flex-shrink: 0;
}

.station-meta .listeners {
  font-family: 'Lexend', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
}

.station-meta .listeners-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 12px;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
  color: inherit;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: #000;
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(0,0,0,0.15); }

.btn-accent {
  background: var(--accent-purple);
  color: #fff;
  box-shadow: 0 4px 16px rgba(124,77,255,0.25);
}
.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 6px 24px rgba(124,77,255,0.35); }

.btn-danger {
  background: #FFF0F0;
  color: var(--accent-red);
}
.btn-danger:hover { background: #FFE0E0; }

.btn-ghost {
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1.5px solid rgba(0,0,0,0.1);
}
.btn-ghost:hover { border-color: rgba(0,0,0,0.2); transform: translateY(-1px); }

.btn-green {
  background: #E8F5E9;
  color: #2e7d32;
}
.btn-green:hover { background: #C8E6C9; }

.btn-sm { padding: 7px 14px; font-size: 12px; border-radius: 10px; }

/* ── Station Card (stations list) ── */
.station-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 12px;
  transition: all 0.2s;
}

.station-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}

.station-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.station-dot.live {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(0,200,83,0.4);
  animation: pulse-dot 2s ease-in-out infinite;
}
.station-dot.offline { background: #ccc; }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.station-info { flex: 1; }
.station-info h3 {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 16px;
  font-weight: 600;
}
.station-info p { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── Media Table ── */
.media-table {
  width: 100%;
  border-collapse: collapse;
}

.media-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.media-table td {
  font-size: 14px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.media-table tr:hover td { background: #faf8ff; }
.media-table .title-cell { font-weight: 600; }
.media-table .dim { color: var(--text-muted); }

/* ── Upload Area ── */
.upload-area {
  border: 2px dashed rgba(124,77,255,0.25);
  border-radius: var(--card-radius);
  padding: 44px 20px;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
  margin-bottom: 20px;
  background: rgba(124,77,255,0.02);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent-purple);
  background: rgba(124,77,255,0.05);
}

.upload-area .upload-icon {
  margin-bottom: 12px;
  color: var(--accent-purple);
}
.upload-area .upload-icon svg { width: 36px; height: 36px; }
.upload-area p { font-size: 14px; color: var(--text-secondary); }
.upload-area .upload-hint { font-size: 12px; margin-top: 6px; color: var(--text-muted); }

/* ── History ── */
.history-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.history-meta { flex: 1; }
.history-meta h4 { font-size: 14px; font-weight: 600; }
.history-meta p { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

.history-time {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--card-bg);
  border-radius: 22px;
  padding: 32px;
  width: 440px;
  max-width: 90vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.15);
}

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

.modal-header h3 {
  font-family: 'Lexend', sans-serif;
  font-size: 20px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: all 0.15s;
}
.modal-close:hover { background: #f5f5f5; color: var(--text-primary); }

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input, .form-group select, .select-input {
  width: 100%;
  padding: 11px 14px;
  background: #fafafa;
  border: 1.5px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus, .form-group select:focus, .select-input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(124,77,255,0.12);
}

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

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}

/* ── Select Input ── */
.select-input {
  width: auto;
  padding: 9px 14px;
  cursor: pointer;
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { margin-bottom: 12px; color: #ccc; }
.empty-state .empty-icon svg { width: 48px; height: 48px; }
.empty-state h3 {
  font-family: 'Lexend', sans-serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.empty-state p { font-size: 14px; }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-green { background: #e8f5e9; color: #2e7d32; }
.badge-red { background: #fce4ec; color: #c62828; }
.badge-purple { background: #f0eaff; color: var(--accent-purple); }

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 25;
}

/* ── Scrollbar ── */
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: #ddd; border-radius: 3px; }
.main::-webkit-scrollbar-thumb:hover { background: #bbb; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100vh;
    transition: left 0.25s ease;
    z-index: 30;
  }

  .sidebar.open { left: 0; }
  .sidebar-overlay.show { display: block; }

  .mobile-menu-btn { display: block; }

  .main { width: 100%; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px; }
  .stat-icon { width: 38px; height: 38px; }
  .stat-icon svg { width: 16px; height: 16px; }
  .stat-value { font-size: 22px; }

  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .topbar h2 { font-size: 17px; }

  .np-controls { gap: 6px; }
  .btn-sm { padding: 6px 10px; font-size: 11px; }

  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .np-info { flex-direction: column; text-align: center; }
  .station-meta { text-align: center; }
  .np-controls { justify-content: center; }
}
