/* ===== RESET & BASE ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  background-color: #1a1a2e;
  color: #e0e0e0;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: #FF1C1C;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== APP LAYOUT ===== */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#page-content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ===== NAVIGATION ===== */
#main-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: #16213e;
  border-bottom: 2px solid #FF1C1C;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 56px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: #FF1C1C;
  cursor: pointer;
}

.nav-logo img {
  width: 32px;
  height: 32px;
}

.nav-spacer {
  flex: 1;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.nav-link {
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  color: #b0b0c0;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.15s, color 0.15s;
  border: none;
  background: none;
}

.nav-link:hover {
  background-color: rgba(255, 28, 28, 0.12);
  color: #ffffff;
}

.nav-link--active {
  background-color: rgba(255, 28, 28, 0.2);
  color: #FF1C1C;
}

.nav-logout {
  padding: 7px 16px;
  border-radius: 6px;
  cursor: pointer;
  color: #b0b0c0;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid #444466;
  background: none;
  margin-left: 8px;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.nav-logout:hover {
  border-color: #FF1C1C;
  color: #FF1C1C;
  background-color: rgba(255, 28, 28, 0.08);
}

/* ===== CARDS ===== */
.card {
  background-color: #16213e;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #ffffff;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2a2a4a;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background-color 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background-color: #FF1C1C;
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background-color: #e01010;
}

.btn-secondary {
  background-color: #2a2a4a;
  color: #e0e0e0;
  border: 1px solid #444466;
}

.btn-secondary:hover:not(:disabled) {
  background-color: #363660;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #9090a8;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background-color: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus {
  border-color: #FF1C1C;
}

.form-input::placeholder {
  color: #555577;
}

.form-select {
  width: 100%;
  padding: 10px 14px;
  background-color: #1a1a2e;
  border: 1px solid #333355;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
  cursor: pointer;
  appearance: none;
}

.form-select:focus {
  border-color: #FF1C1C;
}

.form-error {
  color: #FF1C1C;
  font-size: 0.82rem;
  margin-top: 6px;
}

.form-hint {
  color: #666688;
  font-size: 0.82rem;
  margin-top: 6px;
}

/* ===== BT STATUS BAR ===== */
.bt-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  background-color: #1a1a2e;
  border: 1px solid #333355;
  margin-bottom: 16px;
}

.bt-status--connected {
  border-color: #22cc66;
  color: #22cc66;
}

.bt-status--disconnected {
  border-color: #666688;
  color: #888899;
}

.bt-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.bt-dot--on {
  background-color: #22cc66;
  box-shadow: 0 0 6px #22cc66;
}

.bt-dot--off {
  background-color: #666688;
}

/* ===== MAP ===== */
.map-container {
  height: 400px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #333355;
}

/* Leaflet dark override */
.leaflet-container {
  background-color: #1a1a2e;
}

.leaflet-tile-pane {
  filter: brightness(0.85) saturate(0.8);
}

.leaflet-control-zoom a {
  background-color: #16213e;
  color: #e0e0e0;
  border-color: #333355;
}

.leaflet-control-zoom a:hover {
  background-color: #2a2a4a;
}

.leaflet-popup-content-wrapper {
  background-color: #16213e;
  color: #e0e0e0;
  border: 1px solid #333355;
}

.leaflet-popup-tip {
  background-color: #16213e;
}

/* ===== FEED ===== */
.feed {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #333355 transparent;
}

.feed::-webkit-scrollbar {
  width: 6px;
}

.feed::-webkit-scrollbar-track {
  background: transparent;
}

.feed::-webkit-scrollbar-thumb {
  background-color: #333355;
  border-radius: 3px;
}

.feed-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 4px;
  font-size: 0.88rem;
  background-color: rgba(255, 255, 255, 0.03);
  transition: background-color 0.1s;
}

.feed-item:hover {
  background-color: rgba(255, 255, 255, 0.06);
}

.feed-result--caught {
  color: #22cc66;
  font-weight: 600;
}

.feed-result--fled {
  color: #FF1C1C;
  font-weight: 600;
}

.feed-pokemon {
  color: #e0e0e0;
  flex: 1;
}

.feed-time {
  color: #555577;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.feed-empty {
  color: #555577;
  text-align: center;
  padding: 24px;
  font-size: 0.9rem;
}

/* ===== STATS ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  background-color: #1a1a2e;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  border: 1px solid #2a2a4a;
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: #FF1C1C;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: #7070a0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ===== RULES TABLE ===== */
.rules-table {
  width: 100%;
  border-collapse: collapse;
}

.rules-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #7070a0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #2a2a4a;
}

.rules-table td {
  padding: 12px;
  border-bottom: 1px solid #1e1e3a;
  vertical-align: middle;
}

.rules-table tr:last-child td {
  border-bottom: none;
}

.rules-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  border-radius: 12px;
  background-color: #333355;
  cursor: pointer;
  transition: background-color 0.2s;
  flex-shrink: 0;
}

.toggle--on {
  background-color: #FF1C1C;
}

.toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #ffffff;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.toggle--on .toggle-knob {
  transform: translateX(18px);
}

/* ===== LOGIN ===== */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 56px);
  padding: 24px;
}

.login-card {
  background-color: #16213e;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.login-logo img {
  width: 64px;
  height: 64px;
}

.login-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #FF1C1C;
  text-align: center;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.9rem;
  color: #7070a0;
  text-align: center;
  margin-bottom: 28px;
}

/* ===== PRESET BUTTONS ===== */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #333355;
  background-color: #1a1a2e;
  color: #b0b0c0;
  transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.preset-btn:hover {
  border-color: #FF1C1C;
  color: #FF1C1C;
  background-color: rgba(255, 28, 28, 0.08);
}

.preset-btn--active {
  border-color: #FF1C1C;
  color: #FF1C1C;
  background-color: rgba(255, 28, 28, 0.15);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #16213e;
  color: #e0e0e0;
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  border-left: 3px solid #FF1C1C;
  font-size: 0.9rem;
  z-index: 9999;
  max-width: 320px;
  animation: slideIn 0.3s ease;
}

.toast--success {
  border-left-color: #22cc66;
}

.toast--error {
  border-left-color: #FF1C1C;
}

.toast--info {
  border-left-color: #4488ff;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #ffffff;
}

/* ===== SECTION ===== */
.section {
  margin-bottom: 28px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: #9090a8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

/* ===== BADGE ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge--green {
  background-color: rgba(34, 204, 102, 0.15);
  color: #22cc66;
}

.badge--red {
  background-color: rgba(255, 28, 28, 0.15);
  color: #FF1C1C;
}

.badge--gray {
  background-color: rgba(100, 100, 136, 0.15);
  color: #888899;
}

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.alert--error {
  background-color: rgba(255, 28, 28, 0.1);
  border: 1px solid rgba(255, 28, 28, 0.3);
  color: #ff6666;
}

.alert--success {
  background-color: rgba(34, 204, 102, 0.1);
  border: 1px solid rgba(34, 204, 102, 0.3);
  color: #44dd88;
}

.alert--info {
  background-color: rgba(68, 136, 255, 0.1);
  border: 1px solid rgba(68, 136, 255, 0.3);
  color: #6699ff;
}

/* ===== SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #333355;
  border-top-color: #FF1C1C;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px;
}

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.dashboard-grid .card--full {
  grid-column: 1 / -1;
}

/* ===== SCROLLBAR GLOBAL ===== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1a1a2e;
}

::-webkit-scrollbar-thumb {
  background-color: #333355;
  border-radius: 4px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  #main-nav {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    height: 56px;
    padding: 0 8px;
    border-bottom: none;
    border-top: 2px solid #FF1C1C;
    justify-content: space-around;
  }

  .nav-logo {
    display: none;
  }

  .nav-spacer {
    display: none;
  }

  .nav-logout {
    margin-left: 0;
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .nav-links {
    gap: 2px;
  }

  .nav-link {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  #page-content {
    padding: 16px;
    padding-bottom: 72px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .map-container {
    height: 280px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .login-card {
    padding: 28px 20px;
  }

  .toast {
    bottom: 70px;
    right: 12px;
    left: 12px;
    max-width: none;
  }
}
