/* ============================================================
   Holha Screensaver Admin — Styles
   ============================================================ */

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

:root {
  --bg:          #f8fafc;
  --surface:     #ffffff;
  --border:      #e2e8f0;
  --border-soft: #f1f5f9;
  --text:        #0f172a;
  --text-muted:  #64748b;
  --accent:      #3b82f6;
  --accent-dark: #2563eb;
  --accent-bg:   #eff6ff;
  --danger:      #ef4444;
  --danger-bg:   #fef2f2;
  --success:     #22c55e;
  --success-bg:  #f0fdf4;
  --warning:     #f59e0b;
  --warning-bg:  #fffbeb;
  --shadow:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.06);
  --radius:      8px;
  --radius-sm:   5px;
  --radius-lg:   12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

/* ============================================================
   Screens
   ============================================================ */

.screen { display: contents; }
.hidden { display: none !important; }

/* ============================================================
   Login
   ============================================================ */

#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 48px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card .logo {
  font-size: 28px;
  margin-bottom: 8px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

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

.login-card input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
}

.login-card input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.login-card .btn-login {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.login-card .btn-login:hover { background: var(--accent-dark); }

.login-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

/* ============================================================
   App shell
   ============================================================ */

#app-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   Header
   ============================================================ */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  flex: 1;
}

.header-brand .logo-icon { font-size: 22px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.version-badge {
  background: var(--accent-bg);
  color: var(--accent-dark);
  border: 1px solid #bfdbfe;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, box-shadow .12s, transform .08s;
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fecaca;
}
.btn-danger:hover:not(:disabled) { background: #fee2e2; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
  padding: 5px 8px;
}
.btn-ghost:hover:not(:disabled) { background: var(--border-soft); color: var(--text); }

.btn-save {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}
.btn-save:hover:not(:disabled) { background: #15803d; border-color: #15803d; }
.btn-save.unsaved { animation: pulse-save 2s infinite; }

@keyframes pulse-save {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22,163,74,.4); }
  50%       { box-shadow: 0 0 0 6px rgba(22,163,74,0); }
}

/* ============================================================
   Status bar
   ============================================================ */

#status-bar {
  margin: 16px 24px 0;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

#status-bar.success {
  background: var(--success-bg);
  color: #166534;
  border: 1px solid #bbf7d0;
}

#status-bar.error {
  background: var(--danger-bg);
  color: #991b1b;
  border: 1px solid #fecaca;
}

#status-bar.warning {
  background: var(--warning-bg);
  color: #92400e;
  border: 1px solid #fde68a;
}

/* ============================================================
   Main content
   ============================================================ */

main {
  flex: 1;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

/* ============================================================
   Settings panel
   ============================================================ */

.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.settings-panel h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.settings-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.settings-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.settings-row label .hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.settings-row input[type="number"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 100px;
  outline: none;
  transition: border-color .15s;
}

.settings-row input[type="number"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

/* ============================================================
   Playlist section
   ============================================================ */

.playlist-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

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

.playlist-section-header h2 {
  font-size: 15px;
  font-weight: 600;
}

.item-count {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 13px;
}

#playlist {
  min-height: 80px;
}

#playlist.drag-over {
  background: var(--accent-bg);
}

.playlist-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  gap: 8px;
  font-size: 14px;
}

.playlist-empty .empty-icon { font-size: 40px; }

/* ============================================================
   Playlist item
   ============================================================ */

.playlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface);
  transition: background .1s;
  cursor: default;
  user-select: none;
}

.playlist-item:last-child { border-bottom: none; }
.playlist-item:hover { background: #fafbfc; }

.playlist-item.dragging {
  opacity: .5;
  background: var(--accent-bg);
}

.playlist-item.drag-target-above { border-top: 2px solid var(--accent); }
.playlist-item.drag-target-below { border-bottom: 2px solid var(--accent); }

.drag-handle {
  cursor: grab;
  color: var(--border);
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  padding: 2px;
}

.drag-handle:hover { color: var(--text-muted); }
.drag-handle:active { cursor: grabbing; }

/* Thumbnail */
.item-thumb {
  width: 72px;
  height: 48px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}

.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-thumb .video-icon {
  font-size: 24px;
  color: var(--text-muted);
}

.item-thumb.thumb-inactive { opacity: .5; }

/* Item info */
.item-info {
  flex: 1;
  min-width: 0;
}

.item-filename {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-meta {
  display: flex;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-type-image { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }
.badge-type-video { background: #fdf4ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-duration   { background: #f8fafc; color: var(--text-muted); border: 1px solid var(--border); }
.badge-scheduled  { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.badge-inactive   { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.badge-active-now { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }

/* Item actions */
.item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

/* ============================================================
   Upload drop zone (in playlist footer)
   ============================================================ */

.upload-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.upload-drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}

.upload-drop-zone:hover,
.upload-drop-zone.drop-hover {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent-dark);
}

.upload-drop-zone .upload-icon { font-size: 22px; display: block; margin-bottom: 6px; }

/* ============================================================
   Upload progress
   ============================================================ */

.upload-progress {
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  background: var(--accent-bg);
}

.progress-bar-wrap {
  flex: 1;
  height: 6px;
  background: #bfdbfe;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width .2s;
}

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  overflow: hidden;
  animation: modal-in .15s ease-out;
}

@keyframes modal-in {
  from { transform: scale(.95); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.modal-large { max-width: 780px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================================
   Form fields (in modals)
   ============================================================ */

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

.form-row label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--text);
}

.form-row .hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 4px;
}

.form-row input[type="text"],
.form-row input[type="number"],
.form-row input[type="date"] {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  transition: border-color .15s;
  background: var(--surface);
  color: var(--text);
}

.form-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.form-row input[type="number"] { width: 120px; }

.form-row .row-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Inline file-type radio */
.type-selector {
  display: flex;
  gap: 8px;
}

.type-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: border-color .12s, background .12s;
}

.type-option input[type="radio"] { margin: 0; accent-color: var(--accent); }
.type-option.selected { border-color: var(--accent); background: var(--accent-bg); color: var(--accent-dark); }

/* ============================================================
   Preview modal
   ============================================================ */

#preview-modal .modal-header { gap: 12px; }

#preview-content {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#preview-content img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

#preview-content video {
  max-width: 100%;
  max-height: 70vh;
  display: block;
  outline: none;
}

/* ============================================================
   Upload modal file info
   ============================================================ */

.file-info-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.file-info-row .file-icon { font-size: 28px; }

.file-info-name {
  font-weight: 500;
  font-size: 13px;
  word-break: break-all;
}

.file-info-size {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   Loading spinner
   ============================================================ */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  flex-shrink: 0;
}

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

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
