/* ==========================================================================
   THEME VARIABLE LAYER
   These are the ONLY variables the theme engine touches at runtime via
   root.style.setProperty(). Existing chatStyles.css already consumes
   var(--primary-color) etc. everywhere — this file adds the remaining
   variables (font, radius, wallpaper, nav style, glass) plus the small
   set of rules needed to make those variables actually change layout,
   not just color.
   ========================================================================== */

:root {
  --font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  --bubble-radius: 18px;
  --chat-wallpaper: none;
  --glass-opacity: 0.85;
  --glass-blur: 0px;
  --neon-glow: none;
}

body {
  font-family: var(--font-family);
  background: var(--app-bg, var(--secondary-bg));
}

/* Bubble radius + wallpaper are structural, so they need explicit rules
   rather than relying on chatStyles.css's existing var() usage alone. */
.message-bubble, .sent .message-content, .received .message-content {
  border-radius: var(--bubble-radius) !important;
}

#chat-box {
  background-color: var(--secondary-bg);
  transition: background-image .25s ease;
}

/* ---- Glassmorphism ---- */
body.theme-glass #overflow-menu-Bar,
body.theme-glass #user-info,
body.theme-glass .message-input-container,
body.theme-glass .dialog-content {
  background: rgba(255, 255, 255, var(--glass-opacity, 0.12)) !important;
  backdrop-filter: blur(var(--glass-blur, 18px));
  -webkit-backdrop-filter: blur(var(--glass-blur, 18px));
  border: 1px solid var(--border-color);
}

/* ---- Neon / Cyberpunk glow ---- */
body[data-theme="neon-nights"] .sent .message-content,
body[data-theme="cyberpunk-grid"] .sent .message-content,
body[data-theme="neon-nights"] #send-button,
body[data-theme="cyberpunk-grid"] #send-button {
  box-shadow: var(--neon-glow, none);
}

/* ---- Navigation style: bottom bar (default) vs side rail ---- */
body[data-nav-style="rail"] .bottom-nav {
  top: 0; left: 0; bottom: 0; right: auto;
  width: 76px; height: 100%;
  flex-direction: column; justify-content: flex-start; gap: 18px; padding-top: 24px;
  box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}
body[data-nav-style="rail"] .app-wrapper { padding-left: 76px; }

/* ==========================================================================
   THEME STORE WIDGET
   ========================================================================== */
.theme-store-content { max-width: 640px; }

.theme-store-tabs { display: flex; gap: 8px; margin: 12px 0; }
.theme-store-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border-color); background: var(--surface, var(--white));
  color: var(--text-grey); border-radius: 10px; cursor: pointer; font-weight: 600;
}
.theme-store-tab.active { background: var(--primary-gradient); color: #fff; border-color: transparent; }

.theme-store-panel { display: none; }
.theme-store-panel.active { display: block; }

.theme-store-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px; max-height: 55vh; overflow-y: auto; padding: 4px;
}

.theme-card {
  border: 1px solid var(--border-color); border-radius: 14px; padding: 10px;
  background: var(--surface, var(--white)); display: flex; flex-direction: column; gap: 8px;
}
.theme-card.active { border-color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-color) inset; }

.theme-card-preview {
  height: 46px; border-radius: 8px; overflow: hidden; display: flex;
  border: 1px solid var(--border-color);
}
.theme-swatch { flex: 1; }

.theme-card-meta { display: flex; flex-direction: column; }
.theme-card-meta strong { font-size: 13px; color: var(--text-dark); }
.theme-card-cat { font-size: 11px; color: var(--text-grey); text-transform: capitalize; }

.btn-small { padding: 6px 10px; font-size: 12px; }

.theme-custom-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 4px; border-bottom: 1px solid var(--border-color);
}
.theme-custom-row label { font-size: 14px; color: var(--text-dark); font-weight: 500; }
.theme-custom-row input[type="color"] { width: 40px; height: 32px; border: none; background: none; cursor: pointer; }
.theme-custom-row input[type="range"] { width: 140px; }
.theme-custom-row select, .theme-custom-row input[type="text"] {
  padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 8px; background: var(--surface, var(--white)); color: var(--text-dark);
}

/* ---- Wallpaper picker ---- */
.theme-wallpaper-section { padding: 14px 4px 4px; }
.theme-wallpaper-section > label { font-size: 14px; color: var(--text-dark); font-weight: 500; display: block; margin-bottom: 10px; }

.theme-wallpaper-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 10px; margin-bottom: 12px;
}
.theme-wallpaper-tile {
  aspect-ratio: 1; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--border-color); background-color: var(--secondary-bg);
  background-size: auto; display: flex; align-items: center; justify-content: center;
  color: var(--text-grey); transition: border-color .15s, transform .1s;
}
.theme-wallpaper-tile:hover { transform: scale(1.04); }
.theme-wallpaper-tile.active { border-color: var(--primary-color); box-shadow: 0 0 0 2px var(--primary-color) inset; }

.theme-wallpaper-custom-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.theme-wallpaper-url-input {
  flex: 1; min-width: 140px; padding: 8px 12px; border: 1px solid var(--border-color);
  border-radius: 10px; background: var(--surface, var(--white)); color: var(--text-dark); font-size: 13px;
}