/* === PALETA DE COLORES UNIFICADA: Azul/Púrpura Pastel === */
:root {
  --accent-primary: #87CEEB; /* Azul pastel principal */
  --accent-primary-hover: #b983ff; /* Púrpura pastel para hover */
  --accent-secondary: #FFB6C1; /* Rosa pastel para acentos */
  --surface-elevated: #3A455B;
  --surface-selected: #404A60;
  --surface: linear-gradient(120deg, #191a1a 0%, #23272f 100%);
  --border-light: rgba(135, 206, 235, 0.3);
  --border-strong: #87CEEB;
  --text-primary: #fff;
  --text-secondary: #87CEEB;
  --radius-lg: 1.2rem;
  --radius-md: 0.7rem;
  --radius-sm: 0.4rem;
  --card-padding: 10px 18px 10px 18px;
  --border-card: #b983ff22;
  --surface-elevated: #23272f;
  --surface-selected: #404A60;
  --accent-primary: #b983ff;
  --accent-secondary: #b983ffcc;
  --radius-md: 12px;
  --radius-lg: 18px;
  --text-primary: #fff;
  --text-secondary: #b0b0b0;
}

.lm-studio-app {
  background: linear-gradient(135deg, 
    #2A3F5F 0%, 
    #4A3B6B 50%, 
    #5F3A4A 100%);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  min-height: 80vh;
  max-height: 90vh;
  height: 85vh;
  display: flex;
}

.sidebar {
  width: 420px;
  background: linear-gradient(135deg, 
    #3A4F6F 0%, 
    #5A4B7B 100%);
  border-right: 2px solid var(--border-light);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  backdrop-filter: blur(20px);
}

.search-header {
  padding: 16px 16px 10px 16px;
  border-bottom: 1px solid var(--border-light);
  background: transparent;
}

.search-form {
  position: relative;
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  background: linear-gradient(135deg, #3A455B, #4A3B6B);
  border: 2px solid var(--border-light);
  border-radius: 12px;
  padding: 10px 12px 10px 38px;
  color: var(--text-primary);
  font-size: 14px;
  transition: border 0.3s ease, box-shadow 0.3s ease;
  backdrop-filter: blur(10px);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary-hover);
  box-shadow: 0 0 20px rgba(135, 206, 235, 0.3);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent-primary);
}

.filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.filter-select {
  background: linear-gradient(135deg, #3A455B, #4A3B6B);
  border: 2px solid var(--border-light);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-size: 12px;
  transition: border 0.3s ease, box-shadow 0.3s ease;
  backdrop-filter: blur(10px);
}

.filter-select:focus {
  border-color: var(--accent-primary-hover);
  box-shadow: 0 0 15px rgba(135, 206, 235, 0.3);
}

.gguf-badge {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-primary-hover));
  color: white;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(135, 206, 235, 0.3);
}

.staff-picks {
  background: linear-gradient(135deg, var(--accent-secondary), #FF8FA3);
  color: white;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  box-shadow: 0 2px 8px rgba(255, 182, 193, 0.3);
}

.models-list {
  flex: 1;
  overflow: auto;
  background: transparent;
}

.model-card,
.model-card-modern {
  padding: var(--card-padding);
  border-bottom: 1px solid var(--border-card);
  border-radius: 0;
  background: linear-gradient(90deg, #23272f 70%, #3A455B 100%);
  transition: background 0.18s, box-shadow 0.18s;
  cursor: pointer;
  outline: none;
}
.model-card.selected, .model-card-modern.selected {
  background: linear-gradient(90deg, var(--surface-selected) 80%, var(--accent-primary) 100%);
  box-shadow: 0 2px 12px #b983ff33;
  border-left: 4px solid var(--accent-primary);
  z-index: 2;
}
.model-card.focused {
  outline: 2px solid var(--accent-primary);
  z-index: 2;
}
.model-card:hover {
  background: #3a3f5a;
  box-shadow: 0 2px 8px #b983ff33;
}
.model-card-icon {
  font-size: 1.3rem;
  background: #b983ff18;
  border-radius: 7px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.model-card-info {
  min-width: 0;
  flex: 1;
}
.model-card-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 5px;
}
.model-card-readme-preview {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 6px;
  max-height: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: pre-line;
}
.model-card-meta {
  display: flex;
  gap: 7px;
  margin-top: 2px;
  font-size: 0.9rem;
  color: var(--accent-primary);
}
.selected-indicator {
  color: var(--accent-primary);
  font-weight: bold;
  margin-left: 8px;
}

.main-content {
  flex: 1;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.model-details {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: auto;
  padding: 18px 12px 18px 12px;
}

.model-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 7px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-primary);
}
.model-title-link {
  display: inline-flex;
  align-items: center;
  margin-left: 4px;
  text-decoration: none;
  transition: opacity 0.2s;
  opacity: 0.85;
}
.model-title-link-icon {
  color: var(--accent-primary);
}
.model-subtitle {
  color: #b983ff99;
  font-size: 13px;
  margin-bottom: 13px;
}

.model-params-row {
  display: flex;
  gap: 7px;
  margin-bottom: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.model-meta-architecture {
  background: #6366f1;
  color: #fff;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}
.model-meta-params {
  background: #0ea5e9;
  color: #fff;
  border-radius: 5px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
}

.download-section {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px #0001;
  transition: all 0.25s;
  padding:18px;
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: transparent;
  border-radius: 7px;
  padding: 8px 12px;
  margin-bottom: 6px;
  color: var(--accent-primary);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border: none;
  transition: background 0.18s;
}
.sidebar-header:hover {
  background: #b983ff11;
}

.section-scrollable {
  max-height: 250px;
  overflow-y: auto;
}

.download-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #b983ff11;
  background: #404A60;
  border-radius: 6px;
  margin-bottom: 6px;
  transition: background 0.18s;
  box-shadow: none;
}
.download-item:last-child {
  border-bottom: none;
}
.download-info {
  flex: 1;
}
.download-name {
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.download-size {
  color: var(--accent-primary);
  font-size: 12px;
}
.download-button {
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background 0.18s;
  box-shadow: none;
}
.download-button:hover {
  background: var(--accent-primary-hover);
}
.download-button.downloading {
  background: #f59e0b;
  cursor: not-allowed;
}
.download-button.completed {
  background: #10b981;
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
  color: var(--accent-primary);
  gap: 8px;
  font-weight: 600;
}
.error {
  color: #dc2626;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  padding: 13px;
  background: #7f1d1d;
  border-radius: 6px;
  margin: 13px;
  border: 1px solid #e74c3c88;
}
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-secondary);
  font-size: 15px;
  padding: 24px 0;
  text-align: center;
}
.spinner {
  border: 2px solid #b983ff22;
  border-top: 2px solid var(--accent-primary);
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Overlay y modal */
.gguf-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(20, 20, 30, 0.75);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}
.gguf-modal {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px 0 rgba(60,60,90,0.13);
  max-width: 1100px;
  width: 98vw;
  max-height: 80vh;
  min-height: 500px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding: 0;
  animation: modalPop 0.22s cubic-bezier(.4,1.6,.6,1);
}
.gguf-modal-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: rgba(30,30,40,0.25);
  color: #fff;
  border: 1px solid var(--border-light);
  border-radius: 50%;
  width: 2.2rem;
  height: 2.2rem;
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 10;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s;
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
}
.gguf-modal-close:hover {
  background: rgba(220,38,38,0.45);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modalPop {
  0% { transform: scale(0.96) translateY(30px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* README y scroll */
.readme-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  padding:18px

}
.readme-content {
  flex: 1 1 auto;
  height: 100%;
  min-height: 0;
  max-height: 40vh;
  overflow-y: auto;
  overflow-x: auto;
  background: var(--surface);
  border-radius : 0px !important;
  padding: 0 0.7rem 1rem 0.7rem;
  margin: 7px 7px 0 7px;
}
.readme-content > div {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  overflow: auto;
  box-sizing: border-box;
  display: block;
  word-break: break-word;
  overflow-wrap: break-word;
}
.readme-content > div img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 8px auto;
}
.readme-content > div table {
  max-width: 100%;
  width: 100%;
  overflow-x: auto;
  display: block;
  border-collapse: collapse;
}
.readme-content > div pre,
.readme-content > div code {
  max-width: 100%;
  overflow-x: auto;
  word-break: break-all;
  white-space: pre-wrap;
  box-sizing: border-box;
}
.readme-content > div a {
  word-break: break-all;
  color: var(--accent-primary);
}
.readme-content > div ul,
.readme-content > div ol {
  max-width: 100%;
  overflow-wrap: break-word;
}
.readme-content > div blockquote {
  max-width: 100%;
  border-left: 3px solid var(--accent-primary);
  margin: 8px 0;
  padding-left: 12px;
  color: #b3b3b3;
  background: rgba(99,102,241,0.06);
}

/* Scrollbar moderno */
.models-list::-webkit-scrollbar,
.section-scrollable::-webkit-scrollbar,
.readme-content::-webkit-scrollbar {
  width: 8px;
}
.models-list::-webkit-scrollbar-thumb,
.section-scrollable::-webkit-scrollbar-thumb,
.readme-content::-webkit-scrollbar-thumb {
  background: #b983ff55;
  border-radius: 7px;
}
.models-list::-webkit-scrollbar-track,
.section-scrollable::-webkit-scrollbar-track,
.readme-content::-webkit-scrollbar-track {
  background: #404A60;
  border-radius: 7px;
}

@media (max-width: 900px) {
  .gguf-modal {
    max-width: 99vw;
    min-height: 400px;
    padding: 0;
  }
}
@media (max-width: 600px) {
  .gguf-modal {
    min-width: 0;
    width: 100vw;
    min-height: 0;
  }
  .gguf-modal-close { font-size: 1rem; width: 1.7rem; height: 1.7rem; }
}

@media (max-width: 768px) {
  .lm-studio-app {
    flex-direction: column;
    height: 70vh;
    min-height: 70vh;
  }
  .sidebar {
    width: 100%;
    height: 35vh;
  }
  .main-content {
    height: 35vh;
  }
}

.model-card-repo {
  color: var(--accent-secondary);
  font-size: 12px;
  margin-top: 2px;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(185, 131, 255, 0.10); /* acorde a --accent-primary y --surface-elevated */
  border-radius: 6px;
  padding: 2px 8px;
  display: inline-block;
}