:root {
  --verde: #526046;
  --verde-hover: #3f4b35;
  --sage: #adb49b;
  --claro: #f4f5f2;
  --branco: #ffffff;
  --texto: #2e332a;
  --texto-suave: #6c7366;
  --borda: rgba(173, 180, 155, 0.42);
  --perigo: #c0392b;
  --sucesso: #2e7d32;
}

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

body {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--claro);
  color: var(--texto);
  min-height: 100vh;
}

/* ─── LOGIN VIEW ─── */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, rgba(173,180,155,0.28), transparent 60%), var(--claro);
}

.login-card {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 16px 40px rgba(82, 96, 70, 0.08);
  text-align: center;
}

.login-card h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.1rem;
  color: var(--verde);
  margin-bottom: 6px;
}

.login-card p.sub {
  font-size: 0.88rem;
  color: var(--texto-suave);
  margin-bottom: 26px;
}

/* ─── TOPBAR & LAYOUT ─── */
.admin-header {
  background: var(--verde);
  color: var(--branco);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-area h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-badge {
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-radius: 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.event-link-status {
  color: var(--verde);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.event-card-actions button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.25);
}

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ─── STATS CARDS ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 16px;
  padding: 20px 22px;
  box-shadow: 0 4px 14px rgba(82, 96, 70, 0.04);
}

.stat-card .stat-label {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--texto-suave);
  display: block;
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.3rem;
  font-weight: 600;
  color: var(--verde);
  line-height: 1.1;
}

.stat-card .stat-hint {
  font-size: 0.78rem;
  color: var(--sage);
  margin-top: 4px;
}

/* ─── DOMAIN BAR ─── */
.domain-bar {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
}

.domain-bar-info strong {
  font-size: 0.86rem;
  color: var(--verde);
  display: block;
}

.domain-bar-info span {
  font-size: 0.8rem;
  color: var(--texto-suave);
}

.domain-bar-form {
  display: flex;
  gap: 10px;
  flex: 1;
  max-width: 500px;
}

.domain-bar-form input {
  flex: 1;
}

/* ─── TABS NAVIGATION ─── */
.nav-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--borda);
  padding-bottom: 12px;
  flex-wrap: wrap;
}

.nav-tab {
  background: var(--branco);
  border: 1px solid var(--borda);
  color: var(--texto-suave);
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab.active {
  background: var(--verde);
  color: var(--branco);
  border-color: var(--verde);
  box-shadow: 0 4px 12px rgba(82, 96, 70, 0.2);
}

/* ─── BUTTONS & INPUTS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  font-family: 'Lato', sans-serif;
  font-size: 0.84rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}

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

.btn-primary:hover {
  background: var(--verde-hover);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--verde);
  color: var(--verde);
}

.btn-outline:hover {
  background: rgba(82, 96, 70, 0.08);
}

.btn-danger {
  background: rgba(192, 57, 43, 0.1);
  color: var(--perigo);
}

.btn-danger:hover {
  background: var(--perigo);
  color: #fff;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.76rem;
  border-radius: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--borda);
  border-radius: 10px;
  font-family: 'Lato', sans-serif;
  font-size: 0.92rem;
  background: #fff;
  color: var(--texto);
  outline: none;
  transition: border-color 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--verde);
}

label {
  display: block;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--verde);
  margin-bottom: 6px;
}

/* ─── EVENTS GRID ─── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.75rem;
  color: var(--verde);
}

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

.event-card {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 6px 20px rgba(82, 96, 70, 0.05);
}

.event-card-banner {
  height: 150px;
  background: #eaece7;
  position: relative;
  overflow: hidden;
}

.event-card-banner img.cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.event-card-logo {
  position: absolute;
  bottom: 10px;
  right: 12px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  padding: 6px;
  object-fit: contain;
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.event-card-body {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.event-card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  color: var(--verde);
  margin-bottom: 4px;
}

.event-card-meta {
  font-size: 0.82rem;
  color: var(--texto-suave);
  margin-bottom: 12px;
}

.generated-link-box {
  background: rgba(82, 96, 70, 0.06);
  border: 1px dashed rgba(82, 96, 70, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.generated-link-box small {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sage);
  margin-bottom: 3px;
}

.generated-link-box a {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--verde);
  word-break: break-all;
  text-decoration: none;
}

.generated-link-box a:hover {
  text-decoration: underline;
}

.event-mini-stats {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.mini-pill {
  flex: 1;
  background: var(--claro);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}

.mini-pill strong {
  display: block;
  font-size: 1rem;
  color: var(--verde);
}

.mini-pill span {
  font-size: 0.68rem;
  color: var(--texto-suave);
  text-transform: uppercase;
}

.event-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* ─── TABLES (LEADS & RSVPS) ─── */
.panel-box {
  background: var(--branco);
  border: 1px solid var(--borda);
  border-radius: 16px;
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: 0 4px 16px rgba(82, 96, 70, 0.04);
}

.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar > * {
  flex: 1;
  min-width: 200px;
}

.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(173, 180, 155, 0.25);
}

th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--verde);
  background: rgba(82, 96, 70, 0.05);
}

.gift-click-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(82, 96, 70, 0.1);
  color: var(--verde);
  border-radius: 16px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  margin: 2px 4px 2px 0;
  text-decoration: none;
}

.gift-click-tag:hover {
  background: var(--verde);
  color: #fff;
}

/* ─── MODAL FORM CREATE / EDIT EVENT ─── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(25, 30, 22, 0.55);
  backdrop-filter: blur(4px);
  z-index: 200;
  overflow-y: auto;
  padding: 28px 16px;
}

.modal-backdrop.active {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.modal-content {
  background: var(--branco);
  border-radius: 20px;
  max-width: 820px;
  width: 100%;
  padding: 30px 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  margin: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--borda);
}

.modal-header h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.7rem;
  color: var(--verde);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-full {
  grid-column: 1 / -1;
}

.upload-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.upload-row input[type="text"] {
  flex: 1;
}

.file-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(82, 96, 70, 0.12);
  color: var(--verde);
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  margin: 0;
}

.file-upload-label:hover {
  background: rgba(82, 96, 70, 0.22);
}

.gift-item-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--verde);
  color: #fff;
  padding: 14px 22px;
  border-radius: 12px;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  z-index: 400;
  display: none;
}

.toast.show {
  display: block;
}

@media (max-width: 680px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .events-grid {
    grid-template-columns: 1fr;
  }
}

.html-editor-dialog { width: min(1200px, 96vw); max-height: 92vh; margin: auto; border: 1px solid var(--borda); border-radius: 16px; padding: 24px; color: var(--texto); background: var(--branco, #fff); overflow-y: auto; }
.html-editor-dialog::backdrop { background: rgba(0,0,0,.55); }
.html-editor-header, .html-editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.html-editor-dialog p { margin: 12px 0; line-height: 1.5; }
#htmlEditorStatus { min-height: 24px; font-weight: 600; }
#htmlEditorSource { width: 100%; height: 48vh; margin: 8px 0 16px; font: 13px/1.6 Consolas, monospace; tab-size: 2; white-space: pre; }
#htmlEditorFrame { width: 100%; height: 65vh; border: 1px solid var(--borda); margin-top: 12px; background: white; }
@media (max-width: 600px) { .html-editor-dialog { padding: 16px; } .html-editor-actions > * { flex: 1 1 100%; text-align: center; } }
