/* ==========================================================================
   ORBIFY LIFE — NOTAS & POST-ITS BENTO SYSTEM
   Grid dinâmico e flexível estilo Post-its (1x1, 2x1, 1x2, 2x2, 3x2)
   Cores pastéis personalizáveis, visual clean, sem sombras pesadas
   ========================================================================== */

.notes-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  min-height: calc(100vh - 60px);
  background: var(--bg-deep, #0a0b0e);
  color: var(--text-main, #f5f5f5);
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.notes-wrapper::-webkit-scrollbar {
  width: 5px;
}

.notes-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.notes-wrapper::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
}

.notes-wrapper::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

body.dashboard-theme-white .notes-wrapper {
  background: #f8fafc !important;
  color: #0f172a !important;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

body.dashboard-theme-white .notes-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   1. EMPTY STATE (CENTRAL "+" BUTTON)
   ========================================================================== */
.notes-empty-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  margin: auto;
}

.btn-create-note-central {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  background: rgba(165, 255, 143, 0.12);
  border: 1.5px solid rgba(165, 255, 143, 0.35);
  color: var(--color-life, #a5ff8f);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 28px rgba(165, 255, 143, 0.1);
  outline: none;
}

.btn-create-note-central:hover {
  background: var(--color-life, #a5ff8f);
  border-color: var(--color-life, #a5ff8f);
  color: #0a0b0e;
  transform: scale(1.1);
  box-shadow: 0 0 35px rgba(165, 255, 143, 0.35);
}

.btn-create-note-central:active {
  transform: scale(0.96);
}

.notes-empty-label {
  font-size: 0.92rem;
  font-weight: 400;
  color: var(--text-secondary, #94a3b8);
  margin-top: 1rem;
  letter-spacing: -0.01em;
  transition: color 0.2s ease;
}

body.dashboard-theme-white .btn-create-note-central {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.06);
}

body.dashboard-theme-white .btn-create-note-central:hover {
  background: #15803d;
  border-color: #15803d;
  color: #ffffff;
  box-shadow: 0 6px 24px rgba(21, 128, 61, 0.25);
}

body.dashboard-theme-white .notes-empty-label {
  color: #64748b;
}

/* ==========================================================================
   2. NOTAS HEADER TOOLBAR
   ========================================================================== */
.notes-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card, rgb(21 21 21 / 85%));
  border: 1px solid var(--border-subtle);
  border-radius: 18px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

body.dashboard-theme-white .notes-toolbar {
  background: rgb(252 252 252 / 93%);
  border-color: rgba(0, 0, 0, 0.06);
}

.notes-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.notes-toolbar-title {
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text-bright);
  margin: 0;
}

body.dashboard-theme-white .notes-toolbar-title {
  color: #0f172a;
}

.notes-count-pill {
  font-size: 0.72rem;
  font-weight: 400;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

body.dashboard-theme-white .notes-count-pill {
  background: #f1f5f9;
  color: #64748b;
}

/* Barra de Pesquisa Rápida de Notas */
.notes-search-box {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.35rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  min-width: 180px;
}

body.dashboard-theme-white .notes-search-box {
  background: #f1f5f9;
  border-color: #e2e8f0;
}

.notes-search-icon {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.notes-search-input {
  border: none;
  background: transparent;
  color: var(--text-bright);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.notes-search-input::placeholder {
  color: var(--text-muted);
}

body.dashboard-theme-white .notes-search-input {
  color: #0f172a;
}

.notes-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.btn-new-note {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 400;
  background: rgba(165, 255, 143, 0.16);
  border: 1px solid rgba(165, 255, 143, 0.35);
  color: var(--color-life, #a5ff8f);
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
}

.btn-new-note:hover {
  background: rgba(165, 255, 143, 0.25);
  border-color: var(--color-life, #a5ff8f);
}

body.dashboard-theme-white .btn-new-note {
  background: #15803d;
  color: #ffffff;
  border-color: #15803d;
}

body.dashboard-theme-white .btn-new-note:hover {
  background: #166534;
}

/* ==========================================================================
   3. BENTO POST-IT GRID (1x1, 2x1, 1x2, 2x2, 3x2)
   ========================================================================== */
.notes-bento-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: 260px;
  grid-auto-flow: dense;
  gap: 1.15rem;
  align-items: stretch;
}

/* Base Card do Post-it */
.note-card {
  border-radius: 18px;
  padding: 1.2rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.7rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
}

.note-card:hover {
  transform: translateY(-2px);
}

/* Spans de Tamanho Flexíveis (1x1, 2x1, 1x2, 2x2, 3x1, 3x2, etc.) */
.note-card.size-1x1 { grid-column: span 1; grid-row: span 1; }
.note-card.size-2x1 { grid-column: span 2; grid-row: span 1; }
.note-card.size-1x2 { grid-column: span 1; grid-row: span 2; }
.note-card.size-2x2 { grid-column: span 2; grid-row: span 2; }
.note-card.size-3x1 { grid-column: span 3; grid-row: span 1; }
.note-card.size-3x2 { grid-column: span 3; grid-row: span 2; }
.note-card.size-3x3 { grid-column: span 3; grid-row: span 3; }
.note-card.size-4x2 { grid-column: span 4; grid-row: span 2; }
.note-card.size-4x3 { grid-column: span 4; grid-row: span 3; }

/* ==========================================================================
   4. TEMAS DE CORES DOS POST-ITS (DARK & WHITE)
   ========================================================================== */

/* 1. Amarelo Pastel Post-it Clássico */
.note-card.color-amarelo {
  background: rgba(250, 204, 21, 0.08);
  border-color: rgba(250, 204, 21, 0.32);
}
.note-card.color-amarelo .note-card-title,
.note-card.color-amarelo .note-card-body {
  color: #fef08a;
}
body.dashboard-theme-white .note-card.color-amarelo {
  background: #fef9c3;
  border-color: #facc15;
}
body.dashboard-theme-white .note-card.color-amarelo .note-card-title,
body.dashboard-theme-white .note-card.color-amarelo .note-card-body {
  color: #713f12;
}

/* 2. Verde Menta / Life */
.note-card.color-verde {
  background: rgba(165, 255, 143, 0.08);
  border-color: rgba(165, 255, 143, 0.32);
}
.note-card.color-verde .note-card-title,
.note-card.color-verde .note-card-body {
  color: #bbf7d0;
}
body.dashboard-theme-white .note-card.color-verde {
  background: #dcfce7;
  border-color: #86efac;
}
body.dashboard-theme-white .note-card.color-verde .note-card-title,
body.dashboard-theme-white .note-card.color-verde .note-card-body {
  color: #14532d;
}

/* 3. Azul Céu */
.note-card.color-azul {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.32);
}
.note-card.color-azul .note-card-title,
.note-card.color-azul .note-card-body {
  color: #bae6fd;
}
body.dashboard-theme-white .note-card.color-azul {
  background: #e0f2fe;
  border-color: #7dd3fc;
}
body.dashboard-theme-white .note-card.color-azul .note-card-title,
body.dashboard-theme-white .note-card.color-azul .note-card-body {
  color: #075985;
}

/* 4. Roxo Lavanda */
.note-card.color-roxo {
  background: rgba(192, 132, 252, 0.08);
  border-color: rgba(192, 132, 252, 0.32);
}
.note-card.color-roxo .note-card-title,
.note-card.color-roxo .note-card-body {
  color: #e9d5ff;
}
body.dashboard-theme-white .note-card.color-roxo {
  background: #f3e8ff;
  border-color: #d8b4fe;
}
body.dashboard-theme-white .note-card.color-roxo .note-card-title,
body.dashboard-theme-white .note-card.color-roxo .note-card-body {
  color: #581c87;
}

/* 5. Rosa Coral */
.note-card.color-rosa {
  background: rgba(244, 114, 182, 0.08);
  border-color: rgba(244, 114, 182, 0.32);
}
.note-card.color-rosa .note-card-title,
.note-card.color-rosa .note-card-body {
  color: #fbcfe8;
}
body.dashboard-theme-white .note-card.color-rosa {
  background: #fce7f3;
  border-color: #f472b6;
}
body.dashboard-theme-white .note-card.color-rosa .note-card-title,
body.dashboard-theme-white .note-card.color-rosa .note-card-body {
  color: #831843;
}

/* 6. Laranja Pêssego */
.note-card.color-laranja {
  background: rgba(251, 146, 60, 0.08);
  border-color: rgba(251, 146, 60, 0.32);
}
.note-card.color-laranja .note-card-title,
.note-card.color-laranja .note-card-body {
  color: #fed7aa;
}
body.dashboard-theme-white .note-card.color-laranja {
  background: #ffedd5;
  border-color: #fdba74;
}
body.dashboard-theme-white .note-card.color-laranja .note-card-title,
body.dashboard-theme-white .note-card.color-laranja .note-card-body {
  color: #7c2d12;
}

/* 7. Grafite / Neutro Dark */
.note-card.color-grafite {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--border-subtle);
}
.note-card.color-grafite .note-card-title,
.note-card.color-grafite .note-card-body {
  color: #f1f5f9;
}
body.dashboard-theme-white .note-card.color-grafite {
  background: #ffffff;
  border-color: #e2e8f0;
}
body.dashboard-theme-white .note-card.color-grafite .note-card-title,
body.dashboard-theme-white .note-card.color-grafite .note-card-body {
  color: #1e293b;
}

/* ==========================================================================
   5. CONTEÚDO DO POST-IT (CABEÇALHO, TEXTO E RODAPÉ)
   ========================================================================== */

/* Top row: Pin indicator, Title input, Action buttons */
.note-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.note-card-title-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.note-card-title {
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  font-family: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-card-title::placeholder {
  opacity: 0.45;
}

/* Action Icons */
.note-card-actions {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

.btn-note-action {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
  font-size: 0.75rem;
}

.btn-note-action:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.12);
}

body.dashboard-theme-white .btn-note-action:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-note-action.btn-note-pin i {
  transition: transform 0.15s ease, color 0.15s ease;
  transform: rotate(45deg);
}

.btn-note-action.btn-note-pin.pinned {
  opacity: 1;
  color: #facc15 !important;
}

.btn-note-action.btn-note-pin.pinned i {
  transform: rotate(0deg);
}

.btn-note-action.delete:hover {
  color: #ef4444 !important;
}

/* Text Body Area */
.note-card-body-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.note-card-body {
  flex: 1;
  width: 100%;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.5;
  box-sizing: border-box;
  padding: 0;
  padding-right: 0.35rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) transparent;
}

.note-card-body::-webkit-scrollbar {
  width: 4px;
}

.note-card-body::-webkit-scrollbar-track {
  background: transparent;
}

.note-card-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  transition: background 0.15s ease;
}

.note-card-body::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.45);
}

body.dashboard-theme-white .note-card-body {
  scrollbar-color: rgba(0, 0, 0, 0.22) transparent;
}

body.dashboard-theme-white .note-card-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
}

body.dashboard-theme-white .note-card-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.38);
}

.note-card-body::placeholder {
  opacity: 0.45;
}

/* Rodapé do Post-it: Data de edição e alça de redimensionar */
.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.7rem;
  opacity: 0.8;
  padding-right: 1.25rem; /* Espaço para alça no canto */
}

body.dashboard-theme-white .note-card-footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

.note-date-text {
  font-size: 0.68rem;
  opacity: 0.7;
  white-space: nowrap;
}

/* ==========================================================================
   ALÇA DE ARRASTAR PARA REDIMENSIONAR (DRAG TO RESIZE)
   ========================================================================== */
body.is-resizing-notes {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: se-resize !important;
}

.note-card.is-resizing {
  user-select: none !important;
  -webkit-user-select: none !important;
  z-index: 30 !important;
  transition: none !important;
  box-shadow: 0 0 0 2px var(--color-life, #a5ff8f), 0 14px 34px rgba(0, 0, 0, 0.45) !important;
}

.note-card.is-resizing * {
  pointer-events: none !important;
}

body.dashboard-theme-white .note-card.is-resizing {
  box-shadow: 0 0 0 2px #15803d, 0 14px 34px rgba(0, 0, 0, 0.12) !important;
}

/* Alça discreta no canto inferior direito */
.note-resize-handle {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  cursor: se-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.35;
  border-radius: 6px;
  color: inherit;
  transition: opacity 0.15s ease, background 0.15s ease, transform 0.15s ease;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  z-index: 10;
}

.note-card:hover .note-resize-handle {
  opacity: 0.85;
}

.note-resize-handle:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.15);
}

body.dashboard-theme-white .note-resize-handle:hover {
  background: rgba(0, 0, 0, 0.08);
}

/* Badge flutuante dinâmico exibindo proporção durante o arrasto */
.note-resize-badge {
  position: absolute;
  bottom: 12px;
  right: 32px;
  padding: 0.22rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  border-radius: 8px;
  background: rgba(10, 11, 14, 0.92);
  color: var(--color-life, #a5ff8f);
  border: 1px solid rgba(165, 255, 143, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  pointer-events: none;
  animation: badgePop 0.12s ease-out;
  z-index: 40;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

body.dashboard-theme-white .note-resize-badge {
  background: rgba(255, 255, 255, 0.96);
  color: #15803d;
  border-color: rgba(21, 128, 61, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

@keyframes badgePop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Menu Suspenso de Cores (Color Picker Popover) */
.note-color-picker-popover {
  position: absolute;
  top: 40px;
  right: 12px;
  background: var(--bg-surface, #121318);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  z-index: 50;
  animation: popoverFadeIn 0.15s ease;
}

body.dashboard-theme-white .note-color-picker-popover {
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

@keyframes popoverFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.popover-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.popover-color-dot:hover {
  transform: scale(1.2);
}

.popover-color-dot.selected {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4);
}

body.dashboard-theme-white .popover-color-dot.selected {
  border-color: #0f172a;
}

/* ==========================================================================
   6. RESPONSIVIDADE (MOBILE & TELAS INTERMEDIÁRIAS / Z FOLD)
   ========================================================================== */

/* Telas dobráveis (Z Fold aberto: 581px a 1024px) e tablets: 2 COLUNAS DE NOTAS */
@media (min-width: 581px) and (max-width: 1024px) {
  .notes-wrapper {
    padding: 1rem 1.25rem;
  }

  .notes-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
  }

  .notes-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
  }

  .notes-search-box {
    max-width: 280px;
  }

  .notes-toolbar-right {
    width: auto;
  }

  .btn-new-note {
    width: auto;
  }

  /* Grid 2 Colunas */
  .notes-bento-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    grid-auto-rows: minmax(210px, auto) !important;
    gap: 0.95rem !important;
  }

  .note-card {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
    min-height: 210px !important;
  }

  /* Oculta alça de redimensionamento livre para manter grade simétrica de 2 colunas */
  .note-resize-handle {
    display: none !important;
    pointer-events: none !important;
  }

  .note-resize-badge {
    display: none !important;
  }
}

/* Celulares compactos (<= 580px): 1 Coluna */
@media (max-width: 580px) {
  .notes-wrapper {
    padding: 0.85rem 1rem;
  }

  .notes-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .notes-toolbar-left {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 0.5rem;
  }

  .notes-search-box {
    flex: 1;
    min-width: 0;
  }

  .notes-toolbar-right {
    width: 100%;
  }

  .btn-new-note {
    width: 100%;
    justify-content: center;
  }

  /* Grid Mobile: 1 Coluna */
  .notes-bento-grid {
    grid-template-columns: 1fr !important;
    grid-auto-rows: minmax(180px, auto) !important;
    gap: 0.85rem !important;
  }

  .note-card {
    grid-column: span 1 !important;
    grid-row: span 1 !important;
    min-height: 180px !important;
  }

  .note-resize-handle {
    display: none !important;
    pointer-events: none !important;
  }

  .note-resize-badge {
    display: none !important;
  }

  .note-card-footer {
    padding-right: 0 !important;
  }
}
