/* ================================================================
   FebRadio Station v4 — Main CSS
   Font: Kanit | Palette: Sky-500 → Teal-500 gradient
   ================================================================ */

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --primary-from:   #0ea5e9;
  --primary-to:     #14b8a6;
  --primary-mid:    #0891b2;
  --bg-from:        #f0f9ff;
  --bg-to:          #f0fdfa;
  --surface:        #ffffff;
  --surface-2:      #f8fafc;
  --border:         #e2e8f0;
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --success:        #10b981;
  --warning:        #f59e0b;
  --danger:         #ef4444;
  --info:           #3b82f6;
  --radius-sm:      8px;
  --radius:         16px;
  --radius-lg:      24px;
  --radius-pill:    999px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:      0 10px 30px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);
  --nav-height:     64px;
  --transition:     .2s ease;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'Kanit', sans-serif;
  font-weight: 400;
  color: var(--text-primary);
  background: linear-gradient(135deg, var(--bg-from) 0%, var(--bg-to) 100%);
  min-height: 100vh;
  line-height: 1.6;
}

img { max-width: 100%; display: block; }
a   { color: var(--primary-from); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-to); }

/* ─── Navbar ────────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(90deg, var(--primary-from), var(--primary-to));
  height: var(--nav-height);
  box-shadow: 0 2px 16px rgba(14,165,233,.3);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: .625rem;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  flex-shrink: 0;
}

.nav-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.nav-brand-sub  { font-size: .65rem; font-weight: 300; opacity: .85; }

.nav-links {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav-link {
  color: rgba(255,255,255,.85);
  padding: .375rem .75rem;
  border-radius: var(--radius-pill);
  font-weight: 500;
  font-size: .9rem;
  transition: background var(--transition), color var(--transition);
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.2);
  color: white;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-left: .5rem;
  padding-left: .75rem;
  border-left: 1px solid rgba(255,255,255,.25);
}

.nav-user-name  { color: white; font-size: .875rem; font-weight: 500; }
.nav-role-badge {
  padding: .125rem .5rem;
  border-radius: var(--radius-pill);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.nav-role-badge.role-admin   { background: #7c3aed; color: white; }
.nav-role-badge.role-station { background: #0284c7; color: white; }
.nav-role-badge.role-dj      { background: #059669; color: white; }
.nav-role-badge.role-tech    { background: #d97706; color: white; }

.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px; height: 18px;
  background: #ef4444;
  color: white;
  font-size: .65rem;
  font-weight: 700;
  border-radius: 50%;
  margin-left: .25rem;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: .25rem;
  margin-left: auto;
}
.nav-toggle span {
  display: block;
  width: 22px; height: 2px;
  background: white;
  border-radius: 2px;
  transition: var(--transition);
}

/* ─── Page Layout ───────────────────────────────────────────── */
.page-main { padding-bottom: 4rem; min-height: calc(100vh - var(--nav-height)); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-header {
  padding: 2rem 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-subtitle { color: var(--text-secondary); font-size: .9rem; margin-top: .25rem; }

/* ─── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-body  { padding: 1.5rem; }

/* ─── Stat Cards (dashboard) ────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 1rem; margin-bottom: 1.5rem; }

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 1.5rem;
}
.stat-icon.blue  { background: #e0f2fe; }
.stat-icon.teal  { background: #ccfbf1; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.amber { background: #fef3c7; }
.stat-icon.red   { background: #fee2e2; }

.stat-value { font-size: 1.875rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--text-secondary); font-size: .85rem; margin-top: .25rem; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  padding: .5rem 1.25rem;
  border-radius: var(--radius-pill);
  font-family: 'Kanit', sans-serif;
  font-weight: 500;
  font-size: .875rem;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .3rem .875rem; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
  color: white;
  border-color: transparent;
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(14,165,233,.35); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { background: #e2e8f0; }

.btn-success  { background: var(--success);  color: white; border-color: transparent; }
.btn-danger   { background: var(--danger);   color: white; border-color: transparent; }
.btn-warning  { background: var(--warning);  color: white; border-color: transparent; }
.btn-info     { background: var(--info);     color: white; border-color: transparent; }

.btn-outline {
  background: transparent;
  color: var(--primary-from);
  border-color: var(--primary-from);
}
.btn-outline:hover { background: var(--primary-from); color: white; }

.btn-outline-white {
  background: transparent;
  color: white;
  border-color: rgba(255,255,255,.6);
}
.btn-outline-white:hover { background: rgba(255,255,255,.15); }

.btn-icon {
  padding: .4rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-icon:hover { background: var(--surface-2); }

/* ─── Forms ─────────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: .375rem; }
.form-group + .form-group { margin-top: 1rem; }
label { font-size: .875rem; font-weight: 500; color: var(--text-secondary); }

.form-control {
  width: 100%;
  padding: .625rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Kanit', sans-serif;
  font-size: .9rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-from);
  box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.input-icon-wrap { position: relative; }
.input-icon-wrap .form-control { padding-right: 2.75rem; }
.toggle-pw {
  position: absolute; right: .75rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0;
}
.toggle-pw:hover { color: var(--text-primary); }

/* ─── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: .875rem 1.125rem;
  border-radius: var(--radius-sm);
  font-size: .9rem;
  margin-bottom: 1rem;
}
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }

/* ─── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead tr { background: linear-gradient(90deg, var(--primary-from), var(--primary-to)); }
thead th { padding: .875rem 1rem; color: white; font-weight: 600; text-align: left; white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--surface-2); }
td { padding: .75rem 1rem; vertical-align: middle; }

/* ─── Badges ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .6rem;
  border-radius: var(--radius-pill);
  font-size: .75rem;
  font-weight: 600;
}
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-new      { background: linear-gradient(135deg, var(--primary-from), var(--primary-to)); color: white; }
.badge-muted    { background: #f1f5f9; color: var(--text-secondary); }

/* ─── Spinner ───────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner-dark {
  border-color: var(--border);
  border-top-color: var(--primary-from);
}

/* ─── Login Page ────────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0c4a6e 0%, #0f766e 100%);
}
.login-wrapper { width: 100%; max-width: 420px; padding: 1.5rem; }
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo    { display: flex; justify-content: center; margin-bottom: 1rem; }
.login-title   { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin-bottom: .25rem; }
.login-sub     { color: var(--text-secondary); font-size: .9rem; margin-bottom: 1.75rem; }
.login-form    { text-align: left; }
.login-form .btn { margin-top: 1.25rem; }

/* ─── Program Cards (station view) ─────────────────────────── */
.program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.program-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.program-card-banner {
  width: 100%;
  height: 140px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
}
.program-card-banner-placeholder {
  height: 140px;
  background: linear-gradient(135deg, var(--primary-from), var(--primary-to));
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.7); font-size: 2rem;
}

.program-card-body { padding: 1.25rem; flex: 1; }
.program-card-name { font-size: 1rem; font-weight: 600; margin-bottom: .75rem; }

/* ─── File list cards ───────────────────────────────────────── */
.file-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: .5rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.file-card-top {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}
.file-card-icon { color: var(--primary-from); flex-shrink: 0; }
.file-card-name {
  font-size: .85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.file-card-bottom {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ─── Upload / Drag & Drop ──────────────────────────────────── */
.dropzone {
  border: 2.5px dashed var(--primary-from);
  border-radius: var(--radius);
  padding: 3rem 2rem;
  text-align: center;
  background: #f0f9ff;
  transition: all var(--transition);
  cursor: pointer;
}
.dropzone.drag-over {
  background: #e0f2fe;
  border-color: var(--primary-to);
  box-shadow: 0 0 0 4px rgba(14,165,233,.1);
}
.dropzone-icon   { font-size: 3rem; color: var(--primary-from); margin-bottom: .75rem; }
.dropzone-text   { font-weight: 600; color: var(--text-primary); margin-bottom: .25rem; }
.dropzone-sub    { color: var(--text-secondary); font-size: .85rem; }
.dropzone input  { display: none; }

/* ─── Progress bar ──────────────────────────────────────────── */
.progress-wrap {
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  height: 8px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-from), var(--primary-to));
  border-radius: var(--radius-pill);
  transition: width .3s ease;
  width: 0%;
}

/* ─── Upload queue ──────────────────────────────────────────── */
.upload-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  margin-bottom: .5rem;
}
.upload-item-header { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.upload-item-name   { font-size: .85rem; font-weight: 500; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-status      { font-size: .75rem; font-weight: 600; }
.status-uploading   { color: var(--info); }
.status-done        { color: var(--success); }
.status-error       { color: var(--danger); }

/* ─── Audio Player Bar ──────────────────────────────────────── */
.audio-player-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(90deg, #0c4a6e, #0f766e);
  padding: .75rem 1.5rem;
  box-shadow: 0 -4px 20px rgba(0,0,0,.2);
  z-index: 200;
}
.audio-player-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.audio-info {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: white;
  min-width: 0;
  flex-shrink: 0;
  max-width: 240px;
}
.audio-filename {
  font-size: .8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.audio-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: white;
  border-radius: var(--radius-pill);
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: .8rem;
}
.audio-close:hover { background: rgba(255,255,255,.3); }

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(.95);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-title  { font-size: 1.125rem; font-weight: 600; }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.25rem; }

/* ─── Checklist (admin users) ───────────────────────────────── */
.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .5rem;
  margin-top: .5rem;
}
.check-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: .85rem;
}
.check-item:hover { border-color: var(--primary-from); background: #f0f9ff; }
.check-item input[type=checkbox]:checked ~ * { color: var(--primary-from); }
.check-item input[type=checkbox] { cursor: pointer; }

/* ─── Chart wrapper ─────────────────────────────────────────── */
.chart-container { position: relative; width: 100%; }

/* ─── Tooltips ──────────────────────────────────────────────── */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: .3rem .7rem;
  border-radius: 6px;
  font-size: .75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  z-index: 99;
  max-width: 250px;
  white-space: normal;
  text-align: center;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ─── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-toggle { display: flex; }
  .nav-links {
    position: fixed;
    top: var(--nav-height); left: 0; right: 0;
    background: linear-gradient(180deg, var(--primary-from), var(--primary-to));
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    gap: .375rem;
    transform: translateY(-110%);
    transition: transform var(--transition);
    z-index: 99;
  }
  .nav-links.open { transform: translateY(0); }
  .nav-user {
    flex-direction: column;
    align-items: flex-start;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,.25);
    padding-top: .75rem;
    margin-top: .5rem;
  }
  .program-grid { grid-template-columns: 1fr; }
  .stats-grid   { grid-template-columns: repeat(2, 1fr); }
  .audio-player-inner { flex-wrap: wrap; }
  .audio-info { max-width: 100%; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .card-body  { padding: 1rem; }
  .login-card { padding: 1.75rem 1.25rem; }
}

/* ─── Utilities ─────────────────────────────────────────────── */
.d-flex         { display: flex; }
.align-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-1          { gap: .5rem; }
.gap-2          { gap: 1rem; }
.mt-1           { margin-top: .5rem; }
.mt-2           { margin-top: 1rem; }
.mt-3           { margin-top: 1.5rem; }
.mb-1           { margin-bottom: .5rem; }
.mb-2           { margin-bottom: 1rem; }
.text-muted     { color: var(--text-secondary); font-size: .85rem; }
.text-sm        { font-size: .85rem; }
.text-center    { text-align: center; }
.w-100          { width: 100%; }
.flex-1         { flex: 1; }
.truncate       { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden         { display: none !important; }

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text-primary);
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--border);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 1rem; opacity: .4; }
.empty-state p   { font-size: .9rem; }

/* ─── DJ sticky player bar spacing ─────────────────────────── */
body.has-player { padding-bottom: 80px; }
