/* 上田市 遊休施設管理プラットフォーム - Theme CSS */

/* =========================================================
   Google Fonts
   ========================================================= */
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&display=swap');

/* =========================================================
   CSS Custom Properties
   ========================================================= */
:root {
  --color-primary:       #6366f1;
  --color-primary-light: #818cf8;
  --color-secondary:     #f0abfc;
  --color-bg-start:      #f0f4ff;
  --color-bg-end:        #fdf4ff;

  /* Status colours */
  --status-haishi:  #ef4444;   /* 廃止検討 red    */
  --status-tenyou:  #f97316;   /* 転用検討 orange */
  --status-katsuyo: #22c55e;   /* 活用決定 green  */
  --status-chosa:   #94a3b8;   /* 調査中   gray   */
}

/* =========================================================
   Reset / Base
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Noto Sans JP', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  color: #1e293b;
  line-height: 1.6;
}

/* =========================================================
   Animated Blob Background
   ========================================================= */
.blob-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
  animation: blobFloat 12s ease-in-out infinite;
}

.blob-1 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #818cf8, #c084fc);
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.blob-2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #34d399, #06b6d4);
  bottom: -50px;
  right: -50px;
  animation-delay: -4s;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #f9a8d4, #fb923c);
  top: 40%;
  left: 60%;
  animation-delay: -8s;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%       { transform: translate(30px, -30px) scale(1.05); }
  66%       { transform: translate(-20px, 20px) scale(0.95); }
}

/* =========================================================
   Glass Card
   ========================================================= */
.glass-card {
  background: rgba(255, 255, 255, 0.70);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.50);
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.08);
  border-radius: 1rem;
}

/* =========================================================
   Top Navigation
   ========================================================= */
.top-nav {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(99, 102, 241, 0.12);
  box-shadow: 0 2px 16px rgba(99, 102, 241, 0.06);
  position: sticky;
  top: 0;
  z-index: 200;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background: rgba(99, 102, 241, 0.08);
  color: #6366f1;
}

.nav-tab.active {
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.30);
}

/* =========================================================
   Status Badges
   ========================================================= */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

/* 廃止検討 — red */
.badge-廃止検討,
.status-haishi {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* 転用検討 — orange */
.badge-転用検討,
.status-tenyou {
  background: #fff7ed;
  color: #ea580c;
  border: 1px solid #fed7aa;
}

/* 活用決定 — green */
.badge-活用決定,
.status-katsuyo {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

/* 調査中 — gray */
.badge-調査中,
.status-chosa {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* =========================================================
   Sidebar / Filter Panel
   ========================================================= */
.sidebar {
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid rgba(99, 102, 241, 0.10);
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.filter-checkbox:hover {
  background: rgba(99, 102, 241, 0.06);
}

.filter-checkbox input[type="checkbox"] {
  accent-color: #6366f1;
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* =========================================================
   Search Input
   ========================================================= */
.search-input {
  width: 100%;
  padding: 0.6rem 0.875rem 0.6rem 2.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.90);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

/* =========================================================
   Map Container — fills height via flex parent
   ========================================================= */
#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

.map-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* =========================================================
   Detail Panel — slides in from the right
   ========================================================= */
.detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
  width: 400px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-left: 1px solid rgba(99, 102, 241, 0.15);
  box-shadow: -8px 0 40px rgba(99, 102, 241, 0.10);
  z-index: 1000;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel.open {
  transform: translateX(0);
}

/* Mobile: slide up from bottom */
@media (max-width: 640px) {
  .detail-panel {
    width: 100%;
    height: 70vh;
    top: auto;
    bottom: 0;
    transform: translateY(100%);
    border-left: none;
    border-top: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: 1.5rem 1.5rem 0 0;
    box-shadow: 0 -8px 40px rgba(99, 102, 241, 0.10);
  }

  .detail-panel.open {
    transform: translateY(0);
  }
}

/* =========================================================
   Facility Table (List View)
   ========================================================= */
.facility-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.facility-table thead th {
  position: sticky;
  top: 0;
  background: rgba(248, 250, 252, 0.95);
  backdrop-filter: blur(8px);
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
}

.facility-table thead th:hover {
  color: #6366f1;
}

.facility-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.facility-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid #f1f5f9;
}

.facility-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

.facility-table tbody tr.selected {
  background: rgba(99, 102, 241, 0.08);
}

.facility-table tbody td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
  color: #1e293b;
}

/* =========================================================
   Priority Score Bar
   ========================================================= */
.score-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.score-bar-bg {
  flex: 1;
  height: 6px;
  border-radius: 9999px;
  background: #e2e8f0;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #f97316, #ef4444);
  transition: width 0.4s ease;
}

/* =========================================================
   Custom Scrollbar
   ========================================================= */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.20);
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.40);
}

/* =========================================================
   Detail Panel Info Items
   ========================================================= */
.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.info-label {
  font-size: 0.70rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.info-value {
  font-size: 0.90rem;
  font-weight: 500;
  color: #1e293b;
}

/* =========================================================
   Loading Spinner
   ========================================================= */
.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(99, 102, 241, 0.20);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* =========================================================
   Leaflet Map Customisation
   ========================================================= */
.custom-marker {
  width: 28px !important;
  height: 28px !important;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 3px solid #ffffff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.leaflet-tooltip {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.70);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.10);
  padding: 0.4rem 0.75rem;
  color: #1e293b;
}

/* =========================================================
   Responsive Helpers
   ========================================================= */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 500;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }
}
