/* Hanyang University brand colors — https://www.hanyang.ac.kr/colors-fonts */
:root {
  --hy-blue: #1d2475;
  --hy-blue-dark: #151b5c;
  --hy-blue-light: #e8eaf5;
  --hy-gray: #3f3d42;
  --hy-gray-light: #6b6970;
  --hy-silver: #939396;
  --hy-green: #a6ce39;
  --hy-orange: #f7931e;
  --hy-gold: #ab863f;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --text: #1a1a1f;
  --muted: var(--hy-gray-light);
  --primary: var(--hy-blue);
  --primary-hover: var(--hy-blue-dark);
  --border: #dde0e8;
  --shadow-sm: 0 1px 3px rgba(29, 36, 117, 0.06);
  --shadow: 0 4px 20px rgba(29, 36, 117, 0.08);
  --radius: 10px;
  --radius-lg: 14px;
  --header-h: 72px;
  --sticky-actions-h: 11rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1.5rem;
  background: var(--surface);
  border-bottom: 3px solid var(--hy-blue);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
}

.header-logo-link {
  display: flex;
  flex-shrink: 0;
  line-height: 0;
}

.header-logo {
  display: block;
  height: 36px;
  width: auto;
}

.header-title-group {
  min-width: 0;
  padding-left: 1rem;
  border-left: 1px solid var(--border);
}

.app-header h1 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--hy-blue);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.auth-area {
  font-size: 0.8125rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.locale-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.locale-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.locale-select,
.campus-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231d2475' d='M2.5 4.5 6 8l3.5-3.5'/%3E%3C/svg%3E") no-repeat right 0.6rem center;
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.locale-select:hover,
.campus-select:hover {
  border-color: var(--hy-silver);
}

.locale-select:focus,
.campus-select:focus {
  outline: none;
  border-color: var(--hy-blue);
  box-shadow: 0 0 0 3px rgba(29, 36, 117, 0.12);
}

/* ── Main layout ── */
.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 900px) {
  .app-main {
    grid-template-columns: 320px 1fr;
    align-items: start;
    max-width: min(1100px, 96vw);
  }

  .map-panel {
    position: sticky;
    top: calc(var(--header-h) + 1.25rem);
  }

  .map-container {
    height: clamp(460px, 55vh, 640px);
  }
}

@media (min-width: 1200px) {
  .app-main {
    max-width: min(1280px, 94vw);
    grid-template-columns: minmax(300px, 320px) 1fr;
  }

  .map-container {
    height: clamp(540px, 62vh, 760px);
  }
}

@media (min-width: 1600px) {
  .app-main {
    max-width: min(1500px, 92vw);
  }

  .map-container {
    height: clamp(600px, 68vh, 880px);
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 700;
  color: var(--hy-blue);
  letter-spacing: -0.01em;
}

.panel-title::before {
  content: "";
  display: block;
  width: 4px;
  height: 1.1em;
  background: var(--hy-blue);
  border-radius: 2px;
  flex-shrink: 0;
}

.field-label {
  display: block;
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--hy-gray);
}

.campus-switcher {
  margin-bottom: 1rem;
}

.campus-select {
  width: 100%;
  padding: 0.65rem 2rem 0.65rem 0.75rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
}

input[type="search"],
input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 0.7rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="search"]:focus,
input[type="text"]:focus {
  outline: none;
  border-color: var(--hy-blue);
  box-shadow: 0 0 0 3px rgba(29, 36, 117, 0.12);
}

button {
  padding: 0.7rem 1.125rem;
  border: none;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  transform: scale(0.98);
}

#search-btn {
  min-width: 4.5rem;
}

/* ── Search results ── */
.result-list {
  list-style: none;
  margin: 0.875rem 0 0;
  padding: 0;
  max-height: 40vh;
  overflow-y: auto;
}

.result-list li {
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.375rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.result-list li:hover,
.result-list li.active {
  border-color: var(--hy-blue);
  background: var(--hy-blue-light);
}

.result-list li strong {
  color: var(--hy-blue);
  font-weight: 600;
}

.result-list .meta {
  color: var(--muted);
  font-size: 0.8125rem;
  margin-top: 0.125rem;
}

/* ── Map ── */
.map-hint {
  color: var(--muted);
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.map-official-link {
  margin: -0.25rem 0 0.75rem;
  font-size: 0.8125rem;
}

.map-official-link a {
  color: var(--hy-blue);
  font-weight: 600;
  text-decoration: none;
}

.map-official-link a:hover {
  text-decoration: underline;
}

.map-container {
  width: 100%;
  height: clamp(280px, 48vh, 520px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #e8eaef;
}

/* ── Building detail ── */
.building-detail {
  margin-top: 0.875rem;
  color: var(--muted);
}

.building-detail:not(:empty) {
  padding: 0.875rem;
  background: var(--hy-blue-light);
  border: 1px solid rgba(29, 36, 117, 0.12);
  border-radius: var(--radius);
}

.building-summary strong {
  display: block;
  color: var(--hy-blue);
  font-size: 1.0625rem;
  font-weight: 700;
}

.building-actions,
.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.btn-directions {
  flex: 1;
  min-width: 140px;
}

button.btn-secondary {
  flex: 1;
  min-width: 140px;
  background: var(--surface);
  color: var(--hy-blue);
  border: 1.5px solid var(--hy-blue);
}

button.btn-secondary:hover {
  background: var(--hy-blue-light);
}

.route-info {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(29, 36, 117, 0.15);
  color: var(--hy-blue);
  font-size: 0.875rem;
}

.route-error {
  margin-top: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.875rem;
}

.route-hint {
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.app-status {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  background: var(--hy-blue-light);
  border: 1px solid rgba(29, 36, 117, 0.15);
  color: var(--hy-blue);
  font-size: 0.875rem;
}

.app-status.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.map-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 1.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ── Map markers ── */
.naver-building-marker {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 14px;
  background: rgba(29, 36, 117, 0.92);
  border: 2px solid #fff;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(29, 36, 117, 0.35);
  cursor: pointer;
}

.naver-building-infowindow {
  min-width: 140px;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 0.8125rem;
}

.naver-building-infowindow strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--hy-blue);
}

.naver-building-infowindow span {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ── Footer ── */
.app-footer {
  padding: 1rem 1.5rem;
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.app-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--hy-silver);
  letter-spacing: 0.02em;
}

/* ── Responsive: tablet & mobile ── */
@media (max-width: 768px) {
  .app-header {
    padding: 0.75rem 1rem;
  }

  .header-logo {
    height: 28px;
  }

  .header-title-group {
    padding-left: 0.75rem;
  }

  .app-header h1 {
    font-size: 1rem;
  }

  .app-main {
    padding: 1rem;
    gap: 1rem;
  }

  .panel {
    padding: 1rem;
  }

  .search-row {
    flex-direction: column;
  }

  #search-btn {
    width: 100%;
  }

  .result-list {
    max-height: 28vh;
  }

  .map-container {
    height: clamp(260px, 40vh, 400px);
  }

  /* Sticky bottom action bar when building is selected */
  .building-detail:not(:empty) .building-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 150;
    margin: 0;
    padding: 0.75rem 1rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(29, 36, 117, 0.1);
    flex-direction: column;
  }

  .building-detail:not(:empty) .building-actions button,
  .building-detail:not(:empty) .building-actions .route-info {
    flex: none;
    width: 100%;
    min-width: 0;
  }

  body:has(.building-detail:not(:empty) .building-actions) {
    padding-bottom: calc(var(--sticky-actions-h) + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 480px) {
  .app-header {
    flex-wrap: wrap;
  }

  .header-brand {
    flex: 1;
    min-width: 0;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
  }

  .locale-label {
    display: none;
  }
}
