/* --- 1. THEME ENGINE --- */
:root {
  /* LIGHT MODE (Default) */
  --bg-body: #f4f3ee;
  --bg-card: #ffffff;
  --bg-nav: #ffffff;
  --text-main: #1a1a1a;
  --text-muted: #666666;
  --border-color: #1a1a1a;

  /* PALETTE */
  --c-primary: #ff5e3a; /* Orange */
  --c-green: #10b981; /* Green */
  --c-blue: #3b82f6; /* Blue */
  --c-yellow: #fbbf24; /* Yellow */
  --c-red: #ef4444; /* Red */

  /* BUTTON SWAPS */
  --btn-black-bg: #1a1a1a;
  --btn-black-text: #ffffff;
  --btn-white-bg: #ffffff;
  --btn-white-text: #1a1a1a;

  /* DIMS */
  --border-w: 3px;
  --radius: 12px;
  --shadow: 5px 5px 0px var(--border-color);
  --shadow-hover: 7px 7px 0px var(--border-color);
  --shadow-active: 0px 0px 0px var(--border-color);
}

/* DARK MODE OVERRIDES */
.theme-dark {
  --bg-body: #121212;
  --bg-card: #1e1e1e;
  --bg-nav: #1e1e1e;
  --text-main: #ffffff;
  --text-muted: #a0a0a0;
  --border-color: #ffffff; /* White borders = Blueprint look */

  /* Invert Black/White buttons */
  --btn-black-bg: #ffffff;
  --btn-black-text: #1a1a1a;
  --btn-white-bg: #1e1e1e;
  --btn-white-text: #ffffff;
}

/* --- 2. RESET --- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
}

.app-shell {
  background-color: var(--bg-body);
  /* Dynamic Dot Pattern */
  background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
  color: var(--text-main);
  font-family: "Inter", sans-serif;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* --- 3. LAYOUT --- */
.neo-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 40px 20px 80px 20px;
}
.neo-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.neo-masonry {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 24px;
}
.col-span-2 {
  grid-column: span 2;
}
@media (max-width: 768px) {
  .neo-grid-2,
  .col-span-2 {
    grid-template-columns: 1fr;
    grid-column: span 1;
  }
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* --- 4. NAVIGATION --- */
.neo-navbar {
  position: sticky;
  top: 20px;
  width: 90%;
  max-width: 1000px;
  margin: 0 auto 30px auto;
  background: var(--bg-nav);
  border: var(--border-w) solid var(--border-color);
  border-radius: var(--radius);
  padding: 15px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  z-index: 50;
  transition: 0.3s;
}
.nav-brand {
  font-weight: 900;
  font-size: 1.5rem;
  letter-spacing: -1px;
}
.nav-brand a {
  text-decoration: none;
  color: inherit;
}
.text-primary {
  color: var(--c-primary);
}

.nav-links {
  display: flex;
  gap: 20px;
  align-items: center;
}
.nav-link {
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 8px 12px;
  border-radius: 6px;
  transition: 0.2s;
}
.nav-link:hover {
  background: var(--bg-body);
}
.nav-link-logout {
  background: var(--btn-black-bg);
  color: var(--btn-black-text);
  border: 2px solid var(--border-color);
}
.nav-link-logout:hover {
  transform: translate(-1px, -1px);
  box-shadow: 2px 2px 0 var(--border-color);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-label {
  font-weight: 700;
  font-size: 0.8rem;
  margin-right: 10px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-main);
}

@media (max-width: 768px) {
  .nav-links {
    display: none;
  }
  .theme-label {
    display: none;
  }
  .neo-toggle {
    display: none;
  }
  .mobile-menu-btn {
    display: block;
  }
}

/* Drawer */
.neo-drawer {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background: var(--bg-card);
  border-left: var(--border-w) solid var(--border-color);
  padding: 24px;
  z-index: 200;
  transition: right 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  display: flex;
  flex-direction: column;
}
.neo-drawer.open {
  right: 0;
}
.neo-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 150;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
}
.drawer-nav {
  display: flex;
  flex-direction: column;
  gap: 15px;
  flex-grow: 1;
}
.drawer-link {
  text-decoration: none;
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.2rem;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 8px;
}
.drawer-link:hover,
.drawer-link.active {
  border-color: var(--border-color);
  background: var(--bg-body);
}

/* Hamburger FAB */
.neo-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: var(--c-yellow);
  border: var(--border-w) solid #000; /* Always black for visibility */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 100;
  box-shadow: 4px 4px 0px #000;
  transition: 0.1s;
}
.neo-fab:active {
  transform: scale(0.9);
}

/* --- 5. BUTTONS --- */
.neo-btn {
  border: var(--border-w) solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 24px;
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
}
.neo-btn:hover:not(:disabled) {
  transform: translate(-2px, -2px);
  box-shadow: var(--shadow-hover);
}
.neo-btn:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: var(--shadow-active);
}
.neo-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
  transform: translate(2px, 2px);
}

/* Button Variants */
.neo-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}
.neo-lg {
  padding: 16px 32px;
  font-size: 1.2rem;
}
.neo-icon {
  width: 48px;
  height: 48px;
  padding: 0;
  font-size: 1.5rem;
}

.neo-primary {
  background: var(--c-primary);
  color: white;
}
.neo-green {
  background: var(--c-green);
  color: black;
}
.neo-blue {
  background: var(--c-blue);
  color: white;
}
.neo-yellow {
  background: var(--c-yellow);
  color: black;
}
.neo-red {
  background: var(--c-red);
  color: white;
}
.neo-black {
  background: var(--btn-black-bg);
  color: var(--btn-black-text);
}
.neo-white {
  background: var(--btn-white-bg);
  color: var(--btn-white-text);
}

/* Loading Spinner */
.neo-loader {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* --- 6. COMPONENTS --- */
.neo-box,
.neo-card {
  background: var(--bg-card);
  border: var(--border-w) solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.neo-box {
  padding: 24px;
  margin-bottom: 24px;
}
.neo-card {
  padding: 0;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
}
.card-body {
  padding: 20px;
}
.card-img-placeholder {
  height: 150px;
  background: var(--bg-body);
  border-bottom: var(--border-w) solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  opacity: 0.5;
}

.section-label {
  font-size: 1rem;
  font-weight: 900;
  opacity: 0.7;
  letter-spacing: 2px;
  border-bottom: 2px dashed var(--border-color);
  margin-bottom: 20px;
  padding-bottom: 10px;
}
.display-title {
  font-size: clamp(3rem, 8vw, 5rem);
  line-height: 0.9;
  font-weight: 900;
  margin-bottom: 10px;
}

/* --- 7. FORMS --- */
.form-group {
  margin-bottom: 15px;
}
.neo-label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
}
.neo-input,
.neo-select {
  width: 100%;
  padding: 12px;
  background: var(--bg-card);
  color: var(--text-main);
  border: var(--border-w) solid var(--border-color);
  border-radius: 8px;
  font-weight: 600;
  font-size: 1rem;
  outline: none;
}
.neo-input:focus {
  box-shadow: 4px 4px 0 var(--border-color);
}

/* Range Slider */
.neo-range {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  cursor: pointer;
}
.neo-range:focus {
  outline: none;
}

/* Webkit (Chrome, Safari, Edge) */
.neo-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 16px;
  background: var(--bg-card);
  border: var(--border-w) solid var(--border-color);
  border-radius: 10px;
}
.neo-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 24px;
  width: 24px;
  background: var(--c-primary);
  border: var(--border-w) solid var(--border-color);
  border-radius: 4px;
  margin-top: -7px;
  box-shadow: 2px 2px 0 var(--border-color);
  cursor: pointer;
}

/* Firefox */
.neo-range::-moz-range-track {
  width: 100%;
  height: 16px;
  background: var(--bg-card);
  border: var(--border-w) solid var(--border-color);
  border-radius: 10px;
}
.neo-range::-moz-range-thumb {
  height: 24px;
  width: 24px;
  background: var(--c-primary);
  border: var(--border-w) solid var(--border-color);
  border-radius: 4px;
  box-shadow: 2px 2px 0 var(--border-color);
  cursor: pointer;
}

/* Microsoft Edge/IE */
.neo-range::-ms-track {
  width: 100%;
  height: 16px;
  background: transparent;
  border-color: transparent;
  color: transparent;
}
.neo-range::-ms-fill-lower {
  background: var(--bg-card);
  border: var(--border-w) solid var(--border-color);
  border-radius: 10px;
}
.neo-range::-ms-fill-upper {
  background: var(--bg-card);
  border: var(--border-w) solid var(--border-color);
  border-radius: 10px;
}
.neo-range::-ms-thumb {
  height: 24px;
  width: 24px;
  background: var(--c-primary);
  border: var(--border-w) solid var(--border-color);
  border-radius: 4px;
  box-shadow: 2px 2px 0 var(--border-color);
  cursor: pointer;
}

/* Checkboxes */
.neo-checkbox,
.neo-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  margin-right: 20px;
}
.neo-checkbox input,
.neo-radio input {
  display: none;
}
.check-box {
  width: 24px;
  height: 24px;
  border: var(--border-w) solid var(--border-color);
  border-radius: 6px;
  display: grid;
  place-content: center;
}
.check-box::after {
  content: "✓";
  display: none;
  font-weight: 900;
}
.neo-checkbox input:checked + .check-box {
  background: var(--c-green);
}
.neo-checkbox input:checked + .check-box::after {
  display: block;
}

.radio-circle {
  width: 24px;
  height: 24px;
  border: var(--border-w) solid var(--border-color);
  border-radius: 50%;
  position: relative;
}
.radio-circle::after {
  content: "";
  position: absolute;
  inset: 4px;
  background: var(--text-main);
  border-radius: 50%;
  display: none;
}
.neo-radio input:checked + .radio-circle::after {
  display: block;
}

/* --- 8. TOGGLE SWITCH (Restored) --- */
.neo-toggle {
  position: relative;
  width: 50px;
  height: 28px;
  display: inline-block;
  cursor: pointer;
}
.neo-toggle input {
  display: none;
}
.toggle-track {
  width: 100%;
  height: 100%;
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: 20px;
  position: relative;
  transition: 0.2s;
}
.toggle-thumb {
  width: 18px;
  height: 18px;
  background: var(--text-main);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: 0.2s;
}
.neo-toggle input:checked + .toggle-track .toggle-thumb {
  left: 25px;
  background: var(--c-primary);
}

/* --- 9. TOASTS --- */
.neo-toast-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 400px;
}
.neo-toast {
  background: var(--bg-card);
  border: var(--border-w) solid var(--border-color);
  border-radius: var(--radius);
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 4px 4px 0 var(--border-color);
  font-weight: 700;
  animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popUp {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.toast-success {
  background: var(--c-green);
  color: black;
}
.toast-error {
  background: var(--c-red);
  color: white;
}
.toast-info {
  background: var(--c-blue);
  color: white;
}
.toast-close {
  background: transparent;
  border: none;
  font-weight: 900;
  cursor: pointer;
  color: inherit;
}

/* Utils */
.text-white {
  color: white !important;
}
.text-center {
  text-align: center;
}
.full-width {
  width: 100%;
}
.neo-badge {
  padding: 4px 8px;
  background: var(--text-main);
  color: var(--bg-card);
  border-radius: 4px;
  font-size: 0.8rem;
}
.stat-number {
  font-size: 3.5rem;
  font-weight: 900;
  line-height: 1;
  margin: 10px 0;
}
.hidden-mobile {
  display: block;
}
@media (max-width: 600px) {
  .hidden-mobile {
    display: none;
  }
}
