/* =========================================================
   FONTES OFICIAIS AEGEA
   ========================================================= */
@font-face {
  font-family: 'AEGEA Sans';
  src: url('./fontes/AEGEASans-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AEGEA Sans';
  src: url('./fontes/AEGEASans-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AEGEA Sans';
  src: url('./fontes/AEGEASans-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AEGEA Sans';
  src: url('./fontes/AEGEASans-Black.otf') format('opentype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'AEGEA Sans Slanted';
  src: url('./fontes/AEGEASansSlanted-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'AEGEA Sans Slanted';
  src: url('./fontes/AEGEASansSlanted-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: 'AEGEA Move';
  src: url('./fontes/AegeaMove-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* =========================================================
   ESTILOS GERAIS & TEMA
   ========================================================= */
:root {
  --aegea-navy: #002060;
  --aegea-blue: #0027BD;
  --aegea-cyan: #00d2c4;
  --aegea-orange: #f58220;
  --bg-dark: #0f172a;
  --panel-bg: rgba(30, 41, 59, 0.85);
  --border-color: rgba(255, 255, 255, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'AEGEA Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: #f8fafc;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

.font-preload {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
}

/* Layout Principal */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
header.app-header {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 50;
  flex-wrap: wrap;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge h1 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Mode Switcher Tabs - Grid responsivo para acomodar todas as abas sem cortes */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 4px;
}

.mode-tab {
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.mode-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.mode-tab.active {
  background: linear-gradient(135deg, #0027BD, #f58220);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(245, 130, 32, 0.3);
}

.concession-selector {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  padding: 4px;
  gap: 4px;
  max-width: 100%;
  overflow-x: auto;
}

.concession-selector::-webkit-scrollbar {
  display: none;
}

.concession-btn {
  border: none;
  background: transparent;
  color: #94a3b8;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.concession-btn:hover {
  color: #ffffff;
}

.concession-btn.active {
  background: linear-gradient(135deg, #0027BD, #00d2c4);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 39, 189, 0.35);
}

/* Main Split View */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Painel de Controle (Esquerda) */
.editor-panel {
  width: 480px;
  min-width: 380px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.editor-panel::-webkit-scrollbar {
  width: 6px;
}
.editor-panel::-webkit-scrollbar-track {
  background: transparent;
}
.editor-panel::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.section-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed rgba(56, 189, 248, 0.4);
  border-radius: 12px;
  padding: 20px 14px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(56, 189, 248, 0.03);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
}

.drop-zone p {
  margin: 6px 0 0 0;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.drop-zone-clear-btn {
  margin-top: 8px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone-clear-btn:hover {
  background: rgba(239, 68, 68, 0.28);
  color: #ffffff;
}

.spin-icon {
  animation: spin 1s linear infinite;
}

/* Inputs & Form */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  color: #ffffff;
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
  line-height: 1.4;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Range Sliders */
input[type=range].w-full {
  width: 100%;
  accent-color: #38bdf8;
  cursor: pointer;
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, #0027BD, #0284c7);
  color: #ffffff;
  border: none;
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(0, 39, 189, 0.3);
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 39, 189, 0.45);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-warning {
  background: linear-gradient(135deg, #f58220, #ea580c);
  color: #ffffff;
  border: none;
  padding: 14px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px rgba(245, 130, 32, 0.35);
  width: 100%;
}

.btn-warning:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 130, 32, 0.5);
}

.btn-warning:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  border: none;
  padding: 10px 20px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.35);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(16, 185, 129, 0.5);
}

/* Painel de Preview (Direita) */
.preview-panel {
  flex: 1;
  background: #090d16;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: auto;
}

.canvas-wrapper {
  position: relative;
  max-height: 84vh;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#cardCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Modal de Loading */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-box {
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 28px 36px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  max-width: 90%;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(56, 189, 248, 0.2);
  border-radius: 50%;
  border-top-color: #38bdf8;
  animation: spin 0.9s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

.loading-box h4 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.loading-box p {
  margin: 0;
  font-size: 0.85rem;
  color: #94a3b8;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================
   RESPONSIVIDADE PARA SMARTPHONES E TABLETS (MOBILE FIRST)
   ========================================================= */
@media (max-width: 868px) {
  .app-container {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  header.app-header {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .brand-badge {
    justify-content: center;
  }

  .concession-selector {
    justify-content: center;
    width: 100%;
  }

  .concession-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    flex: 1;
    justify-content: center;
  }

  .btn-success {
    width: 100%;
    justify-content: center;
    padding: 12px 18px;
  }

  .main-content {
    flex-direction: column-reverse;
    overflow: visible;
  }

  .editor-panel {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-top: 1px solid var(--border-color);
    padding: 16px;
    overflow: visible;
  }

  .preview-panel {
    padding: 16px;
    min-height: 520px;
    width: 100%;
  }

  .canvas-wrapper {
    max-height: 68vh;
    width: 100%;
    max-width: 380px;
  }
}

/* =========================================================
   NOTIFICAÇÕES TOAST (GOOGLE DRIVE & STATUS)
   ========================================================= */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.3s ease;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.toast-info {
  border-left: 4px solid #38bdf8;
}

.toast.toast-success {
  border-left: 4px solid #10b981;
}

.toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

