/* Culture Events App */

/* ── Reset & Base ─────────────────────────────────── */

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

:root {
  --bg-primary: #1a1a2e;
  --bg-card: #16213e;
  --bg-input: #0f1729;
  --bg-hover: #1f2b47;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #6a6a7a;
  --gold: #f0e6d3;
  --gold-dim: #c9b896;
  --gold-dark: #8a7a5a;
  --accent: #c9b896;
  --border: #2a2a4a;
  --critical: #e74c3c;
  --warning: #e67e22;
  --normal: #3498db;
  --success: #2ecc71;
  --radius: 8px;
  --transition: 150ms ease-out;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--gold-dim);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--gold);
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

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

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

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

::-webkit-scrollbar-thumb:hover {
  background: var(--gold-dark);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--gold-dim);
  outline-offset: 2px;
}

/* ── Layout ───────────────────────────────────────── */

.ev-layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── Header ───────────────────────────────────────── */

.ev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.ev-header__title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--gold);
  text-transform: uppercase;
}

.ev-header__title a {
  color: inherit;
}

.ev-header__actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ev-header__actions a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: color var(--transition);
}

.ev-header__actions a:hover {
  color: var(--gold);
}

/* ── Flash ────────────────────────────────────────── */

.notice,
.alert {
  padding: 10px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.notice {
  background: rgba(46, 204, 113, 0.15);
  color: var(--success);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.alert {
  background: rgba(231, 76, 60, 0.15);
  color: var(--critical);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* ── Search / Filter Row ──────────────────────────── */

.ev-search {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.ev-search__filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.ev-search__input {
  flex: 1;
  min-width: 180px;
}

.ev-search__input input {
  width: 100%;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition);
}

.ev-search__input input::placeholder {
  color: var(--text-muted);
}

.ev-search__input input:focus {
  border-color: var(--gold-dim);
  outline: none;
}

.ev-search__scopes {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Filter / Scope Chips ─────────────────────────── */

.ev-filter,
.ev-scope {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  font-size: 0.8rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  user-select: none;
}

.ev-filter:hover,
.ev-scope:hover {
  border-color: var(--gold-dark);
  color: var(--gold-dim);
}

.ev-filter--active,
.ev-scope--active {
  background: var(--gold-dim);
  color: var(--bg-primary);
  border-color: var(--gold-dim);
  font-weight: 600;
}

.ev-filter--active:hover,
.ev-scope--active:hover {
  background: var(--gold);
  border-color: var(--gold);
}

.ev-filter--separator {
  width: 1px;
  height: 20px;
  background: var(--border);
  border: none;
  padding: 0;
  margin: 0 4px;
  cursor: default;
}

/* ── Cards Grid ───────────────────────────────────── */

.ev-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  padding-bottom: 40px;
}

/* ── Event Card ───────────────────────────────────── */

.ev-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}

.ev-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.ev-card a {
  color: inherit;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.ev-card__poster {
  position: relative;
  width: 100%;
  padding-top: 150%; /* 2:3 ratio */
  background: linear-gradient(135deg, #2a2a4a 0%, #1a1a2e 100%);
  overflow: hidden;
}

.ev-card__poster img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ev-card__poster .ev-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  padding: 20px;
  background: linear-gradient(135deg, #2a2a4a 0%, #16213e 50%, #1a1a2e 100%);
}

.ev-card__body {
  padding: 10px 12px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ev-card__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gold);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ev-card__meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: auto;
}

.ev-card__meta span {
  display: block;
}

.ev-card__venue {
  color: var(--text-secondary);
}

.ev-card__rating {
  color: var(--gold-dim);
}

.ev-card__price {
  color: var(--text-muted);
}

.ev-card__updated {
  color: var(--text-muted);
  font-size: 0.7rem;
}

/* ── Badges ───────────────────────────────────────── */

.ev-badge--type {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--gold-dim);
  backdrop-filter: blur(4px);
  z-index: 1;
}

.ev-badge--urgency {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 3px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  z-index: 1;
}

.ev-badge--urgency.--critical {
  background: rgba(231, 76, 60, 0.85);
  color: #fff;
}

.ev-badge--urgency.--warning {
  background: rgba(230, 126, 34, 0.85);
  color: #fff;
}

.ev-badge--urgency.--normal {
  background: rgba(52, 152, 219, 0.7);
  color: #fff;
}

.ev-badge--favorite {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 1rem;
  color: var(--critical);
  z-index: 1;
  opacity: 0;
  transition: opacity var(--transition);
}

.ev-card:hover .ev-badge--favorite,
.ev-badge--favorite.--active {
  opacity: 1;
}

/* Inline badges (used in detail/source pages) */
.ev-badge-inline {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  background: rgba(201, 184, 150, 0.15);
  color: var(--gold-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ev-badge-inline.--critical {
  background: rgba(231, 76, 60, 0.15);
  color: var(--critical);
}

.ev-badge-inline.--warning {
  background: rgba(230, 126, 34, 0.15);
  color: var(--warning);
}

.ev-badge-inline.--normal {
  background: rgba(52, 152, 219, 0.15);
  color: var(--normal);
}

/* ── Detail Page ──────────────────────────────────── */

.ev-detail {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 32px;
  padding-bottom: 40px;
}

.ev-detail__poster {
  border-radius: var(--radius);
  overflow: hidden;
  position: sticky;
  top: 20px;
  align-self: start;
}

.ev-detail__poster img {
  width: 100%;
  border-radius: var(--radius);
}

.ev-detail__poster-placeholder {
  width: 100%;
  aspect-ratio: 2 / 3;
  background: linear-gradient(135deg, #2a2a4a 0%, #16213e 50%, #1a1a2e 100%);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.ev-detail__actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.ev-detail__info {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.ev-detail__title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.3;
}

.ev-detail__title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.ev-detail__subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

/* ── Info Grid ────────────────────────────────────── */

.ev-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.ev-info-grid__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ev-info-grid__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ev-info-grid__value {
  font-size: 0.95rem;
  color: var(--text-primary);
}

/* ── Description ──────────────────────────────────── */

.ev-description {
  line-height: 1.7;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.ev-description p {
  margin-bottom: 12px;
}

/* ── Map ──────────────────────────────────────────── */

.ev-detail__map {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.ev-detail__map iframe {
  width: 100%;
  height: 250px;
  border: none;
}

/* ── Comments ─────────────────────────────────────── */

.ev-detail__comments {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ev-detail__comments h3 {
  font-size: 1rem;
  color: var(--gold-dim);
}

.ev-comment {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 12px 16px;
  border: 1px solid var(--border);
}

.ev-comment__author {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gold-dim);
  margin-bottom: 4px;
}

.ev-comment__text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Crawl Metadata Footer ────────────────────────── */

.ev-metadata {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* ── Price History ────────────────────────────────── */

.ev-price-history {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.ev-price-history__item {
  display: flex;
  gap: 8px;
}

/* ── Sources Page ─────────────────────────────────── */

.ev-source {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ev-source__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.ev-source__header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ev-source__breadcrumb {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
}

.ev-source__breadcrumb a {
  color: var(--text-secondary);
}

.ev-source__header-actions {
  display: flex;
  gap: 8px;
}

.ev-source__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  transition: background var(--transition);
  flex-wrap: wrap;
}

.ev-source__row:hover {
  background: var(--bg-hover);
}

.ev-source__status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ev-source__status.--ok {
  background: var(--success);
}

.ev-source__status.--error {
  background: var(--critical);
}

.ev-source__status.--stale {
  background: var(--warning);
}

.ev-source__status.--unknown {
  background: var(--text-muted);
}

.ev-source__name {
  font-weight: 600;
  color: var(--gold-dim);
  flex: 1;
  min-width: 120px;
}

.ev-source__badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.ev-source__count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 60px;
}

.ev-source__last-crawl {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 100px;
}

.ev-source__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* ── Source Form ───────────────────────────────────── */

.ev-source-form {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 600px;
}

.ev-source-form h2 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.ev-source-form__field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ev-source-form__field label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.ev-source-form__field input,
.ev-source-form__field select,
.ev-source-form__field textarea {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.ev-source-form__field input:focus,
.ev-source-form__field select:focus,
.ev-source-form__field textarea:focus {
  border-color: var(--gold-dim);
  outline: none;
}

.ev-source-form__field textarea {
  min-height: 80px;
  resize: vertical;
  font-family: monospace;
  font-size: 0.85rem;
}

.ev-source-form__field select {
  appearance: none;
  background-image: 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='%23a0a0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.ev-source-form__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ev-source-form__checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.ev-source-form__checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--gold-dim);
}

.ev-source-form__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* ── Buttons ──────────────────────────────────────── */

.ev-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.ev-btn:hover {
  border-color: var(--gold-dark);
  color: var(--gold-dim);
}

.ev-btn--primary {
  background: var(--gold-dim);
  color: var(--bg-primary);
  border-color: var(--gold-dim);
}

.ev-btn--primary:hover {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--bg-primary);
}

.ev-btn--danger {
  border-color: rgba(231, 76, 60, 0.4);
  color: var(--critical);
}

.ev-btn--danger:hover {
  background: rgba(231, 76, 60, 0.15);
  border-color: var(--critical);
}

.ev-btn--favorite {
  border: none;
  background: none;
  padding: 4px 8px;
  font-size: 1.2rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition), transform var(--transition);
}

.ev-btn--favorite:hover {
  color: var(--critical);
  transform: scale(1.15);
}

.ev-btn--favorite.--active {
  color: var(--critical);
}

.ev-btn--small {
  padding: 4px 10px;
  font-size: 0.78rem;
}

.ev-btn--loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ── Login Page ───────────────────────────────────── */

.ev-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
}

.ev-login__card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.ev-login__title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 32px;
}

.ev-login__field {
  margin-bottom: 20px;
}

.ev-login__field input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  text-align: center;
  font-size: 1rem;
  letter-spacing: 2px;
  transition: border-color var(--transition);
}

.ev-login__field input::placeholder {
  color: var(--text-muted);
  letter-spacing: 1px;
}

.ev-login__field input:focus {
  border-color: var(--gold-dim);
  outline: none;
}

/* ── Infinite Scroll Sentinel ─────────────────────── */

.ev-sentinel {
  height: 1px;
  width: 100%;
}

.ev-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Crawl Status Bar ────────────────────────────── */

.ev-crawl-bar {
  background: var(--normal);
  color: white;
  font-size: 0.8rem;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ev-crawl-bar[hidden] {
  display: none !important;
}

.ev-crawl-bar--running {
  background: linear-gradient(90deg, var(--normal), #2980b9, var(--normal));
  background-size: 200% 100%;
  animation: ev-bar-slide 2s linear infinite;
}

.ev-crawl-bar--done {
  background: var(--success);
}

.ev-crawl-bar--error {
  background: var(--critical);
}

@keyframes ev-bar-slide {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.ev-crawl-bar__close {
  appearance: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-inline-start: auto;
}

.ev-crawl-bar__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Source row crawling state */
.ev-source__row.--crawling {
  border-left: 3px solid var(--normal);
}

.ev-source__row.--crawling .ev-source__status {
  animation: ev-pulse 1s ease-in-out infinite;
}

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

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 768px) {
  .ev-layout {
    padding: 0 12px;
  }

  .ev-header {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .ev-search {
    flex-direction: column;
    align-items: stretch;
  }

  .ev-search__filters,
  .ev-search__scopes {
    justify-content: center;
  }

  .ev-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .ev-detail {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .ev-detail__poster {
    position: static;
    max-width: 300px;
    margin: 0 auto;
  }

  .ev-info-grid {
    grid-template-columns: 1fr;
  }

  .ev-source__row {
    flex-direction: column;
    align-items: flex-start;
  }

  .ev-source__actions {
    margin-left: 0;
  }

  .ev-source-form__row {
    grid-template-columns: 1fr;
  }
}
