/* 
  Modern Modux Theme - Premium Glassmorphism Design 
  Refactored from inline styles
*/

:root {
  --main-color: #0c194b;
  --accent-color: #4f46e5;
  --highlight-bg: rgba(253, 230, 138, 0.5);
  --highlight-text: #7c2d12;
  --text-color: #1a1a2e;
  --bg-color: #ffde59;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px 0 rgba(12, 25, 75, 0.14);
  --font-heading: 'Syne', sans-serif;
  --font-body: 'Jost', sans-serif;
}

body {
  font-family: var(--font-body);
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  font-size: 1.1rem;
  /* Better base size */
  background: linear-gradient(135deg, #ffee75 0%, #ffde59 50%, #fdbb2d 100%);
  background-attachment: fixed;
  color: var(--text-color);
  position: relative;
}

/* --- ENTRY PAGE GRID --- */
#entry-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #ffee75 0%, #ffde59 50%, #fdbb2d 100%);
  /* Paleta do site */
  z-index: 20000;
  overflow-y: auto;
  padding: 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#entry-page h1 {
  font-family: var(--font-heading);
  color: var(--main-color);
  margin-bottom: 40px;
  font-size: 3.5em;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: -2px;
}

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 30px;
  width: 100%;
  max-width: 1400px;
  padding: 20px;
}

.entry-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 30px;
  border-radius: 16px;
  box-shadow: var(--glass-shadow);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  flex-direction: column;
}

.entry-card:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  border-color: var(--main-color);
  background: rgba(255, 255, 255, 0.9);
}

.entry-card h2 {
  font-family: var(--font-heading);
  font-size: 1.4em;
  margin: 0 0 15px 0;
  color: var(--main-color);
  line-height: 1.2;
}

.entry-card p {
  margin-top: auto;
  font-size: 0.95em;
  opacity: 0.7;
  font-style: italic;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 15px;
}

/* --- MAIN LAYOUT --- */
.main-content-wrapper {
  height: 100vh;
  width: 100%;
  display: flex;
  background: transparent;
  /* Removed animation to prevent flickering */
}

/* Right Layout Support */
.main-content-wrapper.layout-right {
  flex-direction: row-reverse;
}

.main-content-wrapper.layout-right .media-sidebar {
  border-right: none;
  border-left: 1px solid var(--glass-border);
  border-radius: 20px 0 0 20px;
  margin: 20px 20px 20px 0;
}

.main-content-wrapper.layout-right .resumo-wrapper {
  border-radius: 20px 20px 0 0;
  /* Consistent radius */
}

/* Reduced flickering by removing animation */

.resumo-wrapper {
  padding: 60px;
  overflow-y: auto;
  /* Removed max-width that causes jumping */
  /* max-width: 800px; */
  width: 100%;
  /* Fill available space */
  margin: 0;
  box-sizing: border-box;
  flex-grow: 1;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(5px);
  border-radius: 20px 20px 0 0;
  margin-top: 20px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.05);
}

/* --- SIDEBAR --- */
/* --- SIDEBAR --- */
.media-sidebar {
  /* Layout Stability */
  width: 400px;
  /* Default width */
  flex: 0 0 400px;
  /* Strict flex basis */
  height: calc(100vh - 40px);

  /* Overflow Control */
  overflow: hidden;
  box-sizing: border-box;

  /* Styling */
  background: var(--glass-bg);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-right: 1px solid var(--glass-border);
  border-radius: 0 20px 20px 0;
  margin: 20px 0 20px 20px;
  box-shadow: 5px 0 25px rgba(0, 0, 0, 0.05);

  /* Flex Layout */
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 100;
}

/* Ensure inner content never exceeds parent width */
.media-sidebar * {
  max-width: 100%;
}

.preview-tooltip {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  box-sizing: border-box;
  padding: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  background: transparent;
}

/* removed stray text */

.media-sidebar.floating {
  position: fixed;
  right: 20px;
  top: 20px;
  left: auto;
  transform: none;
  width: 350px;
  height: 350px;
  border: none;
  border-radius: var(--media-radius, 16px);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  margin: 0;
  background: rgba(20, 20, 30, 0.95);
  backdrop-filter: blur(20px);
}

.media-sidebar.floating:hover .window-btn {
  opacity: 1;
}

.media-sidebar.fullscreen {
  width: 90vw !important;
  height: 90vh !important;
  right: 5vw !important;
  top: 5vh !important;
  border-radius: 0;
}

.media-sidebar.minimized {
  width: 120px !important;
  height: 40px !important;
  border-radius: 20px;
  overflow: hidden;
}

.media-sidebar.minimized .preview-tooltip,
.media-sidebar.minimized #media-placeholder,
.media-sidebar.minimized .resize-handle,
.media-sidebar.minimized .resize-corner {
  display: none;
}

.window-btn {
  position: absolute;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.window-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.fullscreen-btn {
  top: 8px;
  right: 8px;
}

.minimize-btn {
  top: 8px;
  right: 48px;
}

.resize-corner {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 30px;
  height: 30px;
  cursor: nwse-resize;
  z-index: 200;
  background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, 0.3) 50%);
  border-bottom-right-radius: var(--media-radius, 16px);
}

.resize-corner:hover {
  background: linear-gradient(135deg, transparent 50%, rgba(255, 255, 255, 0.6) 50%);
}

.media-sidebar.floating .resize-corner {
  display: block;
}

.media-sidebar:not(.floating) .resize-corner {
  display: none;
}

.media-sidebar.hidden {
  display: none;
}

#media-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--main-color);
  opacity: 0.4;
  font-family: var(--font-heading);
  text-align: center;
  padding: 40px;
  box-sizing: border-box;
  font-size: 1.2em;
  letter-spacing: 2px;
  z-index: 1;
}

/* --- TYPOGRAPHY --- */
h1#title {
  font-family: var(--font-heading);
  font-size: 2.5em;
  color: var(--main-color);
  margin: 0;
  line-height: 1.1;
  text-transform: uppercase;
}

#author {
  font-weight: 500;
  color: #666;
  margin-bottom: 3em;
  font-size: 1.1em;
  display: block;
  letter-spacing: 1px;
}

#abstract-content {
  line-height: 1.8;
  font-size: 1.15em;
  color: #333;
}

#abstract-content img, .entry-card img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

#abstract-content figure.inline-img {
  margin: 24px auto;
  text-align: center;
}

#abstract-content figure.inline-img img {
  margin: 0 auto;
}

#abstract-content figure.inline-img figcaption {
  font-size: 0.85em;
  color: #888;
  font-style: italic;
  margin-top: 8px;
}

.hover-word {
  font-weight: 600;
  color: var(--main-color);
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  border-bottom: 2px solid transparent;
}

.hover-word:hover {
  color: var(--highlight-text);
  background: linear-gradient(120deg, transparent 0%, var(--highlight-bg) 100%);
  border-bottom: 2px solid var(--main-color);
  /* Removed font-weight change to prevent layout shift */
}

.ref-sup {
  font-size: 0.7em;
  vertical-align: super;
  color: var(--main-color);
  margin-left: 2px;
  font-weight: bold;
}

/* --- UI CONTROLS --- */
#index-container {
  position: fixed;
  top: 30px;
  left: 30px;
  z-index: 10001;
}

#index-trigger {
  width: 70px;
  height: 70px;
  background-color: var(--main-color);
  color: white;
  border-radius: 50%;
  /* Circle */
  box-shadow: 0 10px 20px rgba(89, 86, 134, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-heading);
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 4px solid white;
}

#index-trigger:hover {
  transform: scale(1.1) rotate(5deg);
}

#index-panel {
  display: none;
  position: absolute;
  top: 80px;
  left: 0;
  background: white;
  padding: 20px 22px;
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  width: 420px;
  max-height: 62vh;
  overflow-y: auto;
  animation: indexPanelIn 0.25s ease;
}

/* Mantém o menu animado: entrada suave do painel + hover do botão */
@keyframes indexPanelIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

#index-panel h4 {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  color: var(--main-color);
  margin: 0 0 14px 0;
}

#mini-toc-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Itens do índice: fontes padronizadas, sem divisores, com espaçamentos */
.index-item {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 13px 15px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}
.index-item strong {
  display: block;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--main-color);
  margin-bottom: 2px;
}
.index-item small {
  display: block;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 400;
  font-style: normal;
  color: #555;
}
.index-item:hover {
  background: #fff;
  border-color: var(--main-color);
  transform: translateX(4px);
}

#layout-controls {
  position: fixed;
  z-index: 20002;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 40px;
  padding: 6px 12px;
  border: 1px solid rgba(89, 86, 134, 0.22);
  bottom: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.control-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: none;
  background: transparent;
  color: var(--main-color, #0c194b);
  font-family: 'Jost', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  opacity: 0.85;
  transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
  text-decoration: none;
}

.control-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.control-btn span {
  white-space: nowrap;
}

.control-btn:hover {
  background: rgba(89, 86, 134, 0.12);
  opacity: 1;
  transform: translateY(-1px);
}

.control-btn.active {
  background: var(--main-color, #0c194b);
  color: #ffffff;
  opacity: 1;
  box-shadow: 0 3px 8px rgba(12, 25, 75, 0.25);
}

.media-muted-toast {
  position: fixed;
  bottom: 76px;
  right: 24px;
  z-index: 20003;
  background: rgba(18, 18, 28, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #ffffff;
  font-family: 'Jost', sans-serif;
  font-size: 0.78rem;
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

/* --- LIGHTBOX --- */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(20, 20, 30, 0.95);
  backdrop-filter: blur(5px);
  z-index: 30000;
  justify-content: center;
  align-items: center;
}

.lightbox.active {
  display: flex;
}

.lightbox .close-btn {
  position: absolute;
  top: 20px;
  right: 30px;
  font-size: 30px;
  color: white;
  cursor: pointer;
  z-index: 30001;
}

.lightbox-content {
  background: transparent;
  box-shadow: none;
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 90vw;
  height: 90vh;
}

.lightbox-content img,
.lightbox-content video,
.lightbox-content iframe {
  max-width: 100%;
  max-height: 100%;
  border-radius: 8px;
}

/* Hide references toggle */
body.hide-references .ref-sup,
body.hide-references #references-container {
  display: none !important;
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}

::-webkit-scrollbar-thumb {
  background: rgba(89, 86, 134, 0.3);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(89, 86, 134, 0.6);
}

/* --- REFERENCES --- */
#references-container {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  margin-top: 60px;
  padding-top: 30px;
}

#references-toggle {
  color: var(--main-color);
  font-family: var(--font-heading);
  font-size: 1.2em;
}

/* --- PREVIEW CONTENT --- */
.preview-tooltip {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.preview-tooltip img,
.preview-tooltip video,
.preview-tooltip iframe {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

.preview-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 15px 20px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  color: white;
  font-size: 0.9em;
  text-align: center;
  z-index: 20;
}

/* --- RESIZE HANDLE --- */
.resize-handle {
  width: 6px;
  height: 100%;
  background: rgba(89, 86, 134, 0.2);
  position: absolute;
  right: 0;
  top: 0;
  cursor: col-resize;
  z-index: 200;
  transition: background 0.2s;
}

.resize-handle:hover,
.resize-handle:active {
  background: var(--main-color);
}

/* 
  ==========================================================================
  SISTEMA DE DESIGN MODUX SERVER (COMPONENTES DE UI REUTILIZÁVEIS)
  ==========================================================================
*/

/* --- UNIFIED NAVBAR --- */
.modux-navbar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  padding: 12px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-sizing: border-box;
  width: 100%;
}

.modux-navbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.modux-navbar .brand-logo {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--main-color);
  letter-spacing: -1px;
  text-transform: uppercase;
}

.modux-navbar .brand-tag {
  font-size: 0.7rem;
  font-weight: 700;
  background: var(--main-color);
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.modux-navbar nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modux-navbar nav a {
  text-decoration: none;
  color: #4a5568;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modux-navbar nav a:hover,
.modux-navbar nav a.active {
  color: var(--main-color);
  background: rgba(89, 86, 134, 0.1);
}

.modux-navbar nav a.btn-logout {
  color: #dc2626;
  background: rgba(220, 38, 38, 0.06);
}

.modux-navbar nav a.btn-logout:hover {
  background: rgba(220, 38, 38, 0.14);
  color: #b91c1c;
}

/* --- GLASS CARDS & PANELS --- */
.modux-card {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--glass-shadow);
  margin-bottom: 24px;
  transition: box-shadow 0.3s ease, border-color 0.3s ease;
}

.modux-card:hover {
  box-shadow: 0 12px 40px rgba(31, 38, 135, 0.12);
  border-color: rgba(89, 86, 134, 0.25);
}

.modux-card .card-title {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  color: var(--main-color);
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- FORM ELEMENTS & INPUTS --- */
.form-group {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  margin-bottom: 6px;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-color);
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-control:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--main-color);
  box-shadow: 0 0 0 3px rgba(89, 86, 134, 0.15);
  background: white;
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
}

.btn-primary {
  background: var(--main-color);
  color: white;
  box-shadow: 0 4px 12px rgba(89, 86, 134, 0.25);
}

.btn-primary:hover {
  background: #48456c;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(89, 86, 134, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: #475569;
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
  background: white;
  border-color: var(--main-color);
  color: var(--main-color);
}

.btn-danger {
  background: #ef4444;
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-success {
  background: #10b981;
  color: white;
}

.btn-success:hover {
  background: #059669;
}

/* --- LANGUAGE TOGGLE (viewer PT/EN) --- */
.action-buttons {
  display: flex;
  gap: 8px;
}

.action-buttons button {
  padding: 8px 14px;
  border-radius: 50px;
  border: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.85);
  color: #475569;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.action-buttons button:hover {
  border-color: var(--main-color);
  color: var(--main-color);
}

.action-buttons button.active {
  background: var(--main-color);
  color: #fff;
  border-color: var(--main-color);
}

/* --- TABLES & LISTS --- */
.modux-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 10px;
}

.modux-table th {
  background: rgba(89, 86, 134, 0.08);
  color: var(--main-color);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid rgba(89, 86, 134, 0.2);
}

.modux-table th:first-child { border-top-left-radius: 8px; }
.modux-table th:last-child { border-top-right-radius: 8px; }

.modux-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.6);
}

.modux-table tr:hover td {
  background: rgba(255, 255, 255, 0.9);
}

/* --- BADGES --- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-approved, .badge-success {
  background: #d1fae5;
  color: #065f46;
}

.badge-pending, .badge-warning {
  background: #fef3c7;
  color: #92400e;
}

.badge-rejected, .badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-admin {
  background: #e0e7ff;
  color: #3730a3;
}