@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,500;0,600;0,700;1,500&family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&display=swap');

:root {
  --brand: #1e4d6b;
  --brand-deep: #0f2d42;
  --brand-light: #2a6f94;
  --accent: #c9a227;
  --accent-soft: rgba(201, 162, 39, 0.15);
  --whatsapp: #25d366;
  --surface: #ffffff;
  --surface-muted: #f7f5f1;
  --border: rgba(15, 45, 66, 0.1);
  --text: #1a2834;
  --text-muted: #5c6b78;
  --shadow-sm: 0 2px 8px rgba(15, 45, 66, 0.06);
  --shadow-md: 0 8px 32px rgba(15, 45, 66, 0.1);
  --shadow-lg: 0 16px 48px rgba(15, 45, 66, 0.12);
  --radius: 14px;
  --radius-lg: 20px;
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
}

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface-muted);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(30, 77, 107, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(201, 162, 39, 0.06), transparent);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* —— Navbar —— */
.site-nav {
  background: linear-gradient(135deg, var(--brand-deep) 0%, var(--brand) 55%, var(--brand-light) 100%);
  box-shadow: var(--shadow-md);
  padding: 0.65rem 0;
}

.site-nav .container {
  max-width: 1140px;
}

.site-nav__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #fff !important;
}

.site-nav__logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.95);
  padding: 4px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

.site-nav__title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.35rem;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

.site-nav__subtitle {
  font-size: 0.7rem;
  opacity: 0.85;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-nav .nav-link {
  color: rgba(255, 255, 255, 0.88) !important;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem !important;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
}

.site-nav .nav-link:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.12);
}

.site-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff !important;
}

.site-nav .btn-outline-light {
  border-color: rgba(255, 255, 255, 0.45);
  font-weight: 500;
  border-radius: 8px;
}

.site-nav .btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #fff;
}

/* —— Layout —— */
main.container {
  max-width: 960px;
  padding-top: 2rem;
  padding-bottom: 3rem;
}

.page-hero {
  text-align: center;
  margin-bottom: 2rem;
  padding: 1.5rem 1rem 0;
}

.page-hero__logo {
  width: 88px;
  height: 88px;
  object-fit: contain;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 16px rgba(15, 45, 66, 0.12));
}

.page-hero h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.85rem, 4vw, 2.5rem);
  color: var(--brand-deep);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.page-hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 32rem;
  margin: 0 auto;
}

.page-hero--compact {
  margin-bottom: 1.5rem;
  padding-top: 0.5rem;
}

.page-hero--compact .page-hero__logo {
  width: 56px;
  height: 56px;
  margin-bottom: 0.75rem;
}

.howto-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.howto-step {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1rem;
  box-shadow: var(--shadow-sm);
}

.howto-step__num {
  flex-shrink: 0;
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.howto-step strong {
  display: block;
  color: var(--brand-deep);
  font-size: 0.92rem;
  margin-bottom: 0.15rem;
}

.howto-step p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.howto-step code {
  font-size: 0.78rem;
}

.dash-card {
  border-radius: var(--radius);
}

@media (max-width: 768px) {
  .howto-strip {
    grid-template-columns: 1fr;
  }
}

/* —— Cards —— */
.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  overflow: hidden;
  transition: box-shadow 0.25s;
}

.panel-card:hover {
  box-shadow: var(--shadow-md);
}

.panel-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.35rem;
  background: linear-gradient(90deg, var(--brand-deep) 0%, var(--brand) 100%);
  color: #fff;
  border: none;
}

.panel-card__header h2,
.panel-card__header .panel-card__title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
  letter-spacing: 0.02em;
}

.panel-card__header .bi {
  font-size: 1.25rem;
  opacity: 0.9;
}

.panel-card__body {
  padding: 1.35rem 1.35rem 1.5rem;
}

.panel-card .form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--brand-deep);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.panel-card .form-control,
.panel-card .form-select {
  border-radius: 10px;
  border-color: var(--border);
  padding: 0.6rem 0.85rem;
}

.panel-card .form-control:focus,
.panel-card .form-select:focus {
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(42, 111, 148, 0.15);
}

/* —— Tips —— */
.tips-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.tip-card {
  display: flex;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.tip-card__icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.tip-card--faith .tip-card__icon {
  background: var(--accent-soft);
  color: #8a6d12;
}

.tip-card--link .tip-card__icon {
  background: rgba(30, 77, 107, 0.1);
  color: var(--brand);
}

.tip-card--reverend .tip-card__icon {
  background: rgba(37, 211, 102, 0.12);
  color: #128c7e;
}

.tip-card__title {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--brand-deep);
  margin-bottom: 0.25rem;
}

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

.tip-card code {
  font-size: 0.78rem;
  background: var(--surface-muted);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

/* —— Menu option editor —— */
.menu-option-card {
  position: relative;
  background: linear-gradient(180deg, #faf9f7 0%, #fff 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.25rem 1.25rem 4.5rem;
  margin-bottom: 1rem;
  transition: border-color 0.2s, transform 0.2s;
}

.menu-option-card:hover {
  border-color: rgba(30, 77, 107, 0.25);
}

.menu-option-card--nested {
  margin-left: 0.25rem;
  padding-left: 4rem;
  background: #fff;
  border-left: 3px solid var(--accent);
}

.submenu-box {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.submenu-children {
  margin-top: 0.5rem;
}

.menu-option-card__badge {
  position: absolute;
  left: 1rem;
  top: 1.25rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-deep) 100%);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(15, 45, 66, 0.2);
}

.menu-option-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.menu-option-card__head-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.menu-option-card__drag {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text-muted);
  cursor: grab;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.menu-option-card__drag:hover {
  border-color: var(--accent);
  color: var(--brand);
  background: rgba(30, 77, 107, 0.04);
}

.menu-option-card__drag:active {
  cursor: grabbing;
}

.menu-option-card--dragging {
  opacity: 0.55;
  transform: scale(0.99);
}

.menu-option-card--collapsed {
  padding-bottom: 1rem;
}

.menu-option-card--collapsed .menu-option-card__body {
  display: none;
}

.menu-option-card--collapsed .menu-option-card__head {
  margin-bottom: 0;
}

.menu-option-card--drop-target {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px rgba(196, 120, 74, 0.25);
}

.menu-option-card__collapse {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.menu-option-card__collapse:hover {
  border-color: var(--brand);
  background: rgba(30, 77, 107, 0.06);
}

.menu-option-card__head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.menu-option-card__summary {
  font-weight: 500;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.menu-option-card__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--brand-deep);
  margin: 0;
}

.menu-option-card__remove {
  border-radius: 8px;
  font-size: 0.8rem;
}

.menu-option-card .form-section {
  padding-top: 0.75rem;
  margin-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.menu-option-card .form-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.65rem;
}

/* —— Buttons —— */
.btn-brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  border: none;
  color: #fff;
  font-weight: 600;
  padding: 0.65rem 1.5rem;
  border-radius: 10px;
  box-shadow: 0 4px 14px rgba(15, 45, 66, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}

.btn-brand:hover {
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15, 45, 66, 0.3);
}

.btn-accent-outline {
  border: 2px solid var(--accent);
  color: #8a6d12;
  font-weight: 600;
  border-radius: 10px;
  background: transparent;
}

.btn-accent-outline:hover {
  background: var(--accent-soft);
  color: #6b5410;
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 0.5rem;
}

/* —— Alerts —— */
.alert-elegant {
  border: none;
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  box-shadow: var(--shadow-sm);
}

.alert-elegant.alert-success {
  background: linear-gradient(90deg, rgba(37, 211, 102, 0.12) 0%, rgba(37, 211, 102, 0.05) 100%);
  color: #0d5c36;
  border-left: 4px solid var(--whatsapp);
}

/* —— Login —— */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.login-card__top {
  text-align: center;
  padding: 2rem 2rem 1.25rem;
  background: linear-gradient(180deg, var(--surface-muted) 0%, var(--surface) 100%);
}

.login-card__logo {
  width: 100px;
  height: 100px;
  object-fit: contain;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 12px rgba(15, 45, 66, 0.1));
}

.login-card__title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--brand-deep);
  margin-bottom: 0.2rem;
}

.login-card__body {
  padding: 0 2rem 2rem;
}

.login-card .btn-brand {
  width: 100%;
  padding: 0.75rem;
}

/* —— Dashboard legacy + stats —— */
h2.page-title {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--brand-deep);
  font-size: 1.75rem;
}

.card {
  border-radius: var(--radius);
  border-color: var(--border);
}

.card-stat {
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-ready { background: #198754; }
.status-qr { background: #ffc107; }
.status-disconnected { background: #dc3545; }
.status-loading { background: var(--brand-light); animation: pulse 1s infinite; }

@keyframes pulse {
  50% { opacity: 0.4; }
}

.message-in { border-left: 3px solid var(--brand-light); }
.message-out { border-left: 3px solid var(--whatsapp); }

.table-messages td {
  vertical-align: middle;
  max-width: 320px;
  word-break: break-word;
}

/* QR WhatsApp — sin recortes */
.qr-panel {
  overflow: visible;
  padding: 0.5rem 0 1rem;
}

.qr-box {
  background: #fff;
  padding: 1.25rem;
  border-radius: var(--radius);
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
  border: 2px solid rgba(37, 211, 102, 0.35);
  overflow: visible;
}

.qr-box img,
#qrImage {
  display: block;
  width: auto;
  max-width: min(400px, calc(100vw - 3rem));
  height: auto;
  margin: 0 auto;
}

.card.border-success {
  overflow: visible;
}

.qr-fullscreen-body {
  background: #f0f2f5;
}

.qr-fullscreen-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

.qr-fullscreen-back {
  position: absolute;
  top: 1rem;
  left: 1rem;
  margin: 0;
}

.qr-fullscreen-title {
  font-family: var(--font-display);
  color: var(--brand-deep);
  margin-bottom: 0.5rem;
}

.qr-fullscreen-hint {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.qr-fullscreen-frame {
  background: #fff;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  line-height: 0;
}

.qr-fullscreen-frame img {
  display: block;
  width: min(400px, 85vw);
  height: auto;
  max-width: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 2rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.site-footer img {
  width: 28px;
  height: 28px;
  opacity: 0.7;
  margin-right: 0.35rem;
  vertical-align: middle;
}

/* Bootstrap overrides */
.card-header.bg-success {
  background: linear-gradient(90deg, #128c7e 0%, #25d366 100%) !important;
}

.navbar-toggler {
  border-color: rgba(255, 255, 255, 0.4);
}

.navbar-toggler-icon {
  filter: brightness(10);
}

@media (max-width: 576px) {
  .menu-option-card {
    padding-left: 1.25rem;
    padding-top: 3.5rem;
  }

  .menu-option-card__badge {
    left: 50%;
    transform: translateX(-50%);
    top: 0.85rem;
  }
}
