* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    system-ui,
    -apple-system,
    sans-serif;
  display: grid;
  grid-template-columns: minmax(250px, max-content) 1fr;
}

.menu-toggle {
  display: none;
  color: #2c3e50;
}

.sidebar {
  background: #fff;
  padding: 20px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  border-right: 1px solid #ddd;
  overflow-y: hidden;
  min-width: 250px;
  width: max-content;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo {
  width: 40px;
  height: 40px;
}

.header h2 {
  font-size: 18px;
  line-height: 1.2;
  font-weight: 600;
  color: #2c3e50;
}

.upload-section {
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upload-section .upload-button {
  flex: 1;
  min-width: 120px;
}

.upload-button-lod {
  background: #2c5282;
  box-shadow: 0 2px 4px rgba(44, 82, 130, 0.25);
}

.upload-button-lod:hover {
  background: #2b6cb0;
  box-shadow: 0 4px 8px rgba(44, 82, 130, 0.35);
}

.upload-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(139, 0, 0, 0.2);
}

.upload-button:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(139, 0, 0, 0.3);
  transform: translateY(-1px);
}

.upload-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(139, 0, 0, 0.2);
}

.search-section {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.model-count {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
  font-size: 12px;
  color: #666;
}

.model-list {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

.model-list::-webkit-scrollbar {
  width: 8px;
}

.model-list::-webkit-scrollbar-track {
  background: transparent;
}

.model-list::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.model-list::-webkit-scrollbar-thumb:hover {
  background: #999;
}

.example-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin: 4px 0;
  border-radius: 4px;
  color: #2c3e50;
  text-decoration: none;
  transition: background-color 0.2s;
  cursor: pointer;
  user-select: none;
}

.model-type-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-left: 6px;
}

.model-type-badge-lod {
  background: #e6fffa;
  color: #0d9488;
}

.example-link:hover {
  background-color: #ffcccc;
}

.example-link.active {
  background-color: #dc143c;
  color: white;
}

.qr-button,
.edit-button,
.delete-button,
.open-in-new {
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.5;
  padding: 4px;
  border-radius: 4px;
  border: none;
  background: none;
  cursor: pointer;
  color: currentColor;
  width: 24px;
  height: 24px;
}

.qr-button:hover,
.edit-button:hover,
.delete-button:hover,
.open-in-new:hover {
  opacity: 1;
  background: #dc143c;
}

.qr-button svg,
.edit-button svg,
.delete-button svg,
.open-in-new svg {
  stroke-width: 2;
}

.main {
  height: 100dvh;
  overflow: hidden;
}

#example-frame {
  width: 100%;
  height: 100%;
  border: none;
}

@media (hover: none) and (pointer: coarse) {
  body {
    display: block;
    height: 100vh;
    height: 100dvh;
  }

  .menu-toggle {
    display: flex;
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: max(16px, env(safe-area-inset-left));
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 8px;
    z-index: 999;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
    overflow-y: hidden;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 999;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
}

#qr-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  border: none;
  border-radius: 8px;
  background: white;
  margin: 0;
}

#qr-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.qr-modal-content {
  padding: 24px;
  text-align: center;
}

.qr-modal-content p {
  margin-top: 16px;
  color: #2c3e50;
}

#qr-code img {
  display: block;
  margin: 0 auto;
}

/* Ocultar elementos según el modo */
html[data-mode="view"] .upload-section,
html[data-mode="view"] .delete-button,
html[data-mode="view"] .edit-button {
  display: none !important;
}

/* Edit Modal */
#edit-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 0;
  border: none;
  border-radius: 8px;
  background: white;
  margin: 0;
  min-width: 400px;
  max-width: 600px;
}

#edit-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.edit-modal-content {
  padding: 24px;
}

.edit-modal-content h2 {
  margin: 0 0 20px 0;
  font-size: 20px;
  color: #2c3e50;
}

.edit-modal-info {
  margin: 20px 0;
}

.edit-modal-info p {
  margin: 8px 0;
  color: #2c3e50;
}

.placeholder-message {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.placeholder-message svg {
  margin: 0 auto 16px;
  opacity: 0.3;
}

.placeholder-message small {
  font-size: 12px;
  opacity: 0.7;
}

.edit-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid #ddd;
}

.button-secondary {
  padding: 8px 16px;
  background: #666;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.button-secondary:hover {
  background: #555;
}
