:root {
  --header-bg: url('/assets/images/flashcard-header.jpg');
  --header-overlay: rgba(0, 0, 0, 0.50);
  --primary: #0b3a42;
  --secondary: #1f6f78;
  --bg: #f2f2f2;
  --border: #ccc;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", sans-serif;
}

body {
  background: var(--bg);
  color: #333;
  overflow-x: hidden;
  position: relative;
}

/* Layout Polos Opostos */
.container {
  max-width: 98%;
  margin: 30px auto;
  display: grid;
  grid-template-columns: 800px 560px;
  justify-content: space-between;
  padding: 0 40px;
  align-items: start;
}

/* --- SELETOR DE DECKS --- */
.deck-locked {
  background: #fff;
  padding: 15px;
  border-radius: 10px;
  border-left: 6px solid var(--secondary);
  margin-bottom: 20px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.custom-select {
  position: relative;
  width: 100%;
}

.select-selected {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  font-weight: 600;
}

.select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  z-index: 1000;
  border-radius: 0 0 8px 8px;
}

/* --- EDITOR --- */
.editor-side {
  width: 100%;
  margin-left: 38px;
}

.toolbar {
  background: #ffffff;
  padding: 10px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 62px;
  /* Mantém as duas toolbars com a mesma altura */
}

.toolbar button,
.toolbar .file-btn {
  width: 42px !important;
  height: 42px !important;
  padding: 0 !important;
  margin: 0 !important;
  cursor: pointer;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  transition: all 0.2s ease;
  color: #444;
  font-size: 1.1rem;
  box-sizing: border-box;
}

.toolbar button:hover,
.toolbar .file-btn:hover {
  background: #f1f3f5;
  border-color: #bbb;
}

.toolbar button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.editor-box {
  background: var(--bg-editor);
  border: 1px solid var(--border);
  padding: 20px;
  min-height: 200px;
  border-radius: 0 0 12px 12px;
  outline: none;
  font-size: 1.1rem;
  transition: background 0.3s ease;
}

.editor-box:focus {
  background: #ffffff;
  border-color: var(--secondary);
}

.editor label {
  display: block;
  margin: 15px 0 5px;
  font-weight: bold;
  color: var(--primary);
}

/* --- PREVIEW (SIMPLES, SEM ANIMAÇÃO) --- */
.preview-wrapper {
  position: sticky;
  top: 20px;
  margin-right: 38px;
}

.card-preview {
  width: 100%;
  height: 440px;
  position: relative;
  cursor: pointer;
  display: block;
}

.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
}

.side {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-radius: 25px;
  font-size: 1.8rem;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-all;
  overflow-y: auto;
}

/* Cores originais do seu projeto */
.front {
  background: white;
  border-top: 15px solid var(--secondary);
  color: #333;
  display: flex; /* Visível por padrão */
}

.back {
  background: var(--primary);
  border-top: 15px solid rgba(255, 255, 255, 0.2);
  color: white;
  display: none; /* Escondido por padrão */
}

/* O SEGREDO: Troca instantânea, sem frufru */
.card-preview.flipped .front {
  display: none;
}

.card-preview.flipped .back {
  display: flex;
}
/* --- BOTÕES DE AÇÃO --- */
.actions {
  margin-top: 25px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-primary,
.btn-secondary,
.btn-outline {
  padding: 16px;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
  border: none;
  text-align: center;
  transition: 0.2s;
}

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

.btn-secondary {
  background: white;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline {
  background: #eee;
  color: #333;
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: #000;
  color: #fff;
}

/* ... Custom Select & Toasts ... */
.custom-select {
  position: relative;
}

.select-selected {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  background: white;
}

.select-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  z-index: 1000;
  border-radius: 0 0 8px 8px;
}

.select-option {
  padding: 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

.hidden {
  display: none !important;
}

#toastContainer {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: #fff;
  padding: 14px 18px;
  border-radius: 10px;
  border-left: 6px solid var(--secondary);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .15);
  font-weight: 600;
  min-width: 240px;
  transform: translateX(120%);
  opacity: 0;
  transition: all .35s ease;
}

.toast.show {
  transform: translateX(0);
  opacity: 1;
}
/* ── Borda vermelha nos editores ao tentar salvar vazio ── */
.editor-box.editor-error {
  border-color: #e74c3c !important;
  box-shadow: 0 0 0 3px rgba(231,76,60,0.15);
}

/* ── Modal sair sem salvar ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}
.modal.show { display: flex; }

.modal-leave {
  background: white;
  padding: 30px;
  border-radius: 18px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity:0; transform:scale(0.95); }
  to   { opacity:1; transform:scale(1); }
}
.leave-icon { font-size:38px; margin-bottom:12px; }
.modal-leave h2 { font-size:19px; color:#0f3c46; margin-bottom:10px; }
.modal-leave p  { font-size:14px; color:#555; line-height:1.6; margin-bottom:0; }
.modal-leave .modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 22px;
}
.modal-leave .secondary {
  background: transparent;
  color: #555;
  border: 1px solid #ccc;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.modal-leave .secondary:hover { border-color:#999; color:#333; }
.modal-leave .danger {
  background: #e74c3c;
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.modal-leave .danger:hover { background: #c0392b; }