/* ==========================================================================
   Postcode Converter Tool - Scoped Styles
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tool Container Layout
   -------------------------------------------------------------------------- */
.tool-container {
  display: flex;
  max-height: 700px;
  background-color: var(--bg);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.tool-sidebar {
  width: 380px;
  background-color: var(--card);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}

.sidebar-content {
  padding: 20px;
}

.sidebar-content label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  margin-top: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-content label:first-of-type {
  margin-top: 0;
}

.tool-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.tool-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.tool-section h3 {
  font-size: 15px;
  margin-bottom: 16px;
  color: var(--text);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   Input Section
   -------------------------------------------------------------------------- */
.input-section {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--card) 100%);
  margin: -20px -20px 28px -20px;
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

/* --------------------------------------------------------------------------
   Mode Toggle (Forward / Reverse)
   -------------------------------------------------------------------------- */
.mode-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 16px;
}

.mode-btn {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  line-height: 1.3;
}

.mode-btn:hover {
  color: var(--text);
}

.mode-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   Input Toggle (Single / Batch)
   -------------------------------------------------------------------------- */
.input-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.input-btn {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.input-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.input-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* --------------------------------------------------------------------------
   Format Toggle (Decimal / DMS)
   -------------------------------------------------------------------------- */
.format-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 12px;
}

.format-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.format-btn:hover {
  color: var(--text);
}

.format-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   Batch Textarea
   -------------------------------------------------------------------------- */
.batch-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  font-size: 13px;
  font-family: var(--font-mono);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  line-height: 1.5;
}

.batch-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.batch-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* --------------------------------------------------------------------------
   Result Box (Single & Reverse)
   -------------------------------------------------------------------------- */
.result-box {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}

.result-postcode {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.result-coords {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.6;
  word-break: break-all;
}

.result-coords .coord-line {
  display: block;
}

.result-distance {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Reverse Mode Info
   -------------------------------------------------------------------------- */
.reverse-info {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.reverse-info strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
}

/* --------------------------------------------------------------------------
   Batch Results List
   -------------------------------------------------------------------------- */
.batch-results-list {
  max-height: 350px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.batch-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease;
}

.batch-item:hover {
  background: var(--hover-bg);
  border-color: var(--primary);
}

.batch-item.active {
  background: rgba(37, 99, 235, 0.1);
  border-color: var(--primary);
}

.batch-item-rank {
  width: 24px;
  height: 24px;
  background: var(--bg-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  flex-shrink: 0;
}

.batch-item.active .batch-item-rank {
  background: var(--primary);
  color: white;
}

.batch-item-info {
  flex: 1;
  min-width: 0;
}

.batch-item-postcode {
  font-weight: 600;
  color: var(--text);
  font-size: 0.9rem;
}

.batch-item-coords {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.batch-item-error {
  font-size: 0.75rem;
  color: #ef4444;
}

.batch-item-arrow {
  color: var(--text-muted);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.batch-item:hover .batch-item-arrow {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   Results Badge
   -------------------------------------------------------------------------- */
.results-badge {
  background: var(--primary);
  color: white;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  margin-left: auto;
}

/* --------------------------------------------------------------------------
   Progress Bar
   -------------------------------------------------------------------------- */
.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--bg-secondary);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

/* --------------------------------------------------------------------------
   Tool Info Box
   -------------------------------------------------------------------------- */
.tool-info {
  background-color: var(--glass);
  border-radius: var(--radius-lg);
  padding: 14px;
  border: 1px solid var(--border);
}

.tool-item {
  font-size: 13px;
  color: var(--text);
  padding: 6px 0;
}

/* --------------------------------------------------------------------------
   Button Groups
   -------------------------------------------------------------------------- */
.button-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* --------------------------------------------------------------------------
   Map Container
   -------------------------------------------------------------------------- */
.map-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 500px;
  max-height: 700px;
}

.map-container.reverse-mode {
  cursor: crosshair;
}

.map-container.reverse-mode .leaflet-container {
  cursor: crosshair;
}

.map {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

#map .leaflet-container {
  width: 100% !important;
  height: 100% !important;
}

/* --------------------------------------------------------------------------
   Mobile FAB
   -------------------------------------------------------------------------- */
.fab {
  display: none;
  width: 56px;
  height: 56px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 9999;
}

/* --------------------------------------------------------------------------
   Responsive Design
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .tool-container {
    flex-direction: column;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    height: auto;
  }

  .tool-sidebar {
    width: 100%;
    max-height: calc(100vh - 120px);
    overflow-y: visible;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .tool-sidebar.collapsed {
    max-height: 0;
    overflow: hidden;
  }

  .map-container {
    max-height: calc(100vh - 120px);
    flex: none;
    height: 400px;
    min-height: 350px;
    max-height: 400px;
  }

  .map {
    min-height: 350px;
    height: 400px;
  }

  .fab {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    bottom: 20px;
    right: 20px;
  }

  .batch-results-list {
    max-height: 250px;
  }
}

@media (max-width: 600px) {
  .sidebar-content {
    padding: 16px;
  }

  .input-section {
    margin: -16px -16px 24px -16px;
    padding: 16px;
  }

  .tool-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
  }

  .map-container {
    max-height: calc(100vh - 120px);
    height: 350px;
    min-height: 300px;
    max-height: 350px;
  }

  .map {
    min-height: 300px;
    height: 350px;
  }

  .batch-results-list {
    max-height: 200px;
  }

  .mode-btn {
    font-size: 11px;
    padding: 7px 6px;
  }
}
