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

:root {
  --bg-dark: #0f111a;
  --bg-card: rgba(25, 28, 41, 0.65);
  --bg-card-hover: rgba(35, 40, 58, 0.85);
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.35);
  --secondary: #a855f7;
  --accent: #10b981;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --font-title: 'Outfit', 'Noto Sans KR', sans-serif;
  --font-body: 'Noto Sans KR', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--bg-dark);
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* 배경 그라디언트 효과 */
body::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -20%;
  width: 140%;
  height: 140%;
  background: radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 40%),
              radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.15) 0%, transparent 40%);
  pointer-events: none;
  z-index: -1;
}

/* 공통 타이포그래피 */
h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* 로그인 화면 */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  padding: 40px;
  border-radius: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
  animation: fadeInUp 0.6s ease-out;
}

.login-card h2 {
  font-size: 2rem;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--text-main), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* 공통 입력 폼 */
.input-group {
  margin-bottom: 20px;
  text-align: left;
}

.input-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.input-field {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
  background: rgba(0, 0, 0, 0.3);
}

/* 공통 버튼 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 14px 24px;
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  width: 100%;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--text-main);
  box-shadow: none;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  box-shadow: none;
  transform: translateY(-1px);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5);
}

/* 어드민 네비게이션 */
.admin-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background: rgba(15, 17, 26, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-badge {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  padding: 6px 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  color: white;
}

.logo-area h1 {
  font-size: 1.4rem;
  background: linear-gradient(135deg, #fff, #a855f7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logout-btn {
  max-width: 100px;
  padding: 8px 16px;
  font-size: 0.85rem;
  border-radius: 8px;
}

/* 메인 대시보드 구조 */
.dashboard-wrapper {
  max-width: 1400px;
  margin: 40px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
}

/* 사이드바 */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.sidebar-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.95rem;
  border: 1px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.sidebar-item.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.25);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-item-delete {
  color: var(--text-muted);
  opacity: 0;
  transition: all 0.2s ease;
  padding: 4px;
  border-radius: 4px;
}

.sidebar-item:hover .sidebar-item-delete {
  opacity: 1;
}

.sidebar-item-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.add-btn-sm {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.add-btn-sm:hover {
  transform: scale(1.2);
}

/* 대시보드 메인 콘텐츠 */
.main-content {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.section-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

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

.section-header h2 {
  font-size: 1.4rem;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 모니터 관리 그리드 */
.monitors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.monitor-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.monitor-card:hover {
  border-color: var(--primary);
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.1);
  transform: translateY(-2px);
}

.monitor-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.monitor-name {
  font-weight: 600;
  font-size: 1.05rem;
}

.monitor-id {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-title);
  margin-top: 2px;
}

.delete-monitor-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.2s ease;
}

.delete-monitor-btn:hover {
  color: #ef4444;
}

.monitor-playlist-status {
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  min-height: 80px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.empty-playlist-msg {
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
}

.playlist-video-item {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.playlist-video-item:last-child {
  margin-bottom: 0;
}

.playlist-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

/* 비디오 업로드 드롭존 */
.upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  background: rgba(0, 0, 0, 0.1);
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 24px;
  position: relative;
}

.upload-dropzone:hover, .upload-dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.upload-dropzone p {
  color: var(--text-muted);
  margin-top: 12px;
  font-size: 0.9rem;
}

.upload-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* 비디오 목록 테이블 */
.video-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.video-table th, .video-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.video-table th {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.video-table tr:last-child td {
  border-bottom: none;
}

.video-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.video-name {
  font-weight: 500;
}

.video-size {
  font-family: var(--font-title);
  color: var(--text-muted);
}

.video-preview-btn {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  margin-right: 16px;
}

.video-preview-btn:hover {
  text-decoration: underline;
}

/* 모달 스타일 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  justify-content: center;
  align-items: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-header h3 {
  font-size: 1.25rem;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.close-modal-btn:hover {
  color: var(--text-main);
}

/* 재생목록 설정 모달 내 비디오 셀렉터 */
.video-select-list {
  max-height: 250px;
  overflow-y: auto;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.video-select-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.video-select-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.video-select-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
}

/* 매장 TV 플레이어 스타일 */
.player-setup-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.setup-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 40px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
  text-align: center;
  animation: scaleUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.setup-card h2 {
  font-size: 1.8rem;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.setup-card p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 0.95rem;
}

.selection-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
  text-align: left;
}

/* 플레이어 리스트 선택 스타일 */
.setup-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
}

.setup-list-item {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  cursor: pointer;
  text-align: left;
  font-weight: 500;
  transition: all 0.2s ease;
}

.setup-list-item:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  transform: translateX(4px);
}

/* TV 비디오 영역 */
.tv-fullscreen-player {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: black;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.tv-fullscreen-player video {
  width: 100%;
  height: 100%;
  object-fit: cover; /* TV 화면을 빈틈없이 채움 */
}

/* 백그라운드 캐싱 진행 바 */
.caching-overlay {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(15, 17, 26, 0.85);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  z-index: 10000;
  animation: slideInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.caching-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  justify-content: space-between;
}

.caching-progress-container {
  background: rgba(255, 255, 255, 0.1);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}

.caching-progress-bar {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  width: 0%;
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* 설정 리셋을 위한 숨겨진/작은 버튼 */
.hidden-reset-trigger {
  position: fixed;
  top: 0;
  left: 0;
  width: 60px;
  height: 60px;
  opacity: 0; /* 완전히 보이지 않음 */
  z-index: 10001;
  cursor: default;
}

/* 디버그 혹은 오프라인 상태 경고 배지 */
.status-indicator {
  position: fixed;
  bottom: 24px;
  left: 24px;
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
  animation: pulse 2s infinite;
  display: none;
}

/* 키프레임 애니메이션 */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  50% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 0.9; }
}
