/* ==========================================================================
   Premium CSS Design System - JMA Storm Warning Monitor
   ========================================================================== */

:root {
  /* HSL Color Palette */
  --bg-main: hsl(220, 24%, 7%);
  --bg-card: hsla(220, 20%, 12%, 0.65);
  --bg-header: hsla(220, 24%, 6%, 0.8);
  --border-color: hsla(220, 15%, 20%, 0.6);
  --border-focus: hsla(220, 30%, 40%, 0.8);
  
  --text-primary: hsl(220, 20%, 95%);
  --text-secondary: hsl(220, 10%, 65%);
  --text-muted: hsl(220, 8%, 45%);
  
  /* Warning Specific Colors (JMA Standards with Premium Highlights) */
  --color-normal: hsl(220, 12%, 22%);
  --color-normal-hover: hsl(220, 15%, 28%);
  --color-advisory: hsl(45, 90%, 50%); /* Amber Yellow Advisory */
  --color-advisory-hover: hsl(45, 100%, 58%);
  --color-warning: hsl(358, 85%, 52%); /* Vibrant Warning Red */
  --color-warning-hover: hsl(358, 90%, 58%);
  --color-special: hsl(285, 95%, 45%); /* Neon Purple Special Warning */
  --color-special-hover: hsl(285, 100%, 55%);
  
  /* Accent Colors */
  --accent-blue: hsl(207, 95%, 55%);
  --accent-green: hsl(142, 70%, 45%);
  --accent-yellow: hsl(45, 90%, 50%);
  
  /* Layout Constants */
  --header-height: 80px;
  --max-width: 1600px;
  
  /* Smooth Shadows & Transitions */
  --shadow-premium: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  --shadow-glow-yellow: 0 0 15px hsla(45, 90%, 50%, 0.4);
  --shadow-glow-red: 0 0 15px hsla(358, 85%, 52%, 0.4);
  --shadow-glow-purple: 0 0 20px hsla(285, 95%, 45%, 0.5);
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --font-display: 'Outfit', 'Inter', 'Noto Sans JP', sans-serif;
  --font-body: 'Inter', 'Noto Sans JP', sans-serif;
}

/* ==========================================================================
   Basic Resets & Base Styles
   ========================================================================== */

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

body {
  background-color: var(--bg-main);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-blue);
  text-decoration: none;
  transition: var(--transition-smooth);
}

a:hover {
  text-decoration: underline;
  filter: brightness(1.2);
}

button {
  font-family: var(--font-display);
  cursor: pointer;
  border: none;
  background: none;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--color-normal);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==========================================================================
   Top Header & Navigation (Glassmorphic)
   ========================================================================== */

.app-header {
  height: var(--header-height);
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  flex-direction: column;
}

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

.live-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  background-color: var(--accent-green);
  border-radius: 50%;
  margin-right: 8px;
  align-self: center;
}

.logo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, #ffffff 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.brand {
  display: flex;
  flex-direction: column;
}

.brand-wrapper {
  display: flex;
  align-items: center;
}

.tagline {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Header Statistics Overview */
.stats-overview {
  display: flex;
  gap: 20px;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 20px;
  border-radius: 30px;
  border: 1px solid var(--border-color);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 12px;
  color: #fff;
  min-width: 32px;
  text-align: center;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.special-badge {
  background-color: var(--color-special);
  box-shadow: var(--shadow-glow-purple);
}

.warning-badge {
  background-color: var(--color-warning);
  box-shadow: var(--shadow-glow-red);
}

.advisory-badge {
  background-color: var(--color-advisory);
  color: #111;
  box-shadow: var(--shadow-glow-yellow);
}

.normal-badge {
  background-color: var(--color-normal);
  color: var(--text-secondary);
}

/* Header Controls & Timer */
.header-controls {
  display: flex;
  align-items: center;
  gap: 20px;
}

.timer-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.timer-label {
  color: var(--text-muted);
}

.timer-value {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent-blue);
  letter-spacing: 0.5px;
}

.refresh-button {
  background: linear-gradient(135deg, hsl(207, 95%, 45%) 0%, hsl(207, 95%, 55%) 100%);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-smooth);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.refresh-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.refresh-button:active {
  transform: translateY(1px);
}

.refresh-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.5s ease;
}

.refresh-button:hover .refresh-icon {
  transform: rotate(180deg);
}

/* ==========================================================================
   Layout Structures (Main Area)
   ========================================================================== */

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 30px;
  display: flex;
}

.app-container {
  display: grid;
  grid-template-columns: 1fr 450px;
  gap: 30px;
  width: 100%;
}

.panel {
  display: flex;
  flex-direction: column;
}

/* Premium Card Concept */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
  backdrop-filter: blur(25px);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  transition: border-color 0.3s;
}

.card:hover {
  border-color: var(--border-focus);
}

.card-header {
  padding: 20px 25px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.border-b {
  border-bottom: 1px solid var(--border-color);
}

/* ==========================================================================
   Map Visualizer Component (Left Panel)
   ========================================================================== */

.map-card {
  min-height: 680px;
}

.map-legend {
  display: flex;
  gap: 15px;
  font-size: 12px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.normal-color { background-color: var(--color-normal); }
.warning-color { background-color: var(--color-warning); }
.special-color { background-color: var(--color-special); }

.map-viewport {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, hsl(220, 20%, 10%) 0%, hsl(220, 25%, 6%) 100%);
  padding: 30px;
  overflow: hidden;
}

/* Loader styling */
.loader-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  color: var(--text-secondary);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

/* SVG Interactive Prefectures Map */
.map-viewport svg {
  width: 100%;
  height: 100%;
  max-height: 650px;
  filter: drop-shadow(0 15px 30px rgba(0,0,0,0.6));
}

.prefecture {
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
}

/* SVG Path base styling via groups */
.prefecture polygon,
.prefecture path {
  transition: fill 0.3s ease, stroke 0.3s ease;
}

/* Color states based on warnings classes (managed by JavaScript) */
.prefecture[data-storm-level="0"] polygon,
.prefecture[data-storm-level="0"] path,
.prefecture[data-storm-level="1"] polygon,
.prefecture[data-storm-level="1"] path {
  fill: var(--color-normal);
  stroke: #161b22;
  stroke-width: 0.8px;
}

.prefecture[data-storm-level="2"] polygon,
.prefecture[data-storm-level="2"] path {
  fill: var(--color-warning);
  stroke: hsla(358, 85%, 20%, 0.8);
  stroke-width: 0.8px;
}

.prefecture[data-storm-level="3"] polygon,
.prefecture[data-storm-level="3"] path {
  fill: var(--color-special);
  stroke: hsla(285, 95%, 20%, 0.8);
  stroke-width: 0.8px;
}

/* Interactivity (Hover states) */
.prefecture:hover polygon,
.prefecture:hover path {
  stroke: #ffffff !important;
  stroke-width: 1.5px !important;
  filter: brightness(1.25);
}

.prefecture[data-storm-level="0"]:hover polygon,
.prefecture[data-storm-level="0"]:hover path,
.prefecture[data-storm-level="1"]:hover polygon,
.prefecture[data-storm-level="1"]:hover path {
  fill: var(--color-normal-hover);
}

.prefecture[data-storm-level="2"]:hover polygon,
.prefecture[data-storm-level="2"]:hover path {
  fill: var(--color-warning-hover);
  filter: drop-shadow(0 0 8px rgba(230, 0, 18, 0.6));
}

.prefecture[data-storm-level="3"]:hover polygon,
.prefecture[data-storm-level="3"]:hover path {
  fill: var(--color-special-hover);
  filter: drop-shadow(0 0 10px rgba(160, 0, 200, 0.7));
}

/* Focus clicked state class (managed by JS) */
.prefecture.selected-focus polygon,
.prefecture.selected-focus path {
  stroke: var(--accent-blue) !important;
  stroke-width: 2px !important;
  filter: brightness(1.1);
}

/* Boundary lines inside map */
.boundary-line line {
  stroke: var(--border-color) !important;
  stroke-width: 8px !important;
}

/* ==========================================================================
   Details Sidebar Panel (Right Panel)
   ========================================================================== */

.sidebar-panel {
  height: calc(100vh - var(--header-height) - 140px);
  min-height: 680px;
}

.update-stamp {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.5px;
}

.sidebar-content {
  flex: 1;
  padding: 25px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* Default Welcome / Empty State */
.welcome-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto 0;
  padding: 20px 0;
}

.welcome-icon-wrapper {
  background: hsla(220, 20%, 15%, 0.8);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
}

.welcome-icon {
  width: 32px;
  height: 32px;
  color: var(--accent-blue);
}

.welcome-state h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.welcome-desc {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 300px;
  margin-bottom: 30px;
}

/* Welcome Active Prefectures List Card */
.sidebar-stats-card {
  width: 100%;
  background: rgba(0,0,0,0.15);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  text-align: left;
}

.sidebar-stats-card h4 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.active-prefectures-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.empty-list-msg {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

.active-pref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border-left: 3px solid var(--border-color);
  font-size: 13px;
}

.active-pref-item.item-advisory {
  border-left-color: var(--color-advisory);
  background: hsla(45, 90%, 50%, 0.03);
}

.active-pref-item.item-warning {
  border-left-color: var(--color-warning);
  background: hsla(358, 85%, 52%, 0.03);
}

.active-pref-item.item-special {
  border-left-color: var(--color-special);
  background: hsla(285, 95%, 45%, 0.03);
}

.active-pref-item .pref-name {
  font-weight: 600;
  color: var(--text-primary);
}

/* Dynamic Details State */
.details-state {
  display: flex;
  flex-direction: column;
  gap: 25px;
  animation: fadeIn 0.4s ease;
}

.pref-badge-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.selected-pref-name {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 14px;
  border-radius: 30px;
  text-transform: uppercase;
}

.badge-normal {
  background-color: var(--color-normal);
  color: var(--text-secondary);
}

.badge-advisory {
  background-color: var(--color-advisory);
  color: #111;
  box-shadow: var(--shadow-glow-yellow);
  animation: pulse-glow-yellow 2s infinite;
}

.badge-warning {
  background-color: var(--color-warning);
  color: #fff;
  box-shadow: var(--shadow-glow-red);
  animation: pulse-glow-red 2s infinite;
}

.badge-special {
  background-color: var(--color-special);
  color: #fff;
  box-shadow: var(--shadow-glow-purple);
  animation: pulse-glow-purple 2s infinite;
}

/* Storm Warnings Section List */
.storm-alerts-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.alert-card {
  background: hsla(220, 20%, 15%, 0.8);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alert-card.alert-card-warning {
  border-left: 5px solid var(--color-warning);
  background: hsla(358, 85%, 52%, 0.02);
}

.alert-card.alert-card-special {
  border-left: 5px solid var(--color-special);
  background: hsla(285, 95%, 45%, 0.02);
}

.alert-card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.alert-card-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
}

.alert-card-title.alert-warning { color: var(--color-warning); }
.alert-card-title.alert-special { color: var(--color-special-hover); }

.alert-status-text {
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-secondary);
}

.alert-areas-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.alert-areas-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.area-pill {
  font-size: 12px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
}

/* General Alerts Section */
.all-alerts-section h4 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
}

.alerts-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.general-alert-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 13px;
  transition: var(--transition-smooth);
}

.general-alert-item:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-focus);
}

.general-alert-item.alert-danger {
  border-left: 3px solid var(--color-warning);
}

.general-alert-item.alert-special {
  border-left: 3px solid var(--color-special);
}

.general-alert-item.alert-warning {
  border-left: 3px solid var(--accent-yellow);
}

.general-alert-item .alert-name {
  font-weight: 600;
}

.general-alert-item .alert-status {
  font-size: 11px;
  color: var(--text-muted);
}

/* Helpers */
.hidden {
  display: none !important;
}

/* ==========================================================================
   Toast Notification Banner
   ========================================================================== */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: rgba(13, 17, 23, 0.9);
  border-left: 4px solid var(--accent-blue);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 4.7s;
  backdrop-filter: blur(10px);
}

.toast.toast-error {
  border-left-color: var(--color-warning);
}

.toast.toast-success {
  border-left-color: var(--accent-green);
}

/* ==========================================================================
   Premium Animations
   ========================================================================== */

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

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes pulse-glow-yellow {
  0% { box-shadow: 0 0 5px hsla(45, 90%, 50%, 0.4); }
  50% { box-shadow: 0 0 20px hsla(45, 90%, 50%, 0.8); }
  100% { box-shadow: 0 0 5px hsla(45, 90%, 50%, 0.4); }
}

@keyframes pulse-glow-red {
  0% { box-shadow: 0 0 5px hsla(358, 85%, 52%, 0.4); }
  50% { box-shadow: 0 0 20px hsla(358, 85%, 52%, 0.8); }
  100% { box-shadow: 0 0 5px hsla(358, 85%, 52%, 0.4); }
}

@keyframes pulse-glow-purple {
  0% { box-shadow: 0 0 5px hsla(285, 95%, 45%, 0.4); }
  50% { box-shadow: 0 0 25px hsla(285, 95%, 45%, 0.9); }
  100% { box-shadow: 0 0 5px hsla(285, 95%, 45%, 0.4); }
}

.animate-pulse {
  animation: pulse-glow-red 2s infinite ease-in-out;
}

.live-icon {
  animation: pulse-live 1.5s infinite;
}

@keyframes pulse-live {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

/* ==========================================================================
   Footer Component
   ========================================================================== */

.app-footer {
  background-color: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 20px 0;
  margin-top: 30px;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 30px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  text-align: center;
}

.attribution {
  font-size: 12px;
  color: var(--text-secondary);
}

.attribution a {
  font-weight: 600;
}

.disclaimer {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==========================================================================
   Responsive Adaptations
   ========================================================================== */

@media (max-width: 1200px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  
  .sidebar-panel {
    height: auto;
    min-height: auto;
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    padding: 15px;
    height: auto;
    gap: 15px;
  }
  
  .app-header {
    height: auto;
    padding: 10px 0;
  }
  
  .stats-overview {
    width: 100%;
    justify-content: center;
  }
  
  .header-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .app-main {
    padding: 15px;
  }
  
  .map-card {
    min-height: 480px;
  }
}

/* ==========================================================================
   Shiseikan University - Class Cancellation Alert Styles
   ========================================================================== */

/* Premium radial gradient when classes are cancelled */
body.classes-cancelled {
  background-color: hsl(358, 28%, 8%);
  background-image: radial-gradient(circle at top, hsl(358, 40%, 14%) 0%, hsl(220, 24%, 7%) 100%);
  background-attachment: fixed;
}

/* Premium Cancellation Banner */
.cancel-alert-banner {
  background: linear-gradient(90deg, hsla(358, 85%, 52%, 0.95), hsla(358, 95%, 42%, 0.95));
  color: #fff;
  text-align: left;
  padding: 12px 24px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 15px rgba(230, 0, 18, 0.4);
  z-index: 1000;
  position: relative;
  animation: slideDown 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.cancel-alert-banner.hidden {
  display: none !important;
}

.cancel-alert-banner .alert-icon {
  font-size: 18px;
  animation: pulse-icon 1.5s infinite ease-in-out;
}

.cancel-alert-banner .alert-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(1100px, calc(100vw - 88px));
}

.cancel-alert-banner .alert-line {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
