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

:root {
  --bg: #FAF1EC;
  --accent: #9C2F4E;
  --text: #2E211F;
  --card: #F0DAD2;
  --card-radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', sans-serif;
  font-weight: 400;
  min-height: 100vh;
}

h1, h2, h3, .brand {
  font-family: 'Playfair Display', serif;
  font-weight: 600;
  margin: 0;
}

button, input, select, textarea {
  font-family: 'Poppins', sans-serif;
  font-size: 16px;
}

/* Login */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, var(--card) 0%, var(--bg) 60%);
}

.login-card {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 24px;
  padding: 40px 32px;
  box-shadow: 0 12px 40px rgba(46, 33, 31, 0.10);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.login-card img { width: 220px; margin-bottom: 4px; }

.login-subtitle {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.8;
  margin-bottom: 22px;
}

#login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form input {
  background: var(--bg);
  border: 1px solid transparent;
}

#login-form input:focus {
  outline: none;
  border-color: var(--accent);
}

#login-form button.primary {
  margin-top: 6px;
  padding: 13px 20px;
}

/* App shell */
#app {
  display: none;
  flex-direction: column;
  min-height: 100vh;
}

header.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-rows: auto;
  align-items: center;
  padding: 16px 24px;
  background: var(--bg);
}

header.topbar .brand-icon {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  height: 96px;
}

header.topbar .desktop-nav { grid-column: 2; grid-row: 1; justify-self: center; }

header.topbar #logout-btn { grid-column: 3; grid-row: 1; justify-self: end; margin-right: 4px; }

.desktop-nav { display: none; }

main {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

nav.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: #fff;
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(46, 33, 31, 0.05);
  z-index: 4;
}

nav.tabbar button[data-view] {
  flex: 1;
  background: none;
  border: none;
  padding: 8px;
  color: var(--text);
  opacity: 0.55;
  font-size: 13px;
  border-radius: 12px;
}

nav.tabbar button[data-view].active {
  opacity: 1;
  color: var(--accent);
  font-weight: 600;
}

input, select, textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: none;
  background: #fff;
  box-shadow: 0 1px 4px rgba(46, 33, 31, 0.06);
  color: var(--text);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent);
}

.currency-input {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(46, 33, 31, 0.06);
  padding: 0 14px;
}

.currency-input span {
  color: var(--accent);
  font-weight: 500;
  padding-right: 6px;
}

.currency-input input {
  box-shadow: none;
  padding-left: 0;
}

.currency-input:focus-within {
  box-shadow: 0 0 0 2px var(--accent);
}

@media (min-width: 900px) {
  header.topbar {
    padding: 14px 32px;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 4;
    box-shadow: 0 2px 12px rgba(46, 33, 31, 0.05);
  }

  header.topbar .brand-icon { height: 60px; }

  .desktop-nav {
    display: flex;
    gap: 8px;
  }

  .desktop-nav button[data-view] {
    background: none;
    border: none;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 15px;
    color: var(--text);
    opacity: 0.6;
    cursor: pointer;
  }

  .desktop-nav button[data-view].active {
    opacity: 1;
    color: var(--accent);
    font-weight: 600;
    background: var(--card);
  }

  nav.tabbar { display: none; }

  main {
    padding: 32px 40px;
    padding-bottom: 32px;
    max-width: 820px;
  }

  .fab { right: 40px; bottom: 40px; }
}

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
}

button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.card {
  background: var(--card);
  border-radius: var(--card-radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 10px rgba(46, 33, 31, 0.06);
}

.card .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #fff;
}

.tag.agendado { color: #9C6F2F; }
.tag.concluido { color: #2F7A45; }
.tag.cancelado { color: #A33; }
.tag.atrasado { color: #A33; font-weight: 600; }

.section-title {
  margin: 20px 0 10px;
  font-size: 18px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 28px;
  box-shadow: 0 4px 14px rgba(156, 47, 78, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease;
}

.fab:active {
  transform: scale(0.88);
}

.modal-backdrop {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(46, 33, 31, 0.35);
  align-items: flex-end;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.modal-backdrop.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease;
}

.modal {
  background: var(--bg);
  width: 100%;
  max-width: 480px;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transform: translateY(24px);
  opacity: 0;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease;
}

.modal-backdrop.open .modal {
  transform: translateY(0);
  opacity: 1;
}

.modal h3 { margin-bottom: 6px; }

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
}

.gallery-item {
  position: relative;
}

.gallery-download {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  background: rgba(46, 33, 31, 0.72);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 5px 0;
  font-size: 11px;
  cursor: pointer;
}

.gallery-apagar {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(46, 33, 31, 0.72);
  color: #fff;
  border: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.link-danger {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: #A33;
  font-size: 13px;
  padding: 10px 0 0;
  cursor: pointer;
  text-align: center;
}

.hint { font-size: 13px; opacity: 0.65; }
.error { color: #A33; font-size: 14px; }

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.summary-grid .card { margin-bottom: 0; text-align: center; }
.summary-grid .value { font-family: 'Playfair Display', serif; font-size: 26px; }
.summary-grid .label { font-size: 13px; opacity: 0.7; }

/* Prévia estilo Instagram */
.ig-post {
  background: #fff;
  border-radius: var(--card-radius);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: 0 4px 18px rgba(46, 33, 31, 0.08);
  max-width: 420px;
}

.ig-post-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
}

.ig-post-header .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ig-post-header .avatar svg { width: 14px; height: 14px; }

.ig-post-header strong { font-size: 14px; font-family: 'Poppins', sans-serif; font-weight: 600; }
.ig-post-header .hint { margin-left: auto; }

.ig-post-media {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.ig-post-media::-webkit-scrollbar { display: none; }

.ig-post-media .slide {
  flex: 0 0 100%;
  scroll-snap-align: center;
  aspect-ratio: 4 / 5;
  position: relative;
}

.ig-post-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ig-post-media-wrap {
  position: relative;
}

.ig-post-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(46, 33, 31, 0.55);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ig-post-arrow.prev { left: 10px; }
.ig-post-arrow.next { right: 10px; }

.ig-post-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 10px 0 2px;
}

.ig-post-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card);
  cursor: pointer;
}

.ig-post-dots span.active { background: var(--accent); }

.ig-post-caption {
  width: 100%;
  border: none;
  box-shadow: none;
  resize: vertical;
  min-height: 90px;
  padding: 4px 14px 12px;
  font-size: 14px;
  line-height: 1.55;
  background: transparent;
  overflow: hidden;
}

.ig-post-actions {
  display: flex;
  gap: 10px;
  padding: 4px 14px 14px;
}

#posts-gerados-list {
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) {
  #posts-gerados-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    align-items: start;
  }

  .ig-post { max-width: none; margin-bottom: 0; }
}
