/* =============================================================================
   ながのデジタル地形ラボ — Design System
   ============================================================================= */

:root {
  /* Colors */
  --bg-dark: #0f1419;
  --bg-card: #1a2332;
  --bg-card-hover: #1e2a3a;
  --bg-input: #0d1821;
  --border: #2a3a4a;
  --border-focus: #4a9eff;
  --text: #e8edf3;
  --text-mid: #8899aa;
  --text-dim: #556677;
  --accent: #4a9eff;
  --accent-glow: rgba(74, 158, 255, 0.3);
  --green: #3dd68c;
  --green-bg: rgba(61, 214, 140, 0.1);
  --orange: #ff9f43;
  --red: #ff6b6b;
  --road-color: #a0a0a0;
  --river-color: #4a9eff;
  --rail-color: #c78c50;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
#app-header {
  background: linear-gradient(135deg, #1a2332 0%, #0f2847 100%);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1600px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 8px rgba(74, 158, 255, 0.5));
}

.logo h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, #fff 0%, #4a9eff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 11px;
  color: var(--text-mid);
  margin-top: 2px;
}

.header-badge {
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.15), rgba(61, 214, 140, 0.1));
  border: 1px solid rgba(74, 158, 255, 0.3);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

/* Main layout */
#app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  gap: 0;
}

/* Map section */
#map-section {
  position: relative;
  min-height: 600px;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 600px;
  background: var(--bg-dark);
}

#map-instructions {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 20, 25, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  color: var(--text-mid);
  z-index: 500;
  white-space: nowrap;
  transition: opacity 0.3s;
}

#map-instructions .icon {
  margin-right: 6px;
}

#map-instructions strong {
  color: var(--accent);
}

#map-instructions.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Controls sidebar */
#controls {
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 12px;
  letter-spacing: 0.03em;
}

/* Coordinate grid */
.coord-grid {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  align-items: center;
}

.coord-grid label {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.coord-grid input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: 'SF Mono', 'Menlo', monospace;
  width: 100%;
}

.coord-grid input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.coord-grid input[type="number"] {
  -moz-appearance: textfield;
}

.coord-grid input::-webkit-inner-spin-button {
  opacity: 1;
}

.btn-apply {
  width: 100%;
  margin-top: 10px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.15), rgba(61, 214, 140, 0.1));
  border: 1px solid rgba(74, 158, 255, 0.4);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-apply:hover {
  background: linear-gradient(135deg, rgba(74, 158, 255, 0.25), rgba(61, 214, 140, 0.15));
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn-apply:active {
  transform: translateY(0);
}

.coord-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.warning {
  margin-top: 8px;
  padding: 8px 12px;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--red);
}

.hidden { display: none !important; }

/* Feature toggles */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  cursor: pointer;
  border-bottom: 1px solid rgba(42, 58, 74, 0.5);
}

.toggle-row:last-child { border-bottom: none; }

.toggle-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.toggle-icon {
  width: 14px;
  height: 4px;
  border-radius: 2px;
  display: inline-block;
}

.road-icon { background: var(--road-color); }
.river-icon { background: var(--river-color); }
.rail-icon { background: var(--rail-color); }
.building-icon { background: #a0744a; }
.farmland-icon { background: #7ab648; }

/* Input row */
.input-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-row span {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

.input-row input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 14px;
}

.input-row input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #4a9eff 0%, #2d7ad6 100%);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(74, 158, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(74, 158, 255, 0.45);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-download {
  width: 100%;
  padding: 14px 20px;
  background: linear-gradient(135deg, #3dd68c 0%, #2bb870 100%);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(61, 214, 140, 0.3);
}

.btn-download:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(61, 214, 140, 0.45);
}

.btn-icon { font-size: 18px; }

/* Progress */
#progress-section {
  margin-top: 4px;
}

.progress-bar-container {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 10px;
  transition: width 0.3s ease;
}

#progress-text {
  font-size: 12px;
  color: var(--text-mid);
  margin-top: 6px;
  text-align: center;
}

/* Preview */
#preview-section {
  margin-top: 4px;
}

#preview-section h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-mid);
  margin-bottom: 8px;
}

#preview-canvas {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-dark);
}

.preview-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.preview-stats > div {
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.preview-stats span:not(.stat-label) {
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: var(--green);
}

/* Download */
#download-section {
  margin-top: 4px;
}

.download-info {
  margin-top: 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 12px;
  line-height: 1.7;
}

.download-info p {
  margin-bottom: 8px;
  color: var(--accent);
}

.download-info ol {
  padding-left: 18px;
  color: var(--text-mid);
}

.download-info code {
  background: rgba(74, 158, 255, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Menlo', monospace;
  font-size: 11px;
  color: var(--accent);
}

.download-info .info-note {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
}


/* Footer */
#app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
}

#app-footer a {
  color: var(--text-mid);
  text-decoration: none;
}

#app-footer a:hover {
  color: var(--accent);
}

/* Leaflet overrides */
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: var(--bg-card) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-card-hover) !important;
}

/* Draw rectangle style */
.leaflet-draw-toolbar a {
  background-color: var(--bg-card) !important;
}

/* Responsive */
@media (max-width: 900px) {
  #app-main {
    grid-template-columns: 1fr;
  }
  #map-section {
    min-height: 400px;
  }
  #controls {
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--border);
  }
}
