/* ============================================
   Design System - dearjuc dashboard
   Inspirado em dearjuc-site
   ============================================ */

/* --- Tokens --- */
:root {
  --ink:          #2d2d2d;
  --cream:        #fffdf8;
  --parchment:    #fff8ea;
  --sand:         #d9d1c4;

  --mint:         #d4f0e0;
  --mint-soft:    #dcebd8;
  --mint-strong:  #8fcfac;

  --blush:        #fde8e8;
  --blush-soft:   #f3dddd;
  --blush-strong: #e8a0a0;

  --honey:        #fde8c0;
  --honey-soft:   #fef3d8;
  --honey-strong: #e8c070;
  --honey-border: #e8c86a;
  --honey-text:   #7a5e1a;

  --lavender:     #e4d5f5;
  --lavender-strong: #b890e0;

  --periwinkle:      #dce7f6;
  --periwinkle-strong: #8ab4e8;

  --shadow-sm: 2px 2px 0 var(--ink);
  --shadow-md: 4px 4px 0 var(--ink);

  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 220px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Montserrat', sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   Layout
   ============================================ */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--parchment);
  border-right: 1.5px solid var(--ink);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1.5px dashed var(--sand);
  display: flex;
  flex-direction: column;
}

.brand-label {
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
  color: var(--ink);
  line-height: 1;
}

.brand-sub {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--honey-text);
  margin-top: 2px;
}

.sidebar-nav {
  padding: 20px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  text-decoration: none;
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, transform 0.1s;
}

.nav-item:hover {
  background: var(--honey-soft);
  border-color: var(--honey-border);
  transform: translateX(2px);
}

.nav-item.active {
  background: var(--honey);
  border-color: var(--honey-border);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px 0;
  border-top: 1.5px dashed var(--sand);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  background: transparent;
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--sand);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  text-align: left;
}

.btn-logout:hover {
  background: var(--blush-soft);
  color: #7a2020;
  border-color: var(--blush-strong);
}

/* ============================================
   Main content
   ============================================ */
.main-content {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

/* ============================================
   Page header
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-family: 'Patrick Hand', cursive;
  font-size: 32px;
  line-height: 1;
}

.page-subtitle {
  font-size: 13px;
  color: var(--honey-text);
  margin-top: 4px;
  font-weight: 500;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--ink);
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  text-decoration: none;
}

.btn:active { transform: translate(2px, 2px); box-shadow: none !important; }

.btn-primary {
  background: var(--honey);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--honey-strong);
  box-shadow: var(--shadow-md);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
}

.btn-ghost:hover { background: var(--sand); opacity: 0.6; }

/* ============================================
   Alerts
   ============================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid;
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-error {
  background: var(--blush-soft);
  border-color: var(--blush-strong);
  color: #7a2020;
}

.alert-success {
  background: var(--mint-soft);
  border-color: var(--mint-strong);
  color: #1a5e32;
}

/* ============================================
   Empty state
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 12px;
}

.empty-icon {
  font-size: 36px;
  color: var(--sand);
}

.empty-text {
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  color: var(--sand);
  text-align: center;
  line-height: 1.6;
}

/* ============================================
   Subs Grid
   ============================================ */
.subs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.sub-card { position: relative; }

.sub-card {
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.sub-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-md);
}

.sub-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.sub-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
  object-fit: cover;
  display: block;
}

.platform-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: var(--ink);
  color: var(--cream);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}

.platform-tiktok { background: var(--ink); }

.sub-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sub-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-id {
  font-size: 12px;
  color: var(--honey-text);
  font-family: 'Nunito', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  line-height: 1.4;
  width: fit-content;
}

.type-tk_superfan { background: var(--honey);     color: var(--honey-text); }
.type-tk_inscrito { background: var(--periwinkle); color: #2a4a7a; }
.type-yt_membro   { background: var(--blush);      color: #7a2020; }

.sub-date {
  font-size: 11px;
  color: var(--sand);
  font-family: 'Nunito', sans-serif;
  margin-top: 2px;
  white-space: nowrap;
}

/* ============================================
   Status Toggle & Mod Toggle
   ============================================ */
.sub-actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.btn-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--sand);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s, background 0.15s, border-color 0.15s;
}

.sub-card:hover .btn-delete {
  opacity: 1;
}

.btn-delete:hover {
  color: #7a2020;
  background: var(--blush-soft);
  border-color: var(--blush-strong);
}

.btn-danger {
  background: var(--blush);
  color: #7a2020;
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn-danger:hover {
  background: var(--blush-strong);
  box-shadow: var(--shadow-md);
}

.modal-sm { max-width: 360px; }

.status-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--ink);
  background: var(--blush);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  transition: background 0.2s, box-shadow 0.1s, transform 0.1s;
  box-shadow: var(--shadow-sm);
}

.status-toggle.active {
  background: var(--mint);
}

.status-toggle:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-md);
}

.status-toggle:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.toggle-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blush-strong);
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
  transition: background 0.2s;
}

.status-toggle.active .toggle-dot {
  background: var(--mint-strong);
}

.toggle-label { line-height: 1; }

.mod-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--sand);
  background: var(--cream);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  color: var(--sand);
  transition: background 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.1s, transform 0.1s;
  box-shadow: none;
}

.mod-toggle.is-mod {
  background: var(--lavender);
  color: var(--ink);
  border-color: var(--lavender-strong);
  box-shadow: var(--shadow-sm);
}

.mod-toggle:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-sm);
}

.mod-toggle:active {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.mod-label { line-height: 1; }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 45, 45, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  transform: translateY(8px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-title {
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--ink);
  opacity: 0.5;
  padding: 4px 8px;
  border-radius: 6px;
  transition: opacity 0.15s, background 0.15s;
}

.modal-close:hover { opacity: 1; background: var(--sand); }

.modal-desc {
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  color: var(--honey-text);
  margin-bottom: 20px;
  line-height: 1.5;
}

.modal-form { display: flex; flex-direction: column; gap: 20px; }

.field-group { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.field-with-prefix {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: white;
}

.field-prefix {
  padding: 0 10px;
  font-size: 15px;
  font-weight: 700;
  border-right: 1.5px solid var(--ink);
  background: var(--honey-soft);
  color: var(--honey-text);
  height: 40px;
  display: flex;
  align-items: center;
}

.field-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  background: transparent;
  color: var(--ink);
}

.field-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  background: white;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232d2d2d' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.field-select:focus {
  outline: none;
  border-color: var(--honey-border);
  box-shadow: var(--shadow-md);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ============================================
   Toast
   ============================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  padding: 12px 18px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.25s ease;
  max-width: 320px;
}

.toast-success { background: var(--mint); }
.toast-error   { background: var(--blush); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================
   Loading state
   ============================================ */
.sub-card.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--sand); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink); }

/* ============================================
   Mods list
   ============================================ */
.mods-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 560px;
}

.mod-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--cream);
  border: 1.5px solid var(--ink);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  gap: 12px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.mod-row:hover {
  transform: translate(-1px, -1px);
  box-shadow: var(--shadow-md);
}

.mod-row-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mod-row-icon { color: var(--lavender-strong); flex-shrink: 0; }

.mod-row-username {
  font-size: 14px;
  font-weight: 600;
}

.mod-row-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.mod-row-date {
  font-size: 11px;
  color: var(--sand);
  font-family: 'Nunito', sans-serif;
  white-space: nowrap;
}

.btn-mod-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  color: var(--sand);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.btn-mod-delete:hover {
  color: #7a2020;
  background: var(--blush-soft);
  border-color: var(--blush-strong);
}

.mod-row.loading {
  opacity: 0.5;
  pointer-events: none;
}

/* ============================================
   Topbar (mobile only — hidden no desktop)
   ============================================ */
.topbar { display: none; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(45, 45, 45, 0.4);
  z-index: 70;
  opacity: 0;
  transition: opacity 0.25s;
}

.sidebar-overlay.open { display: block; opacity: 1; }

/* ============================================
   Responsivo — Tablet (≤ 900px)
   ============================================ */
@media (max-width: 900px) {
  .subs-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

/* ============================================
   Responsivo — Mobile (≤ 768px)
   ============================================ */
@media (max-width: 768px) {

  /* Topbar */
  .topbar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--parchment);
    border-bottom: 1.5px solid var(--ink);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 60;
  }

  .topbar .topbar-brand {
    display: flex;
    flex-direction: column;
  }

  /* Hamburger */
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 36px;
    height: 36px;
    background: none;
    border: 1.5px solid var(--ink);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0 8px;
  }

  .hamburger span {
    display: block;
    height: 1.5px;
    background: var(--ink);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
  }

  .hamburger.open span:nth-child(1) { transform: translateY(6.5px) rotate(45deg); }
  .hamburger.open span:nth-child(2) { opacity: 0; }
  .hamburger.open span:nth-child(3) { transform: translateY(-6.5px) rotate(-45deg); }

  /* Sidebar vira drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 80;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    min-height: 100dvh;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(45,45,45,0.15);
  }

  /* Layout */
  .app-wrapper { flex-direction: column; }

  .main-content {
    padding: 76px 16px 32px;
    width: 100%;
  }

  /* Grid vira 1 coluna */
  .subs-grid {
    grid-template-columns: 1fr;
  }

  /* Sempre mostrar o botão de excluir (sem hover em touch) */
  .btn-delete { opacity: 0.4; }
  .sub-card:hover .btn-delete,
  .sub-card:focus-within .btn-delete { opacity: 1; }

  /* Modal vira bottom sheet */
  .modal-overlay { align-items: flex-end; padding: 0; }

  .modal {
    max-width: 100%;
    border-radius: var(--radius) var(--radius) 0 0;
    transform: translateY(100%);
    padding: 24px 20px 32px;
  }

  .modal-overlay.open .modal { transform: translateY(0); }

  /* Toast ocupa largura toda */
  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast { max-width: 100%; }
}

/* ============================================
   Responsivo — Pequeno (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
  .page-header { flex-direction: column; gap: 10px; }

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

  .sub-card { padding: 12px; gap: 10px; }

  .sub-avatar { width: 44px; height: 44px; }

  .status-toggle { padding: 5px 8px; font-size: 11px; }
}
