/* ==========================================================================
   Femathcc - Repositorio de Tesis & Proyectos de Investigación
   Estilo integrado con el Laboratorio de Matemáticas (UNAL)
   ========================================================================== */

:root {
  --bg: #ffffff;
  --card: #ffffff;
  --line: #e5e7eb;
  --text: #1f2937;
  --muted: #4b5563;
  --accent: rgba(72, 133, 45, 0.88);
  --accent-hover: #2d551c;
  --accent-light: #f0f7ee;
  --accent-border: #bfe0b6;
  
  --font-sans: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-serif: 'Lora', Georgia, serif;
  --font-mono: 'Fira Code', Menlo, Monaco, Consolas, monospace;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
}

[data-theme="dark"] {
  --bg: #0d140e;
  --card: #152017;
  --line: #263829;
  --text: #f0fdf4;
  --muted: #8ca391;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --accent-light: #182b1d;
  --accent-border: #2e5938;
}

/* Dark mode page background and layout overrides */
html[data-theme="dark"],
html[data-theme="dark"] body {
  background-color: var(--bg) !important;
  color: var(--text) !important;
  transition: background-color 0.2s ease, color 0.2s ease;
}

html[data-theme="dark"] .initial-content {
  background-color: var(--bg) !important;
}

html[data-theme="dark"] .masthead {
  background-color: var(--card) !important;
  border-bottom: 1px solid var(--line) !important;
  transition: background-color 0.2s ease;
}

html[data-theme="dark"] .masthead a {
  color: var(--text) !important;
}

html[data-theme="dark"] .masthead a:hover {
  color: var(--accent) !important;
}

html[data-theme="dark"] .greedy-nav {
  background: transparent !important;
}

html[data-theme="dark"] .greedy-nav button {
  background: transparent !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .page__footer {
  background-color: var(--card) !important;
  color: var(--muted) !important;
  border-top: 1px solid var(--line) !important;
  transition: background-color 0.2s ease;
}

html[data-theme="dark"] .page__footer a {
  color: var(--accent) !important;
}

html[data-theme="dark"] .page__footer-copyright {
  color: var(--muted) !important;
}

/* Scoped box-sizing */
.femath-wrapper *,
.femath-wrapper *::before,
.femath-wrapper *::after,
.modal-overlay *,
.modal-overlay *::before,
.modal-overlay *::after {
  box-sizing: border-box;
}

.femath-wrapper {
  color: var(--text);
  font-family: var(--font-sans);
  margin-bottom: 40px;
}

.hidden { display: none !important; }

/* Hero Section */
.femath-hero {
  text-align: center;
  max-width: 900px;
  margin: 10px auto 25px auto;
  padding: 0 15px;
}

.femath-hero h1 {
  text-align: center;
  color: #000000;
  font-size: clamp(1.8rem, 3.5vw, 2.3rem);
  font-weight: bold;
  margin: 15px 0;
  transition: color 0.2s ease;
}

.femath-divider {
  border: none;
  height: 1px;
  background-color: #CCCCCC;
  margin: 15px auto;
  max-width: 900px;
  transition: background-color 0.2s ease;
}

.femath-subtitle {
  font-family: 'Arial', sans-serif;
  color: #000000;
  font-size: 16px;
  line-height: 1.6;
  margin: 15px auto;
  max-width: 820px;
  text-align: center;
  transition: color 0.2s ease;
}

html[data-theme="dark"] .femath-hero h1 {
  color: #f0fdf4 !important;
}

html[data-theme="dark"] .femath-subtitle {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .femath-subtitle strong {
  color: #ffffff !important;
}

html[data-theme="dark"] .femath-divider {
  background-color: var(--line) !important;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Sticky Toolbar */
.toolbar {
  position: sticky;
  top: 10px;
  z-index: 90;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .toolbar {
  background: rgba(21, 32, 23, 0.94);
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto auto auto auto;
  gap: 10px;
  align-items: center;
}

.search-field {
  position: relative;
}

.search-field input {
  width: 100%;
  padding-right: 32px;
}

.clear-search {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  transform: translateY(-50%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

input, select {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 14px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(72, 133, 45, 0.18);
}

.theme-toggle-btn {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease;
}

.theme-toggle-btn:hover {
  background: var(--accent-light);
}

[data-theme="light"] .sun-icon { display: none; }
[data-theme="light"] .moon-icon { display: block; }
[data-theme="dark"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: none; }

.meta {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: bold;
  padding: 8px 16px;
  border-radius: 20px; /* Estilo pastilla del laboratorio */
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none !important;
  transition: all 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff !important;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #ffffff !important;
  opacity: 1;
}

.btn-outline {
  border-color: var(--accent-border);
  color: var(--accent);
  background: transparent;
}

.btn-outline:hover {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12.5px;
  border-radius: 16px;
}

/* Grid & Cards */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  margin-bottom: 40px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-border);
}

.media {
  height: 190px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9fafb;
  position: relative;
  overflow: hidden;
}

[data-theme="dark"] .media {
  background: #111827;
}

.media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.media canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.media-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(17, 24, 39, 0.82);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.chip {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid var(--accent-border);
  color: var(--accent-hover);
  background: var(--accent-light);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  margin-bottom: 8px;
  align-self: flex-start;
}

[data-theme="dark"] .chip {
  color: var(--accent);
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  line-height: 1.35;
  color: var(--text);
  cursor: pointer;
  transition: color 0.15s ease;
}

.card-title:hover {
  color: var(--accent-hover);
}

[data-theme="dark"] .card-title:hover {
  color: var(--accent);
}

.card-authors {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.4;
}

.math-snippet {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-bottom: 10px;
  overflow-x: auto;
}

.desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(17, 24, 39, 0.72);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

.modal-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  position: relative;
  color: var(--text);
}

.modal-large {
  max-width: 840px;
}

.modal-close-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text);
}

.modal-header-block {
  margin-bottom: 16px;
}

.modal-title {
  font-family: var(--font-sans);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  margin: 8px 0;
}

.modal-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 12px;
  line-height: 1.4;
}

.modal-meta-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 12px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
}

.modal-media-container {
  height: 280px;
  background: #111827;
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-media-container canvas,
.modal-media-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.math-box {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
  text-align: center;
}

.modal-section {
  margin-bottom: 16px;
}

.modal-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 700;
}

.abstract-p {
  font-size: 14.5px;
  line-height: 1.6;
  text-align: justify;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.cite-selector {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.cite-tab {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s ease;
}

.cite-tab.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.cite-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--text);
  outline: none;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(17, 24, 39, 0.95);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 350;
}

/* Empty State */
.empty-results {
  text-align: center;
  padding: 48px 20px;
  background: var(--card);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  margin-bottom: 40px;
}

.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

/* Femathcc Credits */
.femath-credits {
  text-align: center;
  max-width: 900px;
  margin: 30px auto 10px auto;
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.6;
}

.femath-credits p {
  margin-bottom: 6px;
}

.femath-credits a {
  color: #318233;
  text-decoration: none;
}

.femath-credits a:hover {
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 900px) {
  .controls {
    grid-template-columns: 1fr 1fr;
  }
  
  .search-field {
    grid-column: span 2;
  }
}

@media (max-width: 600px) {
  .controls {
    grid-template-columns: 1fr;
  }
  
  .search-field {
    grid-column: span 1;
  }
  
  .modal-meta-row {
    grid-template-columns: 1fr;
  }
}
