/* =========================================================================
 * dashboard.css - โครงสร้าง Desktop Side-by-Side (ประหยัด RAM & กระชับเหมือนโหมดฟังเพลง)
 * ========================================================================= */

/* 1. Top Header */
.dash-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 10px 20px;
    background: #0b0b0d;
    border-bottom: 1px solid var(--line, #222);
    position: sticky;
    top: 0;
    z-index: 50;
}

.dash-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dash-brand h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--txt, #e0e0e0);
}

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

.quota-chip {
    background: rgba(16, 185, 129, 0.12);
    color: var(--ok, #10b981);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-ok { background: var(--ok, #10b981); color: #fff; }
.btn-ok:hover { filter: brightness(1.1); }
.btn-danger { background: var(--bad, #ef4444); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger-outline {
    background: transparent;
    color: var(--bad, #ef4444);
    border: 1px solid var(--bad, #ef4444);
}
.btn-danger-outline:hover {
    background: var(--bad, #ef4444);
    color: #fff;
}

/* 2. โครงสร้างหลัก Side-by-Side เหมือนภาพแรก (ซ้าย: Player | ขวา: สถิติ 5 ช่อง + คิวเพลง) */
.command-workspace {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
    padding: 16px 20px;
    align-items: stretch;
}

/* ให้กล่องใน grid หดได้ตามจอ (ค่าเริ่มต้น min-width:auto ทำให้หน้าล้นแนวนอนเมื่อหน้าต่างแคบ) */
.command-workspace > * {
    min-width: 0;
}

@media (max-width: 1024px) {
    .command-workspace {
        grid-template-columns: 1fr;
    }
}

.dash-box {
    background: var(--card, #121212);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--line, #222);
    display: flex;
    flex-direction: column;
}

.panel-header, .admin-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line, #222);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.panel-header h2, .admin-panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--txt, #e0e0e0);
}

/* 3. การ์ดสถิติทั้ง 5 ช่อง แบบ Compact วางเหนือคิวเพลงฝั่งขวา */
.compact-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

@media (max-width: 640px) {
    .compact-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.mini-stat-card {
    background: #0a0a0c;
    border: 1px solid var(--line, #222);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.mini-stat-card.clickable-stat {
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}

.mini-stat-card.clickable-stat:hover {
    border-color: var(--acc, #3b82f6);
    transform: translateY(-1px);
}

.mini-stat-label {
    font-size: 11px;
    color: var(--dim, #888);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mini-stat-val {
    font-size: 15px;
    font-weight: 700;
}

.text-pink { color: #f43f5e; }
.text-white { color: #ffffff; }
.text-blue { color: var(--acc, #3b82f6); }
.text-green { color: var(--ok, #10b981); }

/* 4. กล่องควบคุม Player ฝั่งซ้าย */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    margin-bottom: 12px;
    border: 1px solid #1f1f23;
}

.iframe-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.player-progress-Area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    padding: 6px 10px;
    background: #0a0a0c;
    border-radius: 6px;
    border: 1px solid var(--line, #222);
}

.time-label {
    font-size: 12px;
    color: var(--dim, #888);
    font-variant-numeric: tabular-nums;
    min-width: 36px;
    text-align: center;
}

.progress-slider {
    flex: 1;
    accent-color: var(--acc, #3b82f6);
    cursor: pointer;
    height: 5px;
}

.player-controls-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* 5. กล่องคิวเพลง & จัดการ Playlist ฝั่งขวา */
.tools-flex {
    display: flex;
    gap: 8px;
}

.search-input, .dash-select {
    padding: 8px 12px;
    background: #0a0a0c;
    color: var(--txt, #e0e0e0);
    border: 1px solid var(--line, #222);
    border-radius: 6px;
    font-size: 13px;
}

.tools-flex .search-input { flex: 1; }
.search-input:focus, .dash-select:focus { border-color: var(--acc, #3b82f6); }

.queue-badge {
    background: var(--line, #222);
    color: var(--dim, #888);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
}

.playlist-queue-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    max-height: 250px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #0a0a0c;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--line, #222);
}

.queue-item {
    background: #141418;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--line, #222);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 12.5px;
}

.queue-item.active {
    border-color: var(--acc, #3b82f6);
    background: rgba(59, 130, 246, 0.16);
}

.queue-empty-item {
    color: var(--dim, #888);
    text-align: center;
    padding: 40px 10px;
    font-size: 13px;
}

.queue-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.btn-mini {
    padding: 2px 6px;
    font-size: 11px;
    border-radius: 4px;
}

.playlist-footer-tools {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line, #222);
    display: flex;
    gap: 8px;
}

/* 6. ตาราง Media Manager & Comment Center ด้านล่าง */
.admin-panel {
    background: var(--card, #121212);
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--line, #222);
    margin: 0 20px 16px;
}

.admin-table-container {
    overflow-x: auto;
    max-height: 360px;
    overflow-y: auto;
}

.admin-media-table {
    width: 100%;
    text-align: left;
    border-collapse: collapse;
    min-width: 600px;
}

.admin-media-table th {
    padding: 8px 10px;
    color: var(--dim, #888);
    border-bottom: 1px solid var(--line, #222);
    font-size: 12px;
    position: sticky;
    top: 0;
    background: var(--card, #121212);
}

.admin-media-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line, #222);
    vertical-align: middle;
    font-size: 13px;
}

.media-thumb {
    width: 60px;
    height: 34px;
    object-fit: cover;
    border-radius: 4px;
    background: #000;
}

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

.status-badge {
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background: rgba(16, 185, 129, 0.14);
    color: var(--ok, #10b981);
}

.badge-alert {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.comment-list-box {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
}

.comment-card {
    background: #0a0a0c;
    border: 1px solid var(--line, #222);
    border-left: 4px solid var(--bad, #ef4444);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.comment-card.replied { border-left-color: var(--ok, #10b981); opacity: 0.85; }
.comment-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim, #888); }
.comment-author { font-weight: 600; color: var(--txt, #e0e0e0); }
.comment-video-tag { color: var(--acc, #3b82f6); cursor: pointer; text-decoration: underline; }
.comment-body { font-size: 13px; color: var(--txt, #e0e0e0); background: rgba(255,255,255,0.03); padding: 8px 10px; border-radius: 6px; }
.comment-reply-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.comment-reply-input { flex: 1; min-width: 200px; }

/* 7. Auth Guard & Alert Animation */
.auth-guard-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    background: var(--bg, #050505);
    position: fixed;
    inset: 0;
    z-index: 9999;
}

.auth-card {
    background: var(--card, #121212);
    padding: 32px;
    border-radius: 12px;
    border: 1px solid var(--line, #222);
    width: 100%;
    max-width: 380px;
}

.auth-card h2 { text-align: center; margin-bottom: 18px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; color: var(--dim, #888); font-size: 13px; }
.form-group input { width: 100%; padding: 9px 12px; border-radius: 6px; border: 1px solid var(--line, #222); background: #0a0a0c; color: #fff; }
.forgot-password-wrapper { text-align: right; margin: -6px 0 14px; }
.forgot-password-wrapper a { color: var(--acc, #3b82f6); font-size: 12px; text-decoration: none; }
.btn-full { width: 100%; padding: 10px; }
.login-error-msg { color: var(--bad, #ef4444); text-align: center; margin-top: 10px; display: none; }
.mt-10 { margin-top: 10px; }

@keyframes pulseRedAlert {
    0%, 100% { border-color: rgba(244, 63, 94, 0.4); }
    50% { border-color: rgba(244, 63, 94, 1); box-shadow: 0 0 8px rgba(244, 63, 94, 0.4); }
}

.mini-stat-card.alert-pulse {
    animation: pulseRedAlert 2s infinite;
    background: rgba(244, 63, 94, 0.12);
}

.btn-comment-has-unread {
    border-color: #f43f5e !important;
    color: #fda4af !important;
    background: rgba(244, 63, 94, 0.15) !important;
}

/* === Smart Playlist Persistence Toolbar === */
.smart-pl-bar {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.smart-pl-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.smart-pl-select {
  flex: 1;
  background: #14171c;
  color: #e2e8f0;
  border: 1px solid #2d3748;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 0.82rem;
  outline: none;
}

.smart-pl-select:focus {
  border-color: #38bdf8;
}

.btn-pl-action {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-pl-save:hover {
  background: #0284c7;
  border-color: #38bdf8;
}

.btn-pl-del:hover:not(:disabled) {
  background: #dc2626;
  border-color: #f87171;
}

.btn-pl-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.smart-pl-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #94a3b8;
}

.pl-status-badge {
  color: #38bdf8;
  font-weight: 500;
}

.pl-quick-tools {
  display: flex;
  gap: 4px;
}

.btn-pl-mini {
  background: transparent;
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  cursor: pointer;
}

.btn-pl-mini:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

/* ปุ่มเลื่อนลำดับเพลงในคิว (Up/Down) */
.queue-item-controls {
  display: inline-flex;
  gap: 3px;
  margin-left: auto;
}
/* === Phase 3 & 4: Admin Promotion Toolkit Modal === */
.promo-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(9, 10, 15, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.promo-modal-card {
  width: 100%;
  max-width: 680px;
  background: #12151e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.promo-hero-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 640px) {
  .promo-hero-grid {
    grid-template-columns: 1fr;
  }
}

.promo-thumb-box img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.promo-thumb-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.promo-thumb-actions > * {
  flex: 1;
  text-align: center;
  text-decoration: none;
}

.promo-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.promo-metric-pill {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.promo-metric-pill small {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 3px;
}

.promo-metric-pill strong {
  font-size: 14px;
  color: #38bdf8;
}

.promo-links-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 10px;
}

.promo-quick-copy-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

/* จำกัดความสูงกล่องคิวเพลงเพื่อให้เห็นคลังเพลงด้านล่างพร้อมกันแบบ Desktop UI */
#playlist-container {
    max-height: 240px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: #3b82f6 #161922;
}
/* แจ้งเตือนชั่วคราว (ป๊อปอัปเล็กกลางล่าง แล้วหายเอง) */
#ycc-toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 10050; max-width: min(560px, calc(100vw - 32px));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 10px; background: #f1f1f1; color: #0f0f0f;
  font-size: 14px; line-height: 1.45; box-shadow: 0 6px 24px rgba(0,0,0,.5); cursor: pointer;
  transition: opacity .2s, transform .2s;
}
#ycc-toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#ycc-toast.err { background: #3a1212; color: #ffd6d4; }
@media (prefers-reduced-motion: reduce) { #ycc-toast { transition: none; } }
