/* =========================================================================
   Guidelyze · Calendário Editorial v2
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body, 'DM Sans', sans-serif); background: var(--paper, #FAF6EC); color: var(--ink, #1C1C1A); min-height: 100vh; }

/* ---- Topbar ---- */
.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 24px; border-bottom: 1px solid var(--sand-soft, #E5D9C6); background: var(--paper, #FAF6EC); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo { height: 26px; }
.brand__eyebrow { font-size: 11px; color: var(--fg-soft, #888); text-transform: uppercase; letter-spacing: .04em; }
.brand__title { font-size: 16px; font-weight: 600; }
.back { margin-left: auto; font-size: 13px; color: var(--sage, #5C8F7A); text-decoration: none; white-space: nowrap; }
.back:hover { text-decoration: underline; }

/* ---- Nav de mês ---- */
.cal-nav { display: flex; align-items: center; gap: 12px; padding: 16px 24px 10px; }
.cal-nav__btn { background: none; border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 6px; width: 32px; height: 32px; font-size: 18px; cursor: pointer; color: var(--ink, #1C1C1A); display: flex; align-items: center; justify-content: center; }
.cal-nav__btn:hover { background: var(--paper-warm, #F5EDD8); }
.cal-nav__title { font-family: var(--font-display, 'Fraunces', serif); font-size: 22px; font-weight: 500; min-width: 220px; letter-spacing: -.01em; }
.cal-nav__count { font-size: 12px; color: var(--fg-soft, #888); background: var(--paper-warm, #F5EDD8); padding: 3px 10px; border-radius: 20px; }
.cal-nav__toggle { margin-left: 8px; padding: 6px 14px; border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 20px; background: none; font-size: 12px; cursor: pointer; color: var(--fg-soft, #888); }
.cal-nav__toggle:hover { background: var(--paper-warm, #F5EDD8); }
.cal-nav__toggle.is-active { background: var(--ink, #1C1C1A); color: #fff; border-color: var(--ink, #1C1C1A); }

/* ---- Grid wrap ---- */
.cal-grid-wrap { padding: 0 16px 8px; }

/* ---- Cabeçalhos dos dias ---- */
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-bottom: 3px; }
.cal-weekdays span { text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 6px 4px; border-radius: 4px; color: var(--ink, #1C1C1A); }

/* Cores dos cabeçalhos quando colorido */
[data-colored="true"] .cal-weekdays span[data-day-color="teal"]   { background: #00BCD4; color: #fff; }
[data-colored="true"] .cal-weekdays span[data-day-color="green"]  { background: #66BB6A; color: #fff; }
[data-colored="true"] .cal-weekdays span[data-day-color="yellow"] { background: #FFD600; color: #333; }

/* ---- Grid de células ---- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }

.cal-cell { min-height: 120px; border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 6px; padding: 4px; background: var(--paper, #FAF6EC); display: flex; flex-direction: column; gap: 3px; position: relative; }
.cal-cell--outside { background: rgba(0,0,0,.02); border-color: rgba(0,0,0,.06); }
.cal-cell--today { border: 2px solid var(--sage, #5C8F7A); }

/* Cores das células quando colorido */
[data-colored="true"] .cal-cell:not(.cal-cell--outside)[data-day-color="teal"]   { background: rgba(0,188,212,.08); border-color: rgba(0,188,212,.25); }
[data-colored="true"] .cal-cell:not(.cal-cell--outside)[data-day-color="green"]  { background: rgba(102,187,106,.08); border-color: rgba(102,187,106,.25); }
[data-colored="true"] .cal-cell:not(.cal-cell--outside)[data-day-color="yellow"] { background: rgba(255,214,0,.1); border-color: rgba(255,214,0,.3); }

.cal-cell__num { font-size: 11px; font-weight: 700; color: var(--fg-soft, #888); line-height: 1; padding: 2px 0; }
.cal-cell--today .cal-cell__num { color: var(--sage, #5C8F7A); }
.cal-cell__num--outside { color: #CCC; }

/* ---- Post thumbnail no grid ---- */
.cal-post { position: relative; border-radius: 4px; overflow: hidden; background: var(--paper-warm, #F5EDD8); cursor: pointer; flex-shrink: 0; }

/* Aspect-ratio respeitado */
.cal-post[data-aspect="1:1"]  { aspect-ratio: 1/1; }
.cal-post[data-aspect="9/16"], .cal-post[data-aspect="9:16"] { aspect-ratio: 9/16; max-height: 80px; }
.cal-post[data-aspect="4/5"], .cal-post[data-aspect="4:5"]   { aspect-ratio: 4/5; }
.cal-post[data-aspect="4/3"], .cal-post[data-aspect="4:3"]   { aspect-ratio: 4/3; }
.cal-post[data-aspect="3/4"], .cal-post[data-aspect="3:4"]   { aspect-ratio: 3/4; }

.cal-post__img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .2s; }
.cal-post:hover .cal-post__img { opacity: .9; }
.cal-post__text { font-size: 9px; color: var(--fg-soft, #888); padding: 4px 5px; line-height: 1.3; display: block; }

.cal-post__rm { position: absolute; top: 3px; right: 3px; background: rgba(0,0,0,.6); color: #fff; border: none; border-radius: 3px; width: 16px; height: 16px; font-size: 11px; cursor: pointer; display: none; align-items: center; justify-content: center; line-height: 1; z-index: 2; }
.cal-post:hover .cal-post__rm { display: flex; }

/* ---- Drag-and-drop ---- */
.cal-post { cursor: grab; }
.cal-post.is-dragging { opacity: .35; cursor: grabbing; }
.cal-post.drag-over { outline: 2px dashed var(--sage, #5C8F7A); outline-offset: 1px; }
.cal-cell.drag-over { outline: 2px dashed var(--sage, #5C8F7A); outline-offset: -2px; background: rgba(92,143,122,.07) !important; }

/* ---- Barra de stats ---- */
.cal-stats-bar { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--sand-soft, #E5D9C6); }
.cal-stat { padding: 5px 14px; border-radius: 4px; font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.cal-stat--total  { background: #1C1C1A; color: #fff; }
.cal-stat--org    { background: #66BB6A; color: #fff; }
.cal-stat--ads    { background: #00BCD4; color: #fff; }

/* ---- Preview modal ---- */
.pv-overlay[hidden] { display: none !important; } /* garante que [hidden] vence o display:flex */
.pv-overlay { position: fixed; inset: 0; background: rgba(28,28,26,.7); z-index: 999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.pv-modal { background: var(--paper, #FAF6EC); border-radius: 16px; max-width: 900px; width: 100%; max-height: 90vh; overflow: hidden; position: relative; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.pv-close { position: absolute; top: 14px; right: 14px; background: none; border: none; font-size: 24px; cursor: pointer; color: var(--fg-soft, #888); z-index: 2; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; }
.pv-close:hover { background: var(--paper-warm, #F5EDD8); }

.pv-layout { display: flex; gap: 0; height: 90vh; max-height: 90vh; }

/* Coluna visual — fica fixa enquanto o lado direito scrolla */
.pv-visual { flex: 0 0 55%; background: #111; border-radius: 16px 0 0 16px; display: flex; align-items: flex-start; justify-content: center; overflow: hidden; }
.pv-frame { width: 100%; display: flex; align-items: flex-start; justify-content: center; }
.pv-img { width: 100%; height: auto; display: block; }
.pv-img[data-aspect="9/16"], .pv-img[data-aspect="9:16"] { max-height: 90vh; width: auto; max-width: 100%; }
.pv-noimg { color: #666; font-size: 14px; margin-top: 40px; }

/* Coluna info — scrolla de forma independente */
.pv-info { flex: 1; padding: 24px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; }
.pv-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pv-plat { font-size: 11px; background: var(--paper-warm, #F5EDD8); border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 20px; padding: 3px 10px; color: var(--fg-soft, #888); }
.pv-date { font-size: 11px; background: var(--paper-warm, #F5EDD8); border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 20px; padding: 3px 10px; color: var(--fg-soft, #888); }

/* Instagram post mockup */
.pv-ig-post { background: #fff; border: 1px solid #DBDBDB; border-radius: 4px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; flex-shrink: 0; }
.pv-ig-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid #EFEFEF; }
.pv-ig-avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); flex-shrink: 0; }
.pv-ig-name { font-size: 13px; font-weight: 600; color: #262626; }
.pv-ig-hook { font-size: 13px; color: #262626; line-height: 1.5; padding: 10px 12px 4px; font-weight: 600; }
.pv-ig-body { font-size: 13px; color: #262626; line-height: 1.5; padding: 0 12px 4px; }
.pv-ig-cta { font-size: 12px; color: #00376B; font-weight: 500; padding: 0 12px 12px; }

@media (max-width: 640px) {
  .pv-layout { flex-direction: column; height: auto; max-height: 90vh; overflow-y: auto; }
  .pv-visual { border-radius: 16px 16px 0 0; flex: none; min-height: 200px; overflow: visible; }
  .pv-info { overflow-y: visible; }
}

/* ---- Painel de configuração ---- */
.cal-cfg-panel { margin: 0 16px 12px; background: #fff; border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 10px; padding: 16px; }
.cal-cfg-header { display: flex; align-items: center; margin-bottom: 8px; }
.cal-cfg-header h3 { font-size: 14px; font-weight: 600; }
.cal-cfg-close { margin-left: auto; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--fg-soft, #888); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.cal-cfg-hint { font-size: 12px; color: var(--fg-soft, #888); margin-bottom: 14px; }
.cal-cfg-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.cal-cfg-row { display: flex; align-items: center; gap: 10px; }
.cal-cfg-day { font-weight: 700; font-size: 13px; min-width: 32px; }
.cal-cfg-swatches { display: flex; gap: 5px; }
.cal-cfg-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; outline: none; transition: transform .1s; }
.cal-cfg-swatch:hover { transform: scale(1.15); }
.cal-cfg-swatch.is-active { outline: 2px solid var(--ink, #1C1C1A); outline-offset: 2px; }
.cal-cfg-tag { flex: 1; border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 6px; padding: 5px 8px; font-size: 12px; font-family: var(--font-body, sans-serif); outline: none; max-width: 140px; }
.cal-cfg-tag:focus { border-color: var(--sage, #5C8F7A); }
.cal-cfg-actions { display: flex; gap: 8px; }
.cal-cfg-save { background: var(--sage, #5C8F7A); color: #fff; border: none; border-radius: 8px; padding: 7px 16px; font-size: 13px; font-weight: 600; cursor: pointer; }
.cal-cfg-reset { background: none; border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 8px; padding: 7px 14px; font-size: 12px; cursor: pointer; color: var(--fg-soft, #888); }
.cal-cfg-reset:hover { background: var(--paper-warm, #F5EDD8); }
.cal-day-tag { display: block; font-size: 9px; font-weight: 700; letter-spacing: .03em; opacity: .85; line-height: 1; margin-top: 1px; }

/* ---- Badge de tipo sobre thumbnail ---- */
.cal-post__type { position: absolute; bottom: 4px; left: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 8px; font-weight: 700; padding: 2px 5px; border-radius: 3px; letter-spacing: .03em; text-transform: uppercase; line-height: 1.2; z-index: 1; pointer-events: none; }

/* ---- Slider carrossel no preview ---- */
.pv-slider { position: relative; width: 100%; height: 100%; display: flex; align-items: center; }
.pv-slider__track { display: flex; width: 100%; overflow: hidden; }
.pv-slider__track img { width: 100%; height: auto; flex-shrink: 0; display: block; }
.pv-slider__btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.55); color: #fff; border: none; cursor: pointer; width: 34px; height: 34px; border-radius: 50%; font-size: 18px; display: flex; align-items: center; justify-content: center; z-index: 3; }
.pv-slider__btn--prev { left: 8px; }
.pv-slider__btn--next { right: 8px; }
.pv-slider__btn:hover { background: rgba(0,0,0,.8); }
.pv-slider__counter { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.5); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 10px; }

/* ---- Tag de tipo no modal de preview ---- */
.pv-type { font-size: 11px; border-radius: 20px; padding: 3px 10px; font-weight: 600; }
.pv-type--post      { background: rgba(92,143,122,.15); color: var(--sage, #5C8F7A); border: 1px solid rgba(92,143,122,.3); }
.pv-type--video     { background: rgba(255,112,67,.12);  color: #E64A19; border: 1px solid rgba(255,112,67,.3); }
.pv-type--carrossel { background: rgba(138,111,176,.12); color: #8A6FB0; border: 1px solid rgba(138,111,176,.3); }

/* ---- Horário editável no preview modal ---- */
.pv-time-row { display: flex; align-items: center; gap: 8px; }
.pv-time-label { font-size: 12px; color: var(--fg-soft, #888); white-space: nowrap; }
.pv-time-input {
  border: 1px solid var(--sand-soft, #E5D9C6); border-radius: 6px;
  padding: 5px 8px; font-size: 13px; background: var(--paper-warm, #F5EDD8);
  color: var(--ink, #1C1C1A); outline: none; cursor: pointer;
}
.pv-time-input:focus { border-color: var(--sage, #5C8F7A); }
.pv-time-saved { font-size: 11px; color: var(--sage, #5C8F7A); font-weight: 600; }
