@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@600;700&family=Inter:wght@400;500;600&display=swap');

/* ── Design tokens ───────────────────────────────────── */
:root {
  --navy:        #1a3353;
  --navy-dark:   #112238;
  --navy-mid:    #2c5f8a;
  --navy-light:  #ddeeff;
  --orange:      #e07b2a;
  --orange-lt:   #f5a55a;
  --orange-pale: #fff4e8;
  --bg:          #f1f5fb;
  --white:       #ffffff;
  --text:        #1e293b;
  --muted:       #64748b;
  --border:      #dde3ed;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 2px 12px rgba(26,51,83,.09);
  --shadow-lg:   0 6px 28px rgba(26,51,83,.15);
}

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

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────── */
header {
  background: var(--navy);
  color: white;
  padding: 0 2rem;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,.22);
}

.brand { text-decoration: none; }
.brand-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: white;
  display: block;
  line-height: 1.15;
}
.brand-sub {
  font-size: .68rem;
  font-weight: 500;
  color: rgba(255,255,255,.5);
  letter-spacing: .06em;
  text-transform: uppercase;
  display: block;
}

.header-nav { display: flex; align-items: center; gap: .5rem; }

.btn-ghost {
  color: rgba(255,255,255,.72);
  text-decoration: none;
  font-size: .83rem;
  font-weight: 500;
  padding: .4rem .75rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  background: none;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.btn-ghost:hover {
  background: rgba(255,255,255,.1);
  color: white;
  border-color: rgba(255,255,255,.15);
}

/* ── Main grid ───────────────────────────────────────── */
main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.25rem;
  width: 100%;
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 2rem;
  align-items: start;
}

/* ── Section header ──────────────────────────────────── */
.section-header {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.55rem;
  color: var(--navy);
  font-weight: 700;
}
.section-count {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 500;
}

/* ── Event cards ─────────────────────────────────────── */
.events-list { display: flex; flex-direction: column; gap: .875rem; }

.event-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}
.event-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }

.event-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  cursor: pointer;
  user-select: none;
}

.date-badge {
  flex-shrink: 0;
  width: 54px;
  background: var(--navy);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: .55rem .2rem .45rem;
  color: white;
}
.date-badge .day  { font-size: 1.55rem; font-weight: 700; line-height: 1; }
.date-badge .mon  { font-size: .6rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; margin-top: .15rem; color: rgba(255,255,255,.7); }

.event-main { flex: 1; min-width: 0; }
.event-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
  margin-bottom: .25rem;
}
.event-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 .5rem;
  font-size: .8rem;
  color: var(--muted);
}
.event-church { color: var(--orange); font-weight: 600; }
.event-time::before { content: '·'; margin-right: .25rem; }
.event-desc-preview {
  font-size: .8rem;
  color: var(--muted);
  margin-top: .3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.toggle-btn {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: .75rem;
  transition: background .15s, transform .2s, color .15s;
  margin-top: .1rem;
}
.event-card.open .toggle-btn { transform: rotate(180deg); background: var(--navy-light); color: var(--navy); }

.event-body {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}
.event-card.open .event-body { display: block; }

.event-full-desc {
  font-size: .9rem;
  color: var(--text);
  line-height: 1.75;
  padding-top: 1rem;
  white-space: pre-wrap;
}

.event-flier {
  margin-top: 1rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.event-flier img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  display: block;
  background: var(--bg);
}

.event-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

.btn-sm {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .9rem;
  font-size: .8rem;
  font-weight: 600;
  border-radius: 6px;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
}
.btn-sm-navy    { background: var(--navy); color: white; }
.btn-sm-navy:hover { background: var(--navy-dark); }
.btn-sm-outline { background: transparent; color: var(--navy); border: 1.5px solid var(--navy); }
.btn-sm-outline:hover { background: var(--navy-light); }
.btn-sm-orange  { background: var(--orange); color: white; }
.btn-sm-orange:hover { background: var(--orange-lt); }

/* ── States ──────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 0 auto .75rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 3.5rem 1rem;
  color: var(--muted);
}
.empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state p { font-size: .9rem; line-height: 1.6; }

/* ── Calendar ────────────────────────────────────────── */
.sidebar { position: sticky; top: 84px; }

.cal-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}
.cal-header {
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1rem;
}
.cal-title { font-family: 'Playfair Display', serif; font-size: .95rem; font-weight: 600; }
.cal-nav {
  background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; font-size: 1.1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.cal-nav:hover { background: rgba(255,255,255,.15); color: white; }

.cal-grid { padding: .7rem; }
.cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr);
  text-align: center; font-size: .62rem; font-weight: 600;
  letter-spacing: .05em; color: var(--muted); text-transform: uppercase;
  padding-bottom: .4rem; border-bottom: 1px solid var(--border); margin-bottom: .35rem;
}
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.cal-day {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  font-size: .76rem; border-radius: 50%; color: var(--text); position: relative;
}
.cal-day.other-month { color: #d1d5db; }
.cal-day.today { background: var(--navy-light); color: var(--navy); font-weight: 700; }
.cal-day.has-event { cursor: pointer; font-weight: 600; color: var(--navy); }
.cal-day.has-event::after {
  content: ''; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; background: var(--orange); border-radius: 50%;
}
.cal-day.has-event:hover { background: var(--orange-pale); }

/* ── Footer ──────────────────────────────────────────── */
footer {
  background: var(--navy-dark);
  color: rgba(255,255,255,.4);
  text-align: center;
  padding: 1.1rem;
  font-size: .75rem;
  margin-top: auto;
}

/* ── Auth / login page ───────────────────────────────── */
.auth-page {
  min-height: 100vh;
  background: linear-gradient(150deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-mid) 100%);
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
.auth-card {
  background: white; border-radius: 16px; padding: 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 64px rgba(0,0,0,.28);
}
.auth-logo { text-align: center; margin-bottom: 2rem; }
.auth-logo-mark {
  width: 56px; height: 56px; background: var(--navy); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700;
  color: white; margin: 0 auto .75rem;
}
.auth-logo-name { font-family: 'Playfair Display', serif; font-size: 1.2rem; color: var(--navy); font-weight: 700; }
.auth-logo-sub  { font-size: .72rem; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; margin-top: .15rem; }
.auth-heading   { font-size: 1.05rem; font-weight: 600; color: var(--text); margin-bottom: 1.4rem; }

/* ── Form elements (shared) ──────────────────────────── */
.field { margin-bottom: 1.05rem; }
.field label {
  display: block; font-size: .8rem; font-weight: 600;
  color: var(--text); margin-bottom: .32rem; letter-spacing: .02em;
}
.field input,
.field select,
.field textarea {
  width: 100%; padding: .6rem .8rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .88rem; font-family: inherit; color: var(--text); background: white;
  transition: border-color .15s, box-shadow .15s; outline: none;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--navy-mid);
  box-shadow: 0 0 0 3px rgba(44,95,138,.12);
}
.field textarea { resize: vertical; min-height: 80px; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .68rem 1.4rem; background: var(--navy); color: white;
  border: none; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600;
  font-family: inherit; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn-primary:hover  { background: var(--navy-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary.full   { width: 100%; }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .62rem 1.1rem; background: transparent; color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: .85rem; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: border-color .15s, background .15s; text-decoration: none;
}
.btn-secondary:hover { border-color: var(--muted); background: var(--bg); }

.error-msg {
  background: #fee2e2; color: #b91c1c; border-radius: var(--radius-sm);
  padding: .65rem .9rem; font-size: .83rem; margin-bottom: 1rem; display: none;
}
.error-msg.show { display: block; }

/* ── Admin layout ────────────────────────────────────── */
.admin-wrap {
  max-width: 1080px; margin: 0 auto; padding: 2rem 1.25rem;
  display: grid; grid-template-columns: 360px 1fr; gap: 2rem; align-items: start;
}

.panel {
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border); overflow: hidden;
}
.panel-header {
  background: var(--navy); color: white; padding: 1rem 1.4rem;
  display: flex; align-items: center; justify-content: space-between;
}
.panel-title { font-family: 'Playfair Display', serif; font-size: 1.05rem; font-weight: 600; }
.panel-body   { padding: 1.4rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* File upload */
.upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 1.4rem; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s; position: relative;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--navy-mid); background: var(--navy-light);
}
.upload-area input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.upload-icon { font-size: 1.6rem; margin-bottom: .3rem; }
.upload-hint { font-size: .78rem; color: var(--muted); }
.upload-hint strong { color: var(--navy); }

.flier-preview { margin-top: .7rem; border-radius: var(--radius-sm); overflow: hidden; position: relative; }
.flier-preview img { width: 100%; max-height: 160px; object-fit: cover; display: block; }
.flier-preview-pdf {
  background: var(--orange-pale); padding: .65rem .9rem; border-radius: var(--radius-sm);
  font-size: .8rem; color: var(--orange); font-weight: 600;
  display: flex; align-items: center; gap: .4rem;
}
.btn-remove-flier {
  position: absolute; top: .4rem; right: .4rem;
  background: rgba(0,0,0,.55); color: white; border: none;
  border-radius: 50%; width: 22px; height: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: .7rem;
}
.btn-remove-flier-pdf {
  background: #fee2e2; color: #b91c1c; border: none;
  border-radius: 5px; padding: .25rem .55rem; font-size: .73rem; font-weight: 600;
  cursor: pointer; margin-left: auto; font-family: inherit;
}

.form-actions { display: flex; gap: .7rem; margin-top: 1.2rem; }

/* Admin event rows */
.admin-events-list { display: flex; flex-direction: column; }

.admin-row {
  display: flex; align-items: center; gap: .85rem;
  padding: .8rem 1.4rem; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.admin-row:last-child { border-bottom: none; }
.admin-row:hover { background: var(--bg); }

.admin-date {
  flex-shrink: 0; width: 44px; background: var(--navy); border-radius: 8px;
  text-align: center; padding: .35rem .15rem; color: white;
}
.admin-date .d { font-size: 1.2rem; font-weight: 700; line-height: 1; }
.admin-date .m { font-size: .55rem; text-transform: uppercase; letter-spacing: .07em; color: rgba(255,255,255,.65); }

.admin-info { flex: 1; min-width: 0; }
.admin-title { font-weight: 600; font-size: .88rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-sub   { font-size: .75rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; margin-top: .1rem; }
.admin-church { color: var(--orange); font-weight: 500; }

.admin-actions { display: flex; gap: .35rem; flex-shrink: 0; }
.btn-icon {
  width: 30px; height: 30px; border-radius: 6px;
  border: 1.5px solid var(--border); background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s; font-size: .8rem;
}
.btn-icon:hover        { background: var(--bg); border-color: var(--muted); }
.btn-icon.edit:hover   { background: var(--navy-light); border-color: var(--navy-mid); }
.btn-icon.del:hover    { background: #fee2e2; border-color: #fca5a5; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
  .sidebar { position: static; order: -1; }
  .admin-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 580px) {
  header   { padding: 0 1rem; }
  main, .admin-wrap { padding: 1.25rem .875rem; }
  .form-row { grid-template-columns: 1fr; }
  .event-card-header { padding: .9rem 1rem; }
  .brand-name { font-size: 1.1rem; }
}
