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

:root {
  --primary: #2c6faa;
  --primary-dark: #1a4d7e;
  --primary-light: #a8d8ea;
  --accent: #f0a500;
  --bg: #f5f7fa;
  --panel-bg: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --border: #dfe6e9;
  --danger: #e74c3c;
  --success: #27ae60;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 20px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.3s ease;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

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

.map-section {
  flex: 0 0 65%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.panel-section {
  flex: 0 0 35%;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  border-left: 1px solid var(--border);
  overflow: hidden;
}

/* ==================== Map Header ==================== */
.map-header {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 16px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.app-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-dark);
  letter-spacing: 1px;
}

.app-subtitle {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* ==================== Country Search ==================== */
.country-search-wrapper {
  position: relative;
  margin-top: 10px;
}

.country-search-wrapper input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
}

.country-search-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 111, 170, 0.1);
}

.country-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 240px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 1001;
}

.country-search-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.country-search-item:hover,
.country-search-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.country-search-item .flag {
  font-size: 1.1rem;
}

/* ==================== Map ==================== */
#map {
  flex: 1;
  z-index: 1;
}

.map-legend {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  display: flex;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.8rem;
}

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

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

/* ==================== Country Tooltip ==================== */
.country-tooltip {
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  color: var(--text);
}

/* ==================== Panel Navigation ==================== */
.panel-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  padding: 14px 8px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-light);
  transition: var(--transition);
  position: relative;
}

.nav-btn:hover {
  color: var(--primary);
  background: rgba(44, 111, 170, 0.05);
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 20%;
  width: 60%;
  height: 3px;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
}

.nav-icon {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 2px;
}

/* ==================== Panel Content ==================== */
.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  animation: fadeIn 0.3s ease;
}

.panel-content.hidden {
  display: none;
}

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

/* ==================== Dashboard ==================== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.stat-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  padding: 18px 14px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  opacity: 0.9;
  margin-top: 6px;
}

.stat-sub {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 2px;
}

.continent-coverage {
  margin-bottom: 28px;
}

.continent-coverage h3,
.recent-trips h3 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 14px;
  color: var(--text);
}

.continent-bar {
  margin-bottom: 12px;
}

.continent-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 4px;
  color: var(--text-light);
}

.continent-bar-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.continent-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 4px;
  transition: width 0.8s ease;
}

/* ==================== Recent Trips ==================== */
.recent-trip-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.recent-trip-item:hover {
  box-shadow: var(--shadow);
  transform: translateX(4px);
}

.recent-trip-flag {
  font-size: 1.6rem;
}

.recent-trip-info {
  flex: 1;
}

.recent-trip-title {
  font-size: 0.85rem;
  font-weight: 500;
}

.recent-trip-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.recent-trip-rating {
  color: var(--accent);
  font-size: 0.75rem;
}

/* ==================== Country Panel ==================== */
.country-header {
  margin-bottom: 16px;
}

.country-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  display: inline;
  margin-right: 8px;
}

.country-flag {
  font-size: 1.5rem;
  vertical-align: middle;
}

.back-btn {
  display: inline-block;
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  padding: 4px 0;
  margin-bottom: 8px;
  transition: var(--transition);
}

.back-btn:hover {
  color: var(--primary-dark);
}

/* ==================== Search & Filter ==================== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-bar input[type="text"] {
  flex: 1;
  min-width: 120px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.82rem;
  outline: none;
  transition: var(--transition);
}

.search-bar input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 111, 170, 0.1);
}

.search-bar select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.82rem;
  background: white;
  cursor: pointer;
  outline: none;
}

/* ==================== Entry List ==================== */
.entries-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
  border-left: 4px solid var(--primary-light);
}

.entry-card:hover {
  box-shadow: var(--shadow);
  transform: translateX(4px);
  border-left-color: var(--primary);
}

.entry-card-title {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 4px;
}

.entry-card-meta {
  font-size: 0.78rem;
  color: var(--text-light);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.entry-card-rating {
  color: var(--accent);
}

.category-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.category-badge.business { background: #fadbd8; color: #c0392b; }
.category-badge.study { background: #d5f5e3; color: #27ae60; }
.category-badge.homecoming { background: #fdebd0; color: #e67e22; }
.category-badge.other { background: #e8daef; color: #8e44ad; }

.empty-message {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
  font-size: 0.9rem;
}

/* ==================== Entry Form ==================== */
.entry-form {
  margin-top: 12px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  outline: none;
  transition: var(--transition);
  background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(44, 111, 170, 0.1);
}

.form-group input[readonly] {
  background: var(--bg);
  color: var(--text-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group {
  flex: 1;
}

/* ==================== Star Rating ==================== */
.star-rating {
  display: flex;
  gap: 4px;
  direction: ltr;
}

.star {
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--border);
  transition: color 0.2s ease, transform 0.2s ease;
}

.star:hover,
.star.active {
  color: var(--accent);
}

.star:hover {
  transform: scale(1.2);
}

/* ==================== Buttons ==================== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.add-entry-btn {
  width: 100%;
  margin-bottom: 16px;
  padding: 12px;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.form-actions .btn {
  flex: 1;
}

/* ==================== Timeline ==================== */
.timeline {
  position: relative;
  padding-left: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 8px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
  animation: fadeIn 0.4s ease;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary-light);
}

.timeline-year {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--primary-dark);
  margin-bottom: 12px;
  margin-top: 8px;
}

.timeline-year::before {
  content: '';
  position: absolute;
  left: -22px;
  top: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary-dark);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.timeline-card:hover {
  box-shadow: var(--shadow);
  transform: translateX(4px);
}

.timeline-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.timeline-card-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.timeline-card-country {
  font-size: 0.78rem;
  color: var(--text-light);
}

.timeline-card-date {
  font-size: 0.75rem;
  color: var(--text-light);
}

.timeline-card-photo {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-top: 8px;
}

/* ==================== Settings ==================== */
.settings-section {
  margin-bottom: 28px;
}

.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.settings-section p {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 12px;
}

.danger-zone {
  border-top: 1px solid var(--danger);
  padding-top: 20px;
}

.danger-zone h3 {
  color: var(--danger);
}

/* ==================== Scrollbar ==================== */
.panel-content::-webkit-scrollbar {
  width: 6px;
}

.panel-content::-webkit-scrollbar-track {
  background: transparent;
}

.panel-content::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

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

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
  .app-container {
    flex-direction: column;
  }
  .map-section {
    flex: 0 0 50vh;
  }
  .panel-section {
    flex: 1;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .stat-cards {
    grid-template-columns: repeat(3, 1fr);
  }
}
