:root {
  --bg-main: #f7dde2;
  --bg-panel: #ffffff;
  --accent: #d9c7f1;
  --accent-2: #cde7f0;
  --accent-3: #f0e8f5;
  --text-main: #444;
  --text-secondary: #666;
  --border-soft: #e5e5e5;
  --accent-dark: #9b88c4;
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
  font-family: 'Nunito', sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.2rem 1rem;
  background: linear-gradient(135deg, #faf0f3 0%, #ffffff 100%);
  box-shadow: 0 2px 8px rgba(155, 136, 196, 0.05);
  flex-shrink: 0;
  z-index: 1001;
  border-bottom: 1px solid var(--border-soft);
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 1 auto;
}

.logo-square {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
  box-shadow: 0 2px 8px rgba(155, 136, 196, 0.12);
  overflow: hidden;
}

.logo-square img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.logo {
  font-size: 0.95rem;
  font-weight: 700;
  color: #4a4a6a;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: font-size 0.3s ease;
}

@media (max-width: 900px) {
  .logo {
    font-size: 0.95rem;
    max-width: 180px;
  }
}

@media (max-width: 768px) {
  .logo-section {
    gap: 0.75rem;
  }

  .logo {
    font-size: 0.85rem;
    max-width: 140px;
  }

  .logo-square {
    width: 40px;
    height: 40px;
    min-width: 40px;
    font-size: 1.2rem;
  }
}

@media (max-width: 600px) {
  .logo {
    font-size: 0.85rem;
    max-width: 50px;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  max-width: 400px;
  word-wrap: break-word;
}

.toast.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
}

.toast.error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: white;
}

.toast.info {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.toast-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.toast-message {
  flex: 1;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.toast.removing {
  animation: slideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@media (max-width: 600px) {
  .toast-container {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
  }

  .toast {
    max-width: 100%;
  }
}

.menu {
  display: flex;
  gap: 0.2rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.menu-btn {
  padding: 0.6rem 1rem;
  border: 2px solid transparent;
  background: rgba(217, 199, 241, 0.3);
  color: #4a4a6a;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  display: inline-block;
}

.menu-btn:hover {
  background: rgba(217, 199, 241, 0.5);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(155, 136, 196, 0.15);
}

.menu-btn.active {
  background: #2d5016;
  color: white;
  border-color: #000000;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.menu-btn.active:hover {
  background: #1e3810;
  transform: translateY(-2px);
}

.menu-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.layout {
  display: flex;
  gap: 0.8rem;
  padding: 0.8rem;
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.panel {
  background: var(--bg-panel);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(155, 136, 196, 0.08);
  padding: 0.3rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(217, 199, 241, 0.3);
}

.panel-svg {
  flex: 0 0 36%;
  min-width: 320px;
  overflow: auto;
  min-height: 500px;
}

.panel-editor {
  flex: 1;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  overflow: auto;
  min-height: 500px;
}

#svgContainer {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
}

#svgContainer svg {
  width: 100%;
  height: auto;
  max-height: 100%;
}

.selectors {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.field {
  flex: 0 1 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: fit-content;
}

.field label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #4a4a6a;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 30px;
}

.field select,
.field input {
  flex: 0 1 auto;
  min-width: 60px;
  max-width: 60px;
}

.field select,
.test-form input,
.field input {
  padding: 0.1rem 0.3rem;
  border: 2px solid var(--border-soft);
  border-radius: 8px;
  font-size: 0.8rem;
  font-family: 'Nunito', sans-serif;
  background: #fafafa;
  color: var(--text-main);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.field select:focus,
.test-form input:focus,
.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: white;
  box-shadow: 0 0 0 3px rgba(179, 229, 176, 0.1);
}

.selectors .btn-primary {
  align-self: flex-end;
  padding: 0.1rem 0.7rem;
  margin-bottom: 0;
}

.edad-consulta {
  align-self: flex-end;
  margin-bottom: 0.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent-dark, #4a7c4a);
  white-space: nowrap;
}

.save-container {
  display: flex;
  justify-content: flex-end;
  flex-shrink: 1;
  align-self: flex-end;
  margin-left: auto;
  min-width: 28px;
  gap: 0;
}

.btn-save {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  border: none;
  padding: 0.1rem;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(155, 136, 196, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 22px;
  width: 22px;
  height: 22px;
}

.btn-save svg {
  width: 16px;
  height: 16px;
}

.btn-save:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(155, 136, 196, 0.25);
}

.btn-save svg {
  stroke: white !important;
}

.editor-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}

.ql-toolbar {
  flex-shrink: 0;
  margin-bottom: 0;
}

.ql-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#editor,
#editorKarma,
#editorProposito,
#editorMision {
  overflow-y: auto !important;
  flex: 1;
  min-height: 0;
  max-height: 100%;
}

#toolbar {
  border-radius: 12px 12px 0 0;
}


.panel-test {
  max-width: 600px;
  margin-top: 1rem;
}

.test-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.test-form input {
  padding: 0.5rem;
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  font-size: 0.875rem;
}

.tab-title-input {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #4a4a6a;
  margin: 0 0 0.5rem 0;
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--border-soft) !important;
  border-radius: 8px !important;
  background: linear-gradient(180deg, #fafafa 0%, #f9f8f9 100%) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-title-input:focus {
  outline: none;
  border-color: var(--accent) !important;
  background: white !important;
  box-shadow: 0 0 0 3px rgba(217, 199, 241, 0.1);
}

.btn-primary {
  background: var(--accent-dark);
  color: white;
  border: none;
  padding: 0.65rem 1.5rem;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(155, 136, 196, 0.15);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(155, 136, 196, 0.25);
}

#testResults {
  margin-top: 1rem;
  max-height: 400px;
  overflow-y: auto;
  background: linear-gradient(180deg, #fafafa 0%, #f9f8f9 100%);
  border: 2px solid var(--border-soft);
  border-radius: 12px;
  padding: 1rem;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.result-table th,
.result-table td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}

.result-table th {
  background: var(--accent-3);
  font-weight: 600;
  color: #4a4a6a;
}

/* Consulta page styles */
.panel-editor {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-height: 0;
}

.value-display {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.5rem;
  background: linear-gradient(180deg, #fafafa 0%, #f9f8f9 100%);
  border-radius: 12px;
  border: 2px solid var(--border-soft);
  min-height: 0;
}

.value-display label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.1rem;
  color: #4a4a6a;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1px;
}

.readonly-field {
  flex: 1;
  padding: 0.3rem;
  background: rgb(235 235 235);
  border: 2px solid var(--border-soft);
  border-radius: 10px;
  overflow-y: auto !important;
  overflow-x: hidden;
  font-size: 0.95rem;
  color: var(--text-main);
  word-break: break-word;
  line-height: 1.2;
  min-height: 50px;
}

.readonly-field ul,
.readonly-field ol {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.readonly-field li {
  margin: 0.25rem 0;
}

.readonly-field p {
  margin: 0.5rem 0;
}

.readonly-field strong {
  font-weight: 600;
}

.readonly-field em {
  font-style: italic;
}

/* Tabs styles */
.tabs-bar {
  display: flex;
  border-bottom: 2px solid var(--border-soft);
  gap: 0;
  margin-bottom: 0.1rem;
  flex-shrink: 0;
}

.tab-btn {
  padding: 0.1rem 1.2rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.8rem;
  border-bottom: 3px solid transparent;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  position: relative;
}

.tab-btn:hover {
  color: #4a4a6a;
}

.tab-btn.active {
  border-bottom-color: var(--accent-dark);
  color: white;
  background: var(--accent-dark);
  border-radius: 8px 8px 0 0;
  font-weight: 700;
}

.tab-content {
  display: none;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
  min-height: 0;
}

.tab-content[style*="display: block"] {
  display: flex !important;
}

.tab-placeholder {
  color: #999;
  font-style: italic;
  padding: 2rem;
  text-align: center;
  margin: auto;
}

/* Quill Editor Styles */
.ql-toolbar {
  border-radius: 12px 12px 0 0 !important;
  border: 2px solid var(--border-soft) !important;
  border-bottom: 1px solid var(--border-soft) !important;
  background: #e8e8e8 !important;
  padding: 0.2rem !important;
  flex-shrink: 0;
}

.ql-toolbar button,
.ql-toolbar button:hover {
  width: 28px;
  height: 28px;
}

.ql-toolbar button svg {
  width: 14px;
  height: 14px;
}

.ql-container {
  border-radius: 0 0 16px 16px !important;
  border: 2px solid var(--border-soft) !important;
  border-top: none !important;
  font-size: 0.95rem !important;
  background: white;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-height: 100%;
  overflow: hidden !important;
}

.ql-editor {
  flex: 1;
  min-height: 0;
  line-height: 1.5;
  color: var(--text-main);
  padding: 0.5rem 0.8rem;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  font-size: 0.9rem;
}

.ql-editor.ql-blank::before {
  color: #aaa;
  font-style: italic;
}

/* Divider button in toolbar */
.ql-toolbar .ql-divider::before {
  content: '|';
  display: inline-block;
}

/* Horizontal rule in editor */
.ql-editor hr {
  border: none;
  border-top: 2px solid #000000;
  margin: 1rem 0;
  height: 0;
}

.ql-editor .ql-divider {
  display: block;
  border: none;
  border-top: 2px solid #000000;
  margin: 1rem 0;
  padding: 0;
}

/* Compact selectors for Arquetipo tab - Mantenimiento (index.php) */
#tab-arquetipo .selectors {
  flex-wrap: wrap;
  gap: 0.2rem;
}

#tab-arquetipo .field {
  flex: 0 1 auto;
  min-width: fit-content;
}

/* En Mantenimiento (index.php): Energía se expande, Arquetipo fijo */
#tab-arquetipo .field:has(> #cmbEnergia) {
  flex: 1 !important;
}

#tab-arquetipo .field:has(> #cmbEnergia) select {
  width: 100% !important;
  min-width: 60px !important;
  max-width: none !important;
}

#tab-arquetipo .field:has(> #cmbArquetipo) {
  flex: 0 0 130px !important;
}

#tab-arquetipo .field:has(> #cmbArquetipo) select {
  width: 130px !important;
  min-width: 130px !important;
  max-width: 130px !important;
}

/* Consulta page - combos de fecha sin expansión automática */
#cmbDia {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  flex: 0 0 auto !important;
}

#cmbMes {
  width: 100px !important;
  min-width: 100px !important;
  max-width: 100px !important;
  flex: 0 0 auto !important;
}

#txtYear {
  width: 60px !important;
  min-width: 60px !important;
  max-width: 60px !important;
  flex: 0 0 auto !important;
}

#tab-arquetipo .field select {
  width: auto;
  min-width: 110px;
  max-width: 180px;
}

/* Compact selectors for Karma, Propósito, Misión, E Año tabs */
#tab-karma .selectors,
#tab-proposito .selectors,
#tab-mision .selectors,
#tab-eneano .selectors {
  flex-wrap: wrap;
  gap: 0.5rem;
}

#tab-karma .field,
#tab-proposito .field,
#tab-mision .field,
#tab-eneano .field {
  flex: 0 1 auto;
  min-width: fit-content;
}

#tab-karma .field select,
#tab-proposito .field select,
#tab-mision .field select,
#tab-eneano .field select {
  min-width: 50px;
  max-width: 100px;
}

#tab-karma .tab-title-input,
#tab-proposito .tab-title-input,
#tab-mision .tab-title-input,
#tab-eneano .tab-title-input {
  flex: 1;
  margin: 0;
  padding: 0.15rem 0.3rem;
  font-size: 0.8rem;
}

@media (max-width: 1024px) {
  .menu-btn {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 900px) {
  .menu-btn {
    padding: 0.5rem 0.875rem;
    font-size: 0.8rem;
  }

  .layout {
    flex-direction: column;
    gap: 1rem;
  }

  .panel-svg {
    flex: 0 0 auto;
    min-width: 100%;
    min-height: 400px;
    max-height: 400px;
  }

  .panel-editor {
    flex: 1;
    min-width: 100%;
    min-height: 400px;
  }
}

@media (max-width: 768px) {
  .panel-svg {
    max-width: 100%;
    flex: 0 0 auto;
    min-width: 100%;
    min-height: 350px;
    max-height: 350px;
  }

  .tabs-bar {
    flex-wrap: wrap;
  }

  .tab-btn {
    flex: 1 1 auto;
    min-width: 80px;
  }

  .menu-btn {
    padding: 0.45rem 0.75rem;
    font-size: 0.75rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 16px;
  }

  .layout {
    padding: 1rem;
  }
}

@media (max-width: 600px) {
  .panel-svg {
    min-height: 300px;
    max-height: 300px;
  }

  .panel {
    padding: 0.75rem;
    border-radius: 12px;
  }

  .layout {
    gap: 0.75rem;
    padding: 0.75rem;
    padding-top: 4.5rem;
  }
}

.ql-toolbar.ql-snow .ql-formats{
  margin-right: 0.2rem;
}