/* filepath: /novo/assets/browser.css */

/* Garantir que todo texto em modais seja branco */
#modalBody,
.modal-body {
  color: var(--foreground) !important;
}

#modalBody *,
.modal-body * {
  color: var(--foreground) !important;
}

#modalBody p,
#modalBody div,
#modalBody span,
#modalBody a,
#modalBody li,
#modalBody td {
  color: var(--foreground) !important;
}

.browser-wrapper {
  width: 100%;
  max-width: 800px;
  margin: 0;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 12px 20px;
  border: 1px solid var(--foreground);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
}

.file-item:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.file-item:not(.is-dir):first-of-type {
  margin-top: 30px;
}

.file-item.is-dir {
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}

.file-item.is-dir:last-of-type {
  margin-bottom: 150px !important;
}

/* Espaço entre última seção de diretórios e primeira de arquivos */
.file-item.is-dir + .file-item:not(.is-dir) {
  margin-top: 80px !important;
}

.file-item .icon {
  font-size: 1em;
  margin-right: 12px;
  min-width: 1em;
}

.file-item .name {
  word-break: break-word;
  font-size: 0.95em;
  color: var(--foreground);
  flex: 1;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1000;
  overflow: hidden;
}

.modal-overlay.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: var(--background);
  border: 2px solid var(--accent);
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
}

/* Modal para imagens - versão centrada */
.modal-content.image-modal {
  width: 90%;
  height: auto;
  max-width: 800px;
  max-height: 90vh;
  border-radius: 4px;
}

.modal-content.image-modal .modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex: 1;
  overflow: hidden;
}

.modal-content.image-modal .modal-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.modal-content.image-modal.fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
}

.modal-content.image-modal.fullscreen .modal-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1001;
}

.modal-content.image-modal.fullscreen .modal-body {
  padding: 20px;
  overflow: auto;
  margin-top: 60px;
  width: 100vw;
  height: calc(100vh - 60px);
  display: block;
}

.modal-content.image-modal.fullscreen .modal-body img {
  max-width: none !important;
  max-height: none !important;
  width: auto !important;
  height: auto !important;
  object-fit: none !important;
  display: block;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--accent);
}

.modal-header h2 {
  margin: 0;
  font-size: calc(var(--font-size) * 1.3);
  color: var(--accent);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: calc(var(--font-size) * 1.5);
  cursor: pointer;
  padding: 0;
  width: auto;
  height: auto;
  transition: color 0.2s ease;
  min-width: 30px;
  text-align: center;
}

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

.modal-body {
  overflow-y: auto;
  padding: 20px;
  flex: 1;
  color: var(--foreground) !important;
}

.modal-body * {
  color: var(--foreground) !important;
}

/* Markdown rendering */
.modal-body h1 {
  color: var(--accent) !important;
  margin-top: 20px;
  margin-bottom: 10px;
  font-size: 2em;
}

.modal-body h2 {
  color: var(--accent) !important;
  margin-top: 18px;
  margin-bottom: 10px;
  font-size: 1.6em;
}

.modal-body h3 {
  color: var(--accent) !important;
  margin-top: 16px;
  margin-bottom: 10px;
  font-size: 1.3em;
}

.modal-body {
  color: var(--foreground) !important;
}

.modal-body p {
  margin: 10px 0;
  line-height: 1.6;
  color: var(--foreground) !important;
}

.modal-body code {
  background: color-mix(in srgb, var(--foreground) 10%, transparent);
  padding: 2px 6px;
  border: 1px solid var(--foreground);
  color: var(--foreground) !important;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-body pre {
  background: transparent;
  padding: 0;
  overflow-x: auto;
  border: none;
  margin: 0;
  color: var(--foreground) !important;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}

.modal-body pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--foreground) !important;
}

.modal-body img {
  max-width: 100%;
  border: 2px solid var(--accent);
  margin: 15px 0;
}

.modal-body a {
  color: var(--accent);
  text-decoration: underline;
}

.modal-body a:hover {
  color: var(--foreground);
}

.modal-body ul,
.modal-body ol {
  margin: 10px 0;
  padding-left: 20px;
  color: var(--foreground) !important;
}

.modal-body li {
  color: var(--foreground) !important;
}

/* Scrollbar estilização */
.modal-body::-webkit-scrollbar {
  width: 8px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 0;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--foreground);
}

@media (max-width: 768px) {
  .file-item {
    padding: 10px 15px;
  }

  .file-item .icon {
    font-size: 0.9em;
  }

  .modal-body {
    padding: 15px;
  }

  .modal-content.image-modal {
    width: 95%;
    max-width: 100%;
    max-height: 80vh;
  }

  .modal-header {
    padding: 15px;
  }

  .modal-header h2 {
    font-size: calc(var(--font-size) * 1.1);
  }

  .close-btn {
    font-size: calc(var(--font-size) * 1.2);
    min-width: 25px;
  }

  .modal-content.image-modal .modal-body img {
    max-width: 100%;
    max-height: 100%;
  }

  /* Fullscreen em mobile - desabilitar zoom do pai */
  .modal-overlay.active .modal-content.image-modal.fullscreen {
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 0 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    transform: none !important;
    zoom: 1 !important;
  }

  .modal-overlay.active {
    zoom: 1 !important;
  }

  .modal-content.image-modal.fullscreen .modal-header {
    padding: 12px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1002;
  }

  .modal-content.image-modal.fullscreen .modal-body {
    margin-top: 50px;
    height: calc(100vh - 50px);
    width: 100%;
  }
}

/* Loading animation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.loading-spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
}

