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

/* ───────────────────────────────────
   DESIGN TOKENS
   ─────────────────────────────────── */
:root {
  --font: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Surface & Background */
  --bg-base: #f4f6f9;
  --bg-sidebar: #ffffff;
  --bg-card: #ffffff;
  --bg-section: #f8f9fb;
  --bg-input: #f4f6f9;

  /* Borders */
  --border-light: #e8ecf1;
  --border-medium: #dce1e8;
  --border-focus: #6366f1;

  /* Text */
  --text-primary: #111827;
  --text-secondary: #4b5563;
  --text-tertiary: #9ca3af;
  --text-inverse: #ffffff;

  /* Accent – Indigo / Radio brand red  */
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.08);
  --accent-ring: rgba(99, 102, 241, 0.25);
  --brand-red: #ef4444;
  --brand-red-soft: rgba(239, 68, 68, 0.08);

  /* Semantic */
  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.1);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.08);
  --warning: #f59e0b;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.06), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.06), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.2s;
}

/* ───────────────────────────────────
   RESET & BASE
   ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

/* ───────────────────────────────────
   LAYOUT SHELL
   ─────────────────────────────────── */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* ───────────────────────────────────
   SIDEBAR
   ─────────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 100;
  flex-shrink: 0;
  padding: 28px 0 20px;
  box-shadow: 1px 0 0 var(--border-light);
}

.brand {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text-primary);
  padding: 0 24px 24px;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--brand-red);
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--brand-red-soft);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px var(--brand-red-soft); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.04); }
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-actions {
  padding: 16px 16px 0;
  border-top: 1px solid var(--border-light);
  margin-top: 8px;
}

/* Sidebar Tabs */
.tab {
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--duration) var(--ease);
  text-align: left;
  position: relative;
}

.tab svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.75;
  fill: none;
  flex-shrink: 0;
  transition: color var(--duration) var(--ease);
}

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

.tab.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.tab.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

/* ───────────────────────────────────
   MAIN CANVAS
   ─────────────────────────────────── */
.main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  height: 100%;
  background: var(--bg-base);
}

/* ───────────────────────────────────
   CARDS
   ─────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

/* ───────────────────────────────────
   TYPOGRAPHY
   ─────────────────────────────────── */
h1, h2, h3, h4 {
  margin: 0 0 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  line-height: 1.3;
}

h1 {
  font-size: 1.75rem;
  margin-bottom: 24px;
}

h2 {
  font-size: 1.25rem;
  padding-bottom: 16px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
}

h2::before {
  content: "";
  width: 4px;
  height: 20px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 8px;
}

.hint {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  margin-top: 4px;
  line-height: 1.5;
}

.hint.error { color: var(--danger); font-weight: 500; }
.hint.ok { color: var(--success); font-weight: 500; }

/* ───────────────────────────────────
   FORMS
   ─────────────────────────────────── */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

input, textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 450;
  outline: none;
  transition: all var(--duration) var(--ease);
}

input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.span2 {
  grid-column: 1 / -1;
}

/* ───────────────────────────────────
   BUTTONS
   ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 9px 18px;
  background: #ffffff;
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.8125rem;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.btn:hover {
  background: var(--bg-section);
  border-color: var(--border-medium);
  box-shadow: var(--shadow-xs);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
  box-shadow: 0 1px 3px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--bg-section);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: var(--text-inverse);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

/* ───────────────────────────────────
   MODAL SYSTEM
   ─────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.25);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s var(--ease);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: min(850px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.25s var(--ease);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.btn-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-section);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  line-height: 1;
  padding: 0;
}

.btn-close:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.modal-section {
  background: var(--bg-section);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}

.modal h4 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 14px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal h4::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* ───────────────────────────────────
   LIST & ITEMS
   ─────────────────────────────────── */
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--duration) var(--ease);
}

.item:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.item.dragover-top {
  border-top: 2px solid var(--accent);
}

.item.dragover-bottom {
  border-bottom: 2px solid var(--accent);
}

.item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.item .title {
  font-weight: 600;
  font-size: 0.95rem;
}

.item .meta {
  color: var(--text-tertiary);
  font-size: 0.8rem;
}

.item-actions {
  display: flex;
  gap: 8px;
}

/* ───────────────────────────────────
   CHECKLINE / TOGGLE CARDS
   ─────────────────────────────────── */
.checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px;
  margin: 12px 0 20px;
}

.checkline {
  display: flex !important;
  flex-direction: row !important;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  user-select: none;
  text-transform: none !important;
  letter-spacing: 0 !important;
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  color: var(--text-primary) !important;
}

.checkline:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.checkline input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.checkline span {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* ───────────────────────────────────
   SEARCH RESULTS (iTunes / EarOne)
   ─────────────────────────────────── */
.search-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.search-result-item {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  transition: all var(--duration) var(--ease);
  background: var(--bg-section);
}

.search-result-item:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.search-result-item img {
  width: 100%;
  display: block;
  aspect-ratio: 1;
  object-fit: cover;
}

/* ───────────────────────────────────
   CHART / SCHEDULE ITEM ROWS
   ─────────────────────────────────── */
.chart-item-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  margin-bottom: 6px;
  transition: all var(--duration) var(--ease);
}

.chart-item-row:hover {
  border-color: var(--border-medium);
  box-shadow: var(--shadow-xs);
}

.chart-item-cover {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-section);
  border: 1px solid var(--border-light);
  flex-shrink: 0;
}

.chart-item-details {
  flex: 1;
  min-width: 0;
}

.chart-item-title {
  font-weight: 600;
  margin-bottom: 2px;
  display: block;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-item-artist {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-item-pos {
  font-size: 1.1rem;
  font-weight: 800;
  width: 32px;
  text-align: center;
  color: var(--accent);
  flex-shrink: 0;
}

/* ───────────────────────────────────
   DRAG & DROP
   ─────────────────────────────────── */
.chart-item-row[draggable="true"] {
  cursor: grab;
  user-select: none;
}

.chart-item-row[draggable="true"]:active {
  cursor: grabbing;
}

.chart-item-row.dragover-top {
  border-top: 2px solid var(--accent);
}

.chart-item-row.dragover-bottom {
  border-bottom: 2px solid var(--accent);
}

/* ───────────────────────────────────
   SCROLLBARS
   ─────────────────────────────────── */
.main::-webkit-scrollbar,
.modal::-webkit-scrollbar,
.list::-webkit-scrollbar,
#pemEpisodesList::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.main::-webkit-scrollbar-track,
.modal::-webkit-scrollbar-track,
.list::-webkit-scrollbar-track,
#pemEpisodesList::-webkit-scrollbar-track,
textarea::-webkit-scrollbar-track {
  background: transparent;
}

.main::-webkit-scrollbar-thumb,
.modal::-webkit-scrollbar-thumb,
.list::-webkit-scrollbar-thumb,
#pemEpisodesList::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 6px;
}

.main::-webkit-scrollbar-thumb:hover,
.modal::-webkit-scrollbar-thumb:hover,
.list::-webkit-scrollbar-thumb:hover,
#pemEpisodesList::-webkit-scrollbar-thumb:hover,
textarea::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* ───────────────────────────────────
   LOGIN PAGE
   ─────────────────────────────────── */
#loginView {
  max-width: 400px;
  margin: 15vh auto;
  text-align: center;
}

#loginView h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

#loginView .form {
  text-align: left;
}

/* ───────────────────────────────────
   RESPONSIVE
   ─────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 0;
  }

  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    padding: 0 12px;
  }

  .tab {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 0.8rem;
  }

  .tab.active::before {
    display: none;
  }

  .brand {
    padding: 0 16px 12px;
    font-size: 1rem;
  }

  .shell {
    flex-direction: column;
  }

  .main {
    padding: 20px 16px;
  }

  .card {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

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

  .sidebar-actions {
    display: none;
  }
}
