/*
 * Copyright (C) 2026 Yzapre
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

:root {
  --bg: #0a0a0a;
  --panel: #141414;
  --text: #eaeaea;
  --muted: #a0a0a0;
  --border: #2a2a2a;
  --link: #1d97d8;
}

[data-theme="light"] {
  --bg: #f5f5f5;
  --panel: #ffffff;
  --text: #111111;
  --muted: #555555;
  --border: #dddddd;
  --link: #1d97d8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, sans-serif;
  scrollbar-color: var(--border) transparent;
}

body {
  display: flex;
  align-items: stretch;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Sidebar Layout */
.sidebar {
  width: 240px;
  background: var(--panel);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  border-right: 1px solid var(--border);
  min-height: 100%;
  align-self: stretch;
  overflow-y: auto;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Mobile Close Button (Hidden on Desktop) */
.close-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.close-btn:hover {
  background: var(--border);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Base Nav Links & Accordion Toggles */
.nav a,
.submenu-toggle {
  text-decoration: none;
  color: var(--text);
  padding: 0.45rem 0.6rem;
  border-radius: 4px;
  font-size: 1rem;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.nav a:hover,
.submenu-toggle:hover {
  background: var(--border);
}

.nav a.active {
  background: var(--border);
  font-weight: 600;
}

/* Collapsible Submenus */
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.submenu-toggle .arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
  color: var(--muted);
}

.submenu {
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 0.8rem;
  margin-left: 0.4rem;
  border-left: 2px solid var(--border);
}

/* Expanded Submenu State */
.nav-group.open .submenu {
  display: flex;
}

.nav-group.open .submenu-toggle .arrow {
  transform: rotate(180deg);
}

/* Topbar Header */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.menu-btn {
  font-size: 1.2rem;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--text);
  border-radius: 4px;
  padding: 0.3rem 0.4rem;
  transition: background 0.1s;
}
.menu-btn:hover { background: var(--border); }

/* Right-hand cluster of topbar icon buttons (Import / Export, theme) */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.1s, border-color 0.1s;
  min-height: 30px;
}
.icon-btn:hover { background: var(--border); }
.icon-btn.active { border-color: var(--muted); background: var(--border); }

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1;
  transition: background 0.1s, border-color 0.1s;
  min-height: 30px;
  min-width: 35px;
}
.theme-btn:hover { background: var(--border); }

/* Main Content Area */
.main {
  flex: 1;
  padding: 2rem;
}

.hero {
  margin-bottom: 2rem;
  max-width: 700px;
}

.hero h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.hero p {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.card {
  background: var(--panel);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: 0.1s;
  text-decoration: none;
  color: var(--text);
}

.card:hover {
  background: var(--border);
}

.card p {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Changelog Section */
.changelog {
  max-width: 700px;
  margin-bottom: 2rem;
}

.log-entry {
  border-left: 2px solid var(--border);
  padding-left: 0.6rem;
  margin-bottom: 0.6rem;
}

.log-entry span {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Desktop: sidebar can be collapsed via the same menu button as mobile */
@media (min-width: 701px) {
  .sidebar {
    transition: width 0.2s ease-in-out, padding 0.2s ease-in-out, opacity 0.15s ease;
  }
  .sidebar.collapsed {
    width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    border-right: none;
  }
}

/* Mobile Responsiveness */
@media (max-width: 700px) {
  body {
    flex-direction: column;
  }

  .close-btn {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    height: 100vh;
    width: 250px;
    transition: left 0.2s ease-in-out;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    left: 0;
  }

  .main {
    padding: 1rem;
  }
}

.redirect:link {
  color: var(--link);
  background-color: transparent;
  text-decoration: none;
}
.redirect:visited {
  color: var(--link);
  background-color: transparent;
  text-decoration: none;
}
.redirect:hover {
  color: var(--link);
  background-color: transparent;
  text-decoration: underline;
}

/* Credits Section Styling */
.credits {
  max-width: 700px;
  margin-bottom: 0.5rem;
}

.changelog h2,
.credits h2 {
  font-size: 1.3rem;
  margin-bottom: 0.5rem;
}

.credits-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.credits-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.credits-row:last-child { border-bottom: none; }

.credits-role {
  flex-shrink: 0;
  width: 100px;
  font-weight: 700;
}

.credits-names { color: var(--muted); }

@media (max-width: 480px) {
  .credits-role { width: 100%; }
}

.hp-link-btn {
    align-self: flex-start;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.45rem 0.85rem;
    transition: background 0.1s;
}

.hp-link-btn:hover { background: var(--border); }

/* Site-wide Modal (replaces native alert()/confirm(), see shared.js) */
.site-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.site-modal-overlay.open { display: flex; }
.site-modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
}
.site-modal-title {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}
.site-modal-message {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}
.site-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.1rem;
}
.site-modal-actions button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
}
.site-modal-actions button:hover { background: var(--border); }
.site-modal-actions button.btn-primary {
  background: #1a3a1a; border-color: #2d6b2d; color: #8eff8e;
}
.site-modal-actions button.btn-primary:hover { background: #254825; }
.site-modal-actions button.btn-danger {
  background: #3a1010; border-color: #7a2020; color: #ff9999;
}
.site-modal-actions button.btn-danger:hover { background: #4a1818; }

.data-notice { font-size: 0.8rem; color: var(--muted); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.section-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.toolbar-btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
  font-family: inherit;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.toolbar-btn:hover { background: var(--border); }
.toolbar-btn.danger:hover {
  background: #3a1010; border-color: #7a2020; color: #ff9999;
}
.toolbar-btn.active-toggle {
  background: var(--border);
  border-color: var(--muted);
  font-weight: 600;
}

.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  width: 100%;
  max-width: 400px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-box h3 { margin-bottom: 0.5rem; font-size: 1rem; }
.modal-box p { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.modal-box ul {
  margin: 0.25rem 0 0.5rem 1.1rem;
  font-size: 0.85rem;
  color: var(--text);
  max-height: 35vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.modal-box .confirm-short { color: #ff9999; font-weight: 600; }
.confirm-checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.6rem;
  cursor: pointer;
}
.confirm-checkbox-row input[type="checkbox"] { cursor: pointer; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}
.modal-actions button {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  font-family: inherit;
}
.modal-actions button:hover { background: var(--border); }
.modal-actions button.btn-primary {
  background: #1a3a1a; border-color: #2d6b2d; color: #8eff8e;
}
.modal-actions button.btn-primary:hover { background: #254825; }
.modal-actions button.btn-danger {
  background: #3a1010; border-color: #7a2020; color: #ff9999;
}
.modal-actions button.btn-danger:hover { background: #4a1818; }

/* Hero Logo Styling */
.hero-logo {
  max-width: 100%;
  height: auto;
  max-height: 180px; /* Adjust as needed to control maximum height */
  display: block;
  margin-bottom: 1rem;
}
