/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* === Theme variables === */

:root {
  --accent: #6366f1;
  --accent-hover: #5558e3;
  --accent-subtle: rgba(99, 102, 241, 0.08);
  --accent-border: rgba(99, 102, 241, 0.2);
}

/* Light mode (default) */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-header: #f0f2f5;
  --text-primary: #1a1a2e;
  --text-secondary: #4a4a5a;
  --text-muted: #6a6a7a;
  --border-color: rgba(0, 0, 0, 0.08);
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --success-bg: rgba(34, 197, 94, 0.1);
  --success-border: rgba(34, 197, 94, 0.2);
  --success-text: #16a34a;
  --error-bg: rgba(239, 68, 68, 0.1);
  --error-border: rgba(239, 68, 68, 0.2);
  --error-text: #dc2626;
}

[data-theme="light"] body {
  background:
    linear-gradient(165deg, rgba(240, 244, 255, 0.96) 0%, rgba(232, 236, 244, 0.96) 40%, rgba(245, 247, 250, 0.96) 100%),
    url("/assets/light-eea7361e.webp");
  background-size: cover, cover;
  background-position: center, center;
  background-attachment: fixed, fixed;
  color: var(--text-primary);
}

/* Dark mode */
[data-theme="dark"] {
  --bg-primary: #0c1020;
  --bg-secondary: #151a30;
  --bg-header: #151a30;
  --text-primary: #e8e8f0;
  --text-secondary: #a0a0b0;
  --text-muted: #707080;
  --border-color: rgba(255, 255, 255, 0.06);
  --card-bg: rgba(255, 255, 255, 0.03);
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --success-bg: rgba(34, 197, 94, 0.08);
  --success-border: rgba(34, 197, 94, 0.15);
  --success-text: #4ade80;
  --error-bg: rgba(239, 68, 68, 0.08);
  --error-border: rgba(239, 68, 68, 0.15);
  --error-text: #f87171;
}

[data-theme="dark"] body {
  background:
    linear-gradient(165deg, rgba(21, 26, 48, 0.96) 0%, rgba(12, 16, 32, 0.96) 40%, rgba(6, 8, 16, 0.96) 100%),
    url("/assets/dark-7f25553a.webp");
  background-size: cover, cover;
  background-position: center, center;
  background-attachment: fixed, fixed;
  color: var(--text-primary);
}

body {
  min-height: 100vh;
}

/* === Jungle button === */

.jungle-btn {
  background-image: url("/assets/bg5-7db3e714.webp");
  background-size: cover;
  background-position: center;
  color: white;
  font-weight: 600;
  border-radius: 6px;
  box-shadow:
    0 2px 10px rgba(168, 85, 247, 0.4),
    0 0 20px rgba(255, 45, 146, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.25);
  transition: all 0.3s ease;
  text-shadow: 0 0 3px rgba(0,0,0,1), 0 1px 2px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.9);
  border: 3px solid rgba(255,255,255,0.15);
  cursor: pointer;
}

.jungle-btn-green {
  border-color: rgb(0, 200, 100);
}

.jungle-btn-blue {
  border-color: rgb(0, 150, 250);
}

.jungle-btn-red {
  border-color: rgb(220, 50, 50);
}

.jungle-btn-nav {
  border-color: rgb(100, 100, 100);
  box-shadow: none;
}

.jungle-btn-nav:hover {
  box-shadow: none;
  transform: translateY(-1px);
}

.jungle-btn-nav.sort-btn {
  color: white !important;
  border: 3px solid rgb(100, 100, 100) !important;
  text-shadow: 0 0 3px rgba(0,0,0,1), 0 1px 2px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.9);
  background-size: cover !important;
  background-position: center !important;
  opacity: 0.3;
}

.jungle-btn-nav.sort-btn:hover {
  opacity: 0.6;
  color: white !important;
  border-color: rgb(100, 100, 100) !important;
}

.jungle-btn-nav.sort-btn.active {
  border: 3px solid rgb(255, 255, 255) !important;
  opacity: 1;
}

.jungle-btn-nav.sort-btn.active:hover {
  border-color: rgb(255, 255, 255) !important;
}

.sort-btn-recent {
  background: url("/assets/bg7-69016f97.webp") center/cover !important;
}

.sort-btn-popular {
  background: url("/assets/bg12-1d27b970.webp") center/cover !important;
}

.sort-btn-updated {
  background: url("/assets/bg4-c2f9b29c.webp") center/cover !important;
}

.jungle-btn:hover {
  box-shadow:
    0 4px 20px rgba(255, 45, 146, 0.5),
    0 0 30px rgba(0, 212, 255, 0.4),
    inset 0 1px 0 rgba(255,255,255,0.3);
  transform: translateY(-2px) scale(1.02);
}

.jungle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.jungle-btn:disabled:hover {
  transform: none;
  box-shadow:
    0 2px 10px rgba(168, 85, 247, 0.4),
    0 0 20px rgba(255, 45, 146, 0.2),
    inset 0 1px 0 rgba(255,255,255,0.25);
}

/* === Accent button === */

.accent-btn {
  background-image: url("/assets/bg1-7ad21ffd.webp");
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  font-size: 0.7rem;
  line-height: 1;
}

.accent-btn:hover {
  text-decoration: none;
}

/* === Sort/filter buttons === */

.sort-btn {
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  text-decoration: none;
  transition: all 0.2s ease;
  background: var(--card-bg);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.sort-btn:hover {
  border-color: rgba(251, 86, 7, 0.4);
  color: var(--text-primary);
}

.sort-btn.active {
  background-image: url("/assets/bg5-7db3e714.webp");
  background-size: cover;
  background-position: center;
  color: white;
  border: 1px solid rgba(255,255,255,0.15);
  text-shadow: 0 0 3px rgba(0,0,0,1), 0 1px 2px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.9);
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.4);
}

/* === Space card === */

[data-theme="light"] .space-card-content {
  background: #ffffff;
}

[data-theme="dark"] .space-card-content {
  background: #1a1f35;
}

/* === Navigation links === */

.nav-link {
  text-decoration: none;
  font-size: 0.75rem;
  color: var(--text-secondary);
  opacity: 0.8;
  transition: opacity 0.15s;
}

.nav-link:hover {
  opacity: 1;
}

.nav-link-dim {
  text-decoration: none;
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.15s;
}

.nav-link-dim:hover {
  opacity: 1;
}

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

.header-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.header-avatar-initial {
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  text-shadow: 0 0 3px rgba(0,0,0,1), 0 1px 2px rgba(0,0,0,1), 0 0 10px rgba(0,0,0,0.8), 0 2px 6px rgba(0,0,0,0.9);
  box-shadow: 0 2px 8px rgba(168, 85, 247, 0.45);
}

/* === User dropdown === */

.user-dropdown {
  position: relative;
}

.user-dropdown-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.75rem;
  line-height: 1;
  margin-bottom: 0;
}

.user-dropdown-toggle:hover {
  background: var(--accent-subtle);
}

.user-dropdown-toggle svg {
  transition: transform 0.2s;
}

.user-dropdown.open .user-dropdown-toggle svg {
  transform: rotate(180deg);
}

.user-dropdown-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 180px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 0.15s ease;
  z-index: 10000;
}

[data-theme="light"] .user-dropdown-menu {
  background: #ffffff;
}

[data-theme="dark"] .user-dropdown-menu {
  background: #1a1f35;
}

.user-dropdown.open .user-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-dropdown-menu a,
.user-dropdown-menu button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 0.875rem;
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-align: left;
}

.user-dropdown-menu a:hover,
.user-dropdown-menu button:hover {
  background: var(--accent-subtle);
  color: var(--text-primary);
}

.user-dropdown-menu a:first-child {
  border-radius: 7px 7px 0 0;
}

.user-dropdown-menu a:last-child,
.user-dropdown-menu button:last-child {
  border-radius: 0 0 7px 7px;
}

.user-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 0.25rem 0;
}

.user-dropdown-menu .logout-item {
  color: #c0392b;
}

.user-dropdown-menu .logout-item:hover {
  background: rgba(192, 57, 43, 0.08);
  color: #c0392b;
}

/* === Theme toggle === */

.theme-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--card-bg);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  z-index: 1000;
  box-shadow: var(--card-shadow);
}

.theme-toggle:hover {
  transform: scale(1.1);
  border-color: var(--accent);
}

.theme-toggle .icon-light,
.theme-toggle .icon-dark { display: none; }

[data-theme="light"] .theme-toggle .icon-light { display: flex; }
[data-theme="dark"] .theme-toggle .icon-dark { display: flex; }

/* === Compact forms (override Pico defaults) === */

article fieldset {
  margin-bottom: 0.25rem;
  padding: 0;
  border: none;
}

article fieldset label {
  margin-bottom: 0.1rem;
  font-size: 0.8rem;
}

article fieldset input,
article fieldset select {
  margin-bottom: 0.1rem;
  padding: 0.3rem 0.5rem;
  font-size: 0.8rem;
  height: 66px;
  line-height: 1.4;
  box-sizing: border-box;
}

article fieldset small {
  font-size: 0.7rem;
  line-height: 1.2;
}

article hgroup {
  margin-bottom: 0.75rem;
}

article hgroup h2 {
  margin-bottom: 0.15rem;
}

article hgroup p {
  margin-bottom: 0;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-row fieldset {
  flex: 1;
  min-width: 0;
}

/* === Flash messages === */

.flash-undo-link {
  color: var(--accent);
  text-decoration: underline;
  font-weight: 600;
  margin-left: 0.5rem;
}

.flash-undo-link:hover {
  color: var(--accent-hover);
}
