/* LA28 Itinerary Planner — laptop-first, responsive */

:root {
  color-scheme: dark;
  --bg: #0c1220;
  --bg-elevated: #141c2f;
  --bg-card: #1a2438;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-muted: #8b95a8;
  --accent: #e8b84a;
  --accent-end: #c4922a;
  --accent-dim: rgba(232, 184, 74, 0.15);
  --on-accent: #1a1205;
  --success: #5dd39e;
  --danger: #f07178;
  --status-error-text: #ffb4b9;
  --btn-hover-border: rgba(255, 255, 255, 0.15);
  --bg-gradient: radial-gradient(1200px 800px at 10% -10%, rgba(232, 184, 74, 0.08), transparent);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --font: "DM Sans", system-ui, -apple-system, sans-serif;
  --header-h: 72px;
  --itinerary-w: 380px;
  --z-fab: 40;
  --z-sheet: 30;
  --fab-badge-bg: rgba(0, 0, 0, 0.2);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f0f3fa;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #c2410c;
  --accent-end: #ea580c;
  --accent-dim: rgba(194, 65, 12, 0.1);
  --on-accent: #fffbeb;
  --success: #059669;
  --danger: #dc2626;
  --status-error-text: #b91c1c;
  --btn-hover-border: rgba(15, 23, 42, 0.18);
  --bg-gradient: radial-gradient(900px 600px at 12% -8%, rgba(234, 88, 12, 0.07), transparent);
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --fab-badge-bg: rgba(255, 255, 255, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg-gradient), var(--bg);
  color: var(--text);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#app {
  max-width: 1680px;
  margin: 0 auto;
  padding: 1rem 1.25rem 5rem;
}

/* Header */
.app-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.app-header__brand {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.app-header__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), var(--accent-end));
  color: var(--on-accent);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.app-header__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.app-header__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.app-header__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  justify-content: flex-end;
  min-width: min(100%, 420px);
}

.theme-toggle {
  flex-shrink: 0;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.theme-toggle:hover {
  border-color: var(--btn-hover-border);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-field {
  flex: 1;
  min-width: 200px;
}

.search-field input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
}

.search-field input::placeholder {
  color: var(--text-muted);
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
}

.view-toggle__btn {
  padding: 0.55rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.view-toggle__btn.is-active {
  background: var(--accent-dim);
  color: var(--accent);
}

.view-toggle__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Status banner */
.status-banner {
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.status-banner--warn {
  border-color: rgba(232, 184, 74, 0.4);
  color: var(--accent);
}

.status-banner--error {
  border-color: rgba(240, 113, 120, 0.45);
  color: var(--status-error-text);
}

html[data-theme="light"] .status-banner--error {
  border-color: rgba(220, 38, 38, 0.35);
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.toolbar__filters-toggle {
  display: none;
}

.file-load .btn {
  cursor: pointer;
}

/* Filters */
.filters-panel {
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

.filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.filter-field select,
.filter-field input {
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  grid-column: 1 / -1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}

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

.btn--ghost {
  background: transparent;
}

.btn--small {
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn--danger {
  border-color: rgba(240, 113, 120, 0.5);
  color: var(--danger);
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr var(--itinerary-w);
  gap: 1.25rem;
  align-items: start;
}

.main-panel {
  min-width: 0;
}

/* Event list */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.event-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem 1rem;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  align-items: start;
}

.event-card__emoji {
  font-size: 2rem;
  line-height: 1;
  width: 3rem;
  height: 3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.event-card__body h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.event-card__meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.event-card__desc {
  margin: 0.4rem 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.event-card__price {
  text-align: right;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.event-card__actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.event-card.is-in-itinerary {
  border-color: rgba(93, 211, 158, 0.35);
  box-shadow: 0 0 0 1px rgba(93, 211, 158, 0.12);
}

.event-card__badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(240, 113, 120, 0.2);
  color: var(--status-error-text);
  vertical-align: middle;
}

html[data-theme="light"] .event-card__badge {
  background: rgba(220, 38, 38, 0.12);
}

/* Calendar */
.calendar-view {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--bg-elevated);
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.calendar-nav__label {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-cell {
  aspect-ratio: 1;
  min-height: 72px;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-card);
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}

.calendar-cell:hover {
  border-color: var(--border);
}

.calendar-cell--muted {
  opacity: 0.35;
  cursor: default;
}

.calendar-cell--today {
  border-color: rgba(232, 184, 74, 0.35);
}

.calendar-cell--selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.calendar-cell__num {
  font-size: 0.85rem;
  font-weight: 600;
}

.calendar-cell__dots {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.calendar-day-events {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.calendar-day-events h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

/* Itinerary */
.itinerary-panel {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.itinerary-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.itinerary-panel__head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.itinerary-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}

.itinerary-list > li {
  list-style: none;
}

.itinerary-group {
  margin-bottom: 1rem;
}

.itinerary-group__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.itinerary-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem 0.65rem;
  align-items: start;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.itinerary-item:last-child {
  border-bottom: none;
}

.itinerary-item__emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.itinerary-item__title {
  font-weight: 500;
  line-height: 1.3;
}

.itinerary-item__meta {
  grid-column: 2 / -1;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.itinerary-item__price {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

.itinerary-item__remove {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  border-radius: 4px;
}

.itinerary-item__remove:hover {
  background: rgba(240, 113, 120, 0.12);
}

.itinerary-total {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.itinerary-total__row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 1rem;
}

.itinerary-total__row strong {
  font-size: 1.25rem;
  color: var(--accent);
}

.itinerary-total__note {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.empty-state {
  margin: 2rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* FAB */
.fab-itinerary {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: var(--z-fab);
  padding: 0.75rem 1.1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  align-items: center;
  gap: 0.5rem;
}

.fab-itinerary__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--fab-badge-bg);
  font-size: 0.8rem;
}

/* Mobile / tablet */
@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .itinerary-panel {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    top: auto;
    max-height: 55vh;
    z-index: var(--z-sheet);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    border-radius: var(--radius) var(--radius) 0 0;
  }

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

  .fab-itinerary {
    display: inline-flex;
  }

  .toolbar__filters-toggle {
    display: inline-flex;
    padding: 0.5rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    font: inherit;
    cursor: pointer;
  }

  .filters-panel {
    display: none;
  }

  .filters-panel.is-open {
    display: block;
  }

  .calendar-cell {
    min-height: 56px;
  }
}

@media (min-width: 1101px) {
  .itinerary-panel.is-open {
    transform: none;
  }
}
