/* --------------------------------------------------
   Mandar Post - Design System Tokens & Base
   Agência Xispeh - Versão 2.0
   -------------------------------------------------- */

:root {
  --bg-app: #0a0a0c;
  --bg-surface: #131317;
  --bg-surface-hover: #1b1b22;
  --bg-surface-active: #22222b;
  --border-subtle: #23232b;
  --border-focus: #ff8d07;
  --border-success: #10b981;

  --primary: #ff8d07;
  --primary-hover: #ffa126;
  --primary-glow: rgba(255, 141, 7, 0.22);
  --primary-text: #0a0a0c;

  --text-main: #f5f5f7;
  --text-muted: #8e8e99;
  --text-subtle: #5b5b66;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 24px) env(safe-area-inset-left, 16px);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Container Central */
.app-container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px 8px;
}

/* Header */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding-bottom: 4px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.brand-logo {
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  background-color: rgba(255, 141, 7, 0.15);
  color: var(--primary);
  border: 1px solid rgba(255, 141, 7, 0.3);
}

.header-desc {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
  max-width: 520px;
  margin: 0 auto;
}

/* Toast de Feedback / Preview da Frase */
.toast {
  background: #15151a;
  border: 1px solid var(--border-success);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: slideDown 0.35s var(--ease-out);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.hidden {
  display: none;
}

.toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toast-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--success);
  font-size: 14px;
  font-weight: 700;
}

.toast-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.toast-close-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.toast-preview {
  font-size: 13px;
  color: #cfcfd8;
  background: #0d0d10;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 140px;
  overflow-y: auto;
  border: 1px solid #1f1f26;
}

/* Grade de Clientes */
.grid-section {
  width: 100%;
}

.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}

@media (max-width: 480px) {
  .clients-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* Card do Botão de Cliente */
.client-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  min-height: 84px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.client-btn:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(255, 141, 7, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.client-btn:active {
  transform: scale(0.97);
  background: var(--bg-surface-active);
}

.client-btn-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.client-btn-info {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Estado Copiado com Sucesso no Botão */
.client-btn.copied {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}

.client-btn.copied .client-btn-name {
  color: var(--success);
}

/* Botão Avulso Diferenciado */
.client-btn.btn-avulso {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #181512 0%, #201a13 100%);
  border: 1px dashed rgba(255, 141, 7, 0.55);
  align-items: center;
  text-align: center;
  min-height: 76px;
}

.client-btn.btn-avulso:hover {
  background: linear-gradient(135deg, #221c16 0%, #2c2218 100%);
  border-color: var(--primary);
  box-shadow: 0 8px 24px rgba(255, 141, 7, 0.18);
}

.client-btn.btn-avulso .client-btn-name {
  color: var(--primary);
  justify-content: center;
}

.client-btn.btn-avulso .client-btn-info {
  color: #c9935b;
  justify-content: center;
}

/* Footer */
.footer {
  margin-top: 14px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
}

.admin-trigger-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  min-height: 40px;
}

.admin-trigger-btn:hover {
  color: var(--text-main);
  background: var(--bg-surface);
  border-color: #3b3b44;
}

.footer-copy {
  font-size: 12px;
  color: var(--text-subtle);
}

/* Botões Genéricos */
.btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.18s ease;
  min-height: 44px;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-text);
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-secondary {
  background: #25252e;
  color: var(--text-main);
  border: 1px solid #373742;
}

.btn-secondary:hover {
  background: #31313d;
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #3e3e48;
}

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

.btn-ghost:hover {
  color: var(--text-main);
}

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  min-height: 32px;
}

.text-danger {
  color: var(--danger) !important;
}

.file-label {
  cursor: pointer;
}

/* Modais */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid #282832;
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
  animation: popIn 0.25s var(--ease-out);
  overflow: hidden;
}

.modal-card-lg {
  max-width: 780px;
}

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 22px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Campos de Formulário */
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}

.field-hint {
  font-size: 12px;
  color: var(--text-subtle);
  line-height: 1.4;
  margin-top: 2px;
  margin-bottom: 8px;
}

.field-hint code {
  background: #1d1d24;
  color: var(--primary);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 11px;
}

.text-input {
  width: 100%;
  background: #0d0d10;
  border: 1px solid #2a2a33;
  color: var(--text-main);
  font-family: var(--font);
  font-size: 15px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(255, 141, 7, 0.18);
}

/* Chips de Redes Sociais */
.network-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-btn {
  background: #181820;
  border: 1px solid #282833;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.16s ease;
  user-select: none;
}

.chip-btn:hover {
  background: #23232e;
  color: var(--text-main);
}

.chip-btn.active {
  background: rgba(255, 141, 7, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

/* Seção Admin Específica */
.admin-header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.db-status-badge {
  font-size: 12px;
  font-weight: 600;
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
  box-shadow: 0 0 8px #10b981;
}

/* Card de Formulário de Cliente */
.client-form-card {
  background: #16161c;
  border: 1px solid #2c2c38;
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.client-form-card.hidden {
  display: none;
}

.client-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.client-form-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.phrases-editor-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.phrase-editor-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.phrase-textarea {
  flex: 1;
  background: #0d0d10;
  border: 1px solid #2a2a33;
  color: var(--text-main);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  min-height: 64px;
  line-height: 1.4;
}

.phrase-textarea:focus {
  border-color: var(--border-focus);
}

.btn-remove-phrase {
  background: transparent;
  border: none;
  color: var(--text-subtle);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
}

.btn-remove-phrase:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 8px;
}

/* Lista de Clientes no Admin */
.admin-clients-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-client-item {
  background: #16161b;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-client-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-client-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.admin-client-networks {
  font-size: 12px;
  color: var(--text-muted);
}

.admin-client-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Animações */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

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