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

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1e293b;
  overflow: hidden;
}

/* ======= LAYOUT ======= */
.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ======= HEADER ======= */
header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-placeholder {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-text h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.025em;
}

.brand-text p {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.125rem;
}

/* ======= NAVIGATION TABS ======= */
.tab-nav {
  display: flex;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.25rem;
  border-radius: 10px;
  backdrop-filter: blur(10px);
}

.tab-button {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #cbd5e1;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.tab-button.active {
  background: #10b981;
  color: white;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

/* ======= MAIN CONTENT AREA ======= */
.content-area {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tab-content {
  display: none;
  height: 100%;
  width: 100%;
}

.tab-content.active {
  display: block;
}

/* ======= MAP VIEW ======= */
#map-view {
  height: 100%;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.leaflet-container {
  background-color: #e0f2fe !important;
}

.leaflet-popup-content {
  font-family: 'Inter', sans-serif;
  line-height: 1.6;
  font-size: 0.875rem;
}

.coordinate-display {
  background: white;
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 500;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
}

/* Move Leaflet zoom controls to top right */
.leaflet-top.leaflet-left {
  top: auto !important;
  left: auto !important;
  right: 10px !important;
  top: 10px !important;
}

/* ======= MAP OVERLAY CONTROLS ======= */
.map-controls {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 350px;
}

.search-panel {
  background: white;
  border-radius: 12px;
  padding: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
}

.search-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  width: 100%;
}

.button-row {
  display: flex;
  gap: 0.5rem;
  width: 100%;
}

.search-container {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  width: 100%;
}

input[type="text"] {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8125rem;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

input[type="text"]:focus {
  outline: none;
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

button {
  padding: 0.45rem 0.75rem;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
  white-space: nowrap;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

button.secondary:hover {
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

button.icon-btn {
  background: white;
  color: #475569;
  border: 2px solid #e2e8f0;
  padding: 0.5rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}

button.icon-btn:hover {
  background: #f8fafc;
  border-color: #10b981;
  color: #10b981;
  transform: translateY(-1px);
}

/* ======= RESULTS ======= */
#results {
  background: white;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  max-height: 250px;
  overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  margin-top: 0.5rem;
}

#results ul {
  list-style: none;
}

#results li {
  padding: 0.875rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9375rem;
  transition: background 0.15s ease;
}

#results li:last-child {
  border-bottom: none;
}

#results li:hover {
  background: #f8fafc;
}

/* ======= FILTERS ======= */
.filters-panel {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.filters-toggle {
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  color: #475569;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  background: white;
}

.filters-toggle:hover {
  background: #f8fafc;
}

.filters-content {
  padding: 0.75rem;
  display: none;
  background: white;
  border-top: 2px solid #e2e8f0;
}

.filters-content.active {
  display: block;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: #475569;
}

select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-family: 'Inter', sans-serif;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
}

select:focus {
  outline: none;
  border-color: #10b981;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #10b981;
  cursor: pointer;
}

/* ======= INFO BUTTONS - BOTTOM CENTER ======= */
.info-buttons {
  position: absolute;
  bottom: 3.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  gap: 0.75rem;
}

.info-btn {
  background: white;
  border: 2px solid #e2e8f0;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.info-btn:hover {
  background: #10b981;
  border-color: #10b981;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* ======= MODAL ======= */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  position: relative;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 2px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 10;
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0f172a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.modal-body h4:first-child {
  margin-top: 0;
}

.modal-body ul {
  margin-left: 1.5rem;
  color: #475569;
  line-height: 1.7;
}

.modal-body li {
  margin: 0.5rem 0;
}

.modal-body p {
  color: #475569;
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

.modal-body a {
  color: #10b981;
  text-decoration: none;
  font-weight: 500;
}

.modal-body a:hover {
  text-decoration: underline;
}

/* ======= OTHER TABS (Konvertera, Hämta geodata) ======= */
.page-content {
  height: 100%;
  overflow-y: auto;
  padding: 2rem;
  background: #f8fafc;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e2e8f0;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f1f5f9;
}

.section-header h2 {
  font-size: 1.375rem;
  font-weight: 600;
  color: #0f172a;
}

/* ======= CONVERTER ======= */
.converter-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.converter-results {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 1.25rem;
}

.converter-results h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 1rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  padding: 0.625rem 0;
  border-bottom: 1px solid #e2e8f0;
}

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

.result-label {
  font-weight: 600;
  color: #475569;
}

.result-value {
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
  color: #0f172a;
}

/* ======= FILE UPLOAD ======= */
.upload-area {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}

.custom-file-upload {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.3rem;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9375rem;
  color: #475569;
  transition: all 0.2s ease;
}

.custom-file-upload:hover {
  background: #f1f5f9;
  border-color: #10b981;
  color: #10b981;
}

input[type="file"] {
  display: none;
}

.file-info {
  color: #64748b;
  font-size: 0.875rem;
}

/* ======= RADIO BUTTONS ======= */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.radio-group label:hover {
  background: #f1f5f9;
  border-color: #10b981;
}

.radio-group input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: #10b981;
  cursor: pointer;
}

/* ======= INFO BOX ======= */
.info-box {
  background: #f0fdf4;
  border-left: 4px solid #10b981;
  border-radius: 10px;
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.info-box h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.75rem;
}

.info-box ul {
  margin-left: 1.5rem;
  color: #475569;
}

.info-box li {
  margin: 0.5rem 0;
}

details {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  padding: 0;
  margin: 1rem 0;
}

details summary {
  padding: 0.875rem 1.25rem;
  cursor: pointer;
  font-weight: 600;
  color: #475569;
  user-select: none;
}

details[open] summary {
  border-bottom: 2px solid #e2e8f0;
}

details .details-content {
  padding: 1.25rem;
}

/* ======= TABLE ======= */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

table td:first-child {
  font-family: 'SF Mono', 'Monaco', 'Courier New', monospace;
  font-weight: 600;
  color: #0f172a;
  background: #f8fafc;
}

/* ======= RESPONSIVE ======= */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
  }

  .tab-nav {
    width: 100%;
    flex-direction: column;
  }

  .tab-button {
    width: 100%;
    text-align: center;
  }

  .map-controls {
    max-width: calc(100% - 2rem);
    top: 0.5rem;
    left: 0.5rem;
  }
  
  .search-panel {
    padding: 0.75rem;
  }

  .search-header {
    gap: 0.5rem;
    margin-bottom: 0.5rem;
  }

  .search-row {
    flex-direction: row;
    gap: 0.5rem;
  }

  input[type="text"] {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }

  button {
    font-size: 0.875rem;
    padding: 0.5rem 0.875rem;
  }
  
  .button-row button {
    padding: 0.5rem;
    font-size: 0.875rem;
  }

  .info-buttons {
    bottom: 2.5rem;
    gap: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .info-btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.875rem;
  }

  .page-content {
    padding: 1rem;
  }
  
  .filters-panel {
    font-size: 0.8125rem;
  }
  
  .filters-toggle {
    padding: 0.45rem 0.7rem;
    font-size: 0.8125rem;
  }
  
  #results li {
    padding: 0.55rem 0.65rem;
    font-size: 0.8125rem;
  }
}

/* ======= VISA PÅ KARTA TAB ======= */
#map-view-upload {
  height: 100%;
  position: relative;
}

#map-upload {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.upload-controls {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 500;
  max-width: 350px;
}

.upload-panel {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid #e2e8f0;
}

.upload-panel h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.5rem;
}

.upload-panel code {
  background: #f1f5f9;
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: 'SF Mono', 'Monaco', monospace;
}

.upload-area-compact {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
  .upload-controls {
    max-width: calc(100% - 2rem);
    top: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
  }
}

/* ======= JULSNÖ I HEADER ======= */
header {
  position: relative;
  overflow: hidden;
}

.snowflake {
  position: absolute;
  top: -20px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.2rem;
  animation: fall linear infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes fall {
  0% {
    transform: translateY(-20px);
    opacity: 1;
  }
  100% {
    transform: translateY(120px);
    opacity: 0;
  }
}

/* Skapa flera snöflingor med olika positioner och hastigheter */
.snowflake:nth-child(1) { left: 5%; animation-duration: 4s; animation-delay: 0s; font-size: 1rem; }
.snowflake:nth-child(2) { left: 15%; animation-duration: 5s; animation-delay: 1s; font-size: 1.4rem; }
.snowflake:nth-child(3) { left: 25%; animation-duration: 4.5s; animation-delay: 2s; font-size: 0.9rem; }
.snowflake:nth-child(4) { left: 35%; animation-duration: 5.5s; animation-delay: 0.5s; font-size: 1.2rem; }
.snowflake:nth-child(5) { left: 45%; animation-duration: 4s; animation-delay: 1.5s; font-size: 1.1rem; }
.snowflake:nth-child(6) { left: 55%; animation-duration: 5s; animation-delay: 0.8s; font-size: 1.3rem; }
.snowflake:nth-child(7) { left: 65%; animation-duration: 4.5s; animation-delay: 2.2s; font-size: 1rem; }
.snowflake:nth-child(8) { left: 75%; animation-duration: 5.5s; animation-delay: 1.2s; font-size: 0.95rem; }
.snowflake:nth-child(9) { left: 85%; animation-duration: 4.8s; animation-delay: 0.3s; font-size: 1.15rem; }
.snowflake:nth-child(10) { left: 95%; animation-duration: 5.2s; animation-delay: 1.8s; font-size: 1.05rem; }
