/* RunBackHome.com — Main Stylesheet */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1117;
  --bg2: #1a1d2e;
  --bg3: #252840;
  --border: #2e3152;
  --text: #e8eaf6;
  --text-muted: #8892b0;
  --accent: #6c63ff;
  --accent-hover: #7c75ff;
  --accent2: #ff6584;
  --accent3: #43e97b;
  --kids: #f9ca24;
  --kids-bg: #1a1600;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --transition: 0.2s ease;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 28px; }
.logo-text strong { display: block; font-size: 16px; color: var(--text); }
.logo-text small { color: var(--text-muted); font-size: 11px; }

.nav-links { list-style: none; padding: 8px 0; flex: 1; }
.nav-section {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px 4px;
  font-weight: 600;
}
.nav-link {
  display: block;
  padding: 9px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin: 1px 8px;
  transition: all var(--transition);
  font-size: 14px;
}
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--accent); color: white; }
.nav-link.sub { padding-left: 28px; font-size: 13px; }
.nav-link.kids-link { color: var(--kids); }
.nav-link.kids-link:hover, .nav-link.kids-link.active { background: var(--kids-bg); color: var(--kids); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.kids-btn {
  width: 100%;
  background: var(--kids-bg);
  color: var(--kids);
  border: 1px solid var(--kids);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}
.kids-btn:hover { background: var(--kids); color: #1a1600; }

/* ===== MOBILE HEADER ===== */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 101;
  font-weight: 600;
}
.hamburger, .kids-icon-btn {
  background: none; border: none;
  color: var(--text); font-size: 20px;
  cursor: pointer; padding: 4px 8px;
}

/* ===== MAIN CONTENT ===== */
#main-content {
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active, .page:not(.hidden) { display: block; }
.hidden { display: none !important; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}
.page-header h1 { font-size: 26px; font-weight: 700; }
.subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== INPUTS ===== */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  width: 100%;
  transition: border var(--transition);
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.search-input { width: 220px; }
.select-filter { width: auto; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition);
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon { font-size: 32px; }
.stat-num { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== DASHBOARD GRID ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 20px;
}
.dash-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.dash-card h3 { font-size: 16px; margin-bottom: 16px; }
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.card-link { color: var(--accent); text-decoration: none; font-size: 14px; }
.card-link:hover { text-decoration: underline; }

/* ===== MEDIA LIBRARY ===== */
.media-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 7px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
}
.tab-btn:hover { border-color: var(--accent); color: var(--text); }
.tab-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.media-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}
.media-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
}
.media-card-thumb {
  height: 120px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  position: relative;
}
.media-card-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.media-badge {
  position: absolute;
  top: 8px; right: 8px;
  background: rgba(0,0,0,0.7);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}
.media-badge.kids { background: var(--kids); color: #1a1600; }
.media-card-info { padding: 10px 12px; }
.media-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.media-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity var(--transition);
  font-size: 36px;
}
.media-card:hover .play-overlay { opacity: 1; }

.load-more { text-align: center; padding: 24px; }

/* ===== KIDS LIBRARY ===== */
.kids-header { background: linear-gradient(135deg, var(--kids-bg), transparent); border-radius: var(--radius); padding: 20px; }
.kids-categories {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kids-cat-card {
  background: var(--kids-bg);
  border: 2px solid var(--kids);
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.kids-cat-card:hover { transform: scale(1.05); background: var(--kids); }
.kids-cat-card:hover .kids-cat-name { color: #1a1600; }
.kids-cat-icon { font-size: 48px; margin-bottom: 8px; }
.kids-cat-name { color: var(--kids); font-weight: 600; font-size: 14px; }

/* ===== INVENTORY GRID ===== */
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.inv-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
}
.inv-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.inv-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.inv-card-title { font-size: 15px; font-weight: 600; }
.inv-card-cat {
  font-size: 11px;
  background: var(--bg3);
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-muted);
}
.inv-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.inv-meta-item {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}
.inv-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.inv-description { font-size: 13px; color: var(--text-muted); }
.inv-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.tag {
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  color: var(--text-muted);
}

/* ===== ROOMS GRID ===== */
.rooms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.room-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
}
.room-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.room-card h3 { font-size: 16px; margin-bottom: 8px; }
.room-items-count { font-size: 24px; font-weight: 700; color: var(--accent); }
.room-floor { font-size: 12px; color: var(--text-muted); }

/* ===== MEDIA CATEGORY CARDS (dashboard) ===== */
.media-cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--transition);
}
.media-cat-item:last-child { border-bottom: none; }
.media-cat-item:hover { color: var(--accent); }
.media-cat-left { display: flex; align-items: center; gap: 10px; }
.media-cat-icon { font-size: 20px; }
.media-cat-name { font-size: 14px; font-weight: 500; }
.media-cat-count { font-size: 12px; color: var(--text-muted); background: var(--bg3); padding: 2px 8px; border-radius: 20px; }

/* ===== MODALS ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal-box h2 { font-size: 20px; margin-bottom: 8px; }
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.full-width { grid-column: 1 / -1; }

/* ===== PLAYER MODAL ===== */
.player-box { max-width: 900px; }
.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 600;
}
.close-btn {
  background: none; border: none;
  color: var(--text-muted); font-size: 20px;
  cursor: pointer;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: all var(--transition);
}
.close-btn:hover { background: var(--bg3); color: var(--text); }
#player-container video,
#player-container audio {
  width: 100%;
  border-radius: var(--radius-sm);
  background: black;
  max-height: 70vh;
}
.audio-art {
  background: var(--bg3);
  border-radius: var(--radius);
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
  margin-bottom: 16px;
}

/* ===== PIN INPUT ===== */
.pin-input {
  text-align: center;
  font-size: 32px;
  letter-spacing: 0.3em;
  width: 100%;
  margin: 16px 0;
}
.pin-error { color: var(--danger); font-size: 13px; margin-top: 8px; }

/* ===== KIDS MODE OVERLAY ===== */
#kids-mode-overlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 150;
}
.kids-banner {
  background: var(--kids);
  color: #1a1600;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  font-weight: 600;
}
.kids-banner .kids-icon { font-size: 20px; }
.unlock-btn {
  margin-left: auto;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(0,0,0,0.3);
  color: #1a1600;
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
}
.unlock-btn:hover { background: rgba(0,0,0,0.25); }

/* ===== SETTINGS ===== */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.settings-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.settings-card h3 { margin-bottom: 8px; }
.settings-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }
.settings-input { margin-bottom: 10px; }
.muted { color: var(--text-muted) !important; font-size: 13px !important; }

/* ===== EMPTY STATES ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; }

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 14px;
  z-index: 300;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 300px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  .mobile-header { display: flex; }
  #main-content {
    margin-left: 0;
    padding: 16px;
    padding-top: 72px;
  }
  .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; }
  .search-input { width: 100%; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== FOLDER BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  flex-wrap: wrap;
}
.breadcrumb-item {
  color: var(--accent);
  cursor: pointer;
  text-decoration: none;
}
.breadcrumb-item:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-muted); }
.breadcrumb-current { color: var(--text); }

/* ===== FOLDER CARDS ===== */
.folder-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all var(--transition);
}
.folder-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.folder-icon { font-size: 28px; }
.folder-name { font-size: 14px; font-weight: 500; }

.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
