*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary-color: #1abc9c;
  --primary-hover: #16a085;
  --accent-color: #1abc9c;
  --bg-dark: #1f1f1f;
  --card-bg: rgba(44, 44, 44, 0.85);
  --card-border: rgba(255, 255, 255, 0.12);
  --glass-glow: rgba(26, 188, 156, 0.2);
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden;
  background-color: var(--bg-dark) !important;
  background: url('../img/Fondo.webp') no-repeat center center fixed;
  background-size: cover;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  color: var(--text-main); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

#bg-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background-color: transparent; z-index: 9999; opacity: 0; pointer-events: none;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }
* { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.15) transparent; }

body { display: flex; flex-direction: column; }

header {
  background: rgba(31, 31, 31, 0.85); height: 52px; min-height: 52px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  border-bottom: 1px solid var(--card-border); box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

header h1 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-main); letter-spacing: 0.5px; }

header > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

header a,
#config-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  transition: var(--transition);
}

header a:hover,
#config-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.header-icon,
.config-icon {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  cursor: pointer;
  transition: var(--transition);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

header a:hover .header-icon {
  transform: scale(1.1);
}

#config-btn:hover .config-icon {
  transform: rotate(45deg);
}

footer {
  background: rgba(31, 31, 31, 0.85); border-top: 1px solid var(--card-border);
  flex: 0 0 28px; display: flex; align-items: center; justify-content: center;
}
footer p { margin: 0; font-size: 12px; color: var(--text-muted); }

.container {
  flex: 1 1 auto; display: flex; min-height: 0; min-width: 0;
  padding: 12px; gap: 12px; overflow: hidden;
}

aside.sidebar-left {
  width: 260px; background: var(--card-bg); padding: 16px; flex-shrink: 0;
  border-radius: var(--radius-lg); border: 1px solid var(--card-border);
  display: flex; flex-direction: column; gap: 16px; overflow: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.search-bar input {
  display: block; width: 100%; padding: 10px 14px; border: 1px solid var(--card-border);
  border-radius: var(--radius-md); background: rgba(0, 0, 0, 0.35); color: var(--text-main);
  outline: none; font-size: 14px; transition: var(--transition);
}
.search-bar input:focus {
  border-color: var(--primary-color); box-shadow: 0 0 12px var(--glass-glow); background: rgba(0, 0, 0, 0.5);
}

nav ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }

nav button.tab-button {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px;
  border-radius: var(--radius-md); background: rgba(255, 255, 255, 0.04); color: var(--text-main);
  cursor: pointer; border: 1px solid var(--card-border); text-align: left;
  transition: var(--transition); font-size: 14px; font-weight: 500;
  transform: translateX(0);
}
nav button.tab-button:hover {
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-main); transform: translateX(3px);
}
nav button.tab-button.active {
  background: rgba(26, 188, 156, 0.18); border-color: var(--primary-color);
  color: var(--text-main); font-weight: 500; box-shadow: 0 0 15px rgba(26, 188, 156, 0.15);
}

main {
  flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0;
  background: var(--card-bg); color: var(--text-main); overflow: hidden;
  padding: 20px; border-radius: var(--radius-lg); border: 1px solid var(--card-border);
  position: relative; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.tab-content { flex: 1 1 auto; display: none; flex-direction: column; min-height: 0; overflow: hidden; }
.tab-content.active { display: flex; }
.tab-content h2 { color: var(--text-main); margin: 0 0 16px 0; font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }

.project-list { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

.list-container { flex: 1 1 auto; overflow-y: auto; min-height: 0; padding: 4px 6px 12px 2px; }

.list-container ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.project-item {
  display: flex; align-items: center; width: 100%; border: 1px solid var(--card-border);
  border-radius: var(--radius-md); cursor: pointer; text-align: left; background: rgba(255, 255, 255, 0.04);
  height: 46px; padding: 4px 12px 4px 4px; overflow: hidden; transition: var(--transition);
}
.project-item:hover {
  background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); transform: translateX(3px);
}
.project-item.selected {
  background: rgba(26, 188, 156, 0.18); border-color: var(--primary-color); box-shadow: 0 0 15px rgba(26, 188, 156, 0.15);
}

.item-icon { width: 36px; height: 36px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }

.item-text {
  flex: 1; padding-left: 12px; color: var(--text-main); font-size: 14px;
  font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.list-container ul.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 12px; }

.list-container ul.grid .project-item {
  width: 100%; height: auto; aspect-ratio: 1; margin: 0; padding: 10px;
  border-radius: var(--radius-lg); display: flex; flex-direction: column; align-items: center;
  justify-content: center; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--card-border);
  transition: var(--transition); position: relative;
}
.list-container ul.grid .project-item:hover {
  transform: translateY(-4px); background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25); box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.list-container ul.grid .project-item.selected {
  background: rgba(26, 188, 156, 0.2); border-color: var(--primary-color);
  box-shadow: 0 0 20px var(--glass-glow); transform: translateY(-2px);
}
.list-container ul.grid .item-icon {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: var(--radius-md);
}
.list-container ul.grid .item-text { display: none; }

.download-section { margin-top: 16px; display: flex; gap: 12px; width: 100%; }
.download-section-btn {
  background: #1abc9c; height: 42px; display: flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--radius-md); cursor: pointer; color: #fff; font-weight: 600;
  font-size: 14px; flex: 1; letter-spacing: 0.3px; transition: var(--transition);
  box-shadow: 0 4px 15px rgba(26, 188, 156, 0.25);
}
.download-section-btn:hover {
  background: #16a085; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26, 188, 156, 0.4);
}

.emoji { width: 1.1em; height: 1.1em; vertical-align: sub; }

#config-panel {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -45%) scale(0.95);
  background: rgba(31, 31, 31, 0.95); padding: 24px; border-radius: var(--radius-lg);
  border: 1px solid var(--card-border); z-index: 10000; color: var(--text-main);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); min-width: 320px; opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1); display: none; pointer-events: none;
}
#config-panel.visible {
  display: block; opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1);
}

.config-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.config-header h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-main); }
.config-header button.close {
  background: rgba(255, 255, 255, 0.05); border: none; color: var(--text-muted);
  width: 28px; height: 28px; border-radius: 50%; font-size: 14px; cursor: pointer; transition: var(--transition);
}
.config-header button.close:hover { background: rgba(239, 68, 68, 0.2); color: #ef4444; }

.config-separator { height: 1px; background: var(--card-border); margin-bottom: 16px; }

.switch-label { display: flex; align-items: center; justify-content: space-between; cursor: pointer; font-size: 14px; padding: 6px 0; color: var(--text-main); }
.switch-label input { display: none; }
.switch-slider {
  position: relative; width: 44px; height: 22px; background: rgba(255, 255, 255, 0.1);
  border-radius: 20px; transition: var(--transition); border: 1px solid var(--card-border);
}
.switch-slider::before {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; transition: var(--transition);
}
.switch-label input:checked + .switch-slider { background: var(--primary-color); border-color: var(--primary-color); }
.switch-label input:checked + .switch-slider::before { transform: translateX(22px); background: #fff; }

@media (max-width: 768px) {
  .container { flex-direction: column; padding: 8px; }
  aside.sidebar-left { width: 100%; order: 2; padding: 12px; overflow: visible; }
  main { order: 1; width: 100%; padding: 14px; }
  nav ul { 
    flex-direction: row; 
    overflow-x: auto; 
    overflow-y: visible;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  nav button.tab-button {
    white-space: nowrap;
    width: auto;
    transform: translateY(0);
  }
  nav button.tab-button:hover {
    transform: translateY(-3px);
  }
}
