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

body {
  background: #04070d;
  font-family: "Open Sans", "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 100%;
  color: #d6deeb;
  overflow: hidden;
  position: relative;
}

.home-screen,
.drive-screen,
#app {
  position: relative;
  z-index: 1;
}

.screen-hidden {
  display: none !important;
}

.home-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.home-content {
  width: min(960px, 100%);
  padding: 34px;
  border: 1px solid rgba(108, 219, 170, 0.25);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(6, 14, 24, 0.86) 0%, rgba(5, 10, 19, 0.72) 70%, rgba(6, 10, 18, 0.86) 100%);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  animation: homeFade 0.8s ease;
  text-align: center;
}

.home-content h1 {
  font-size: clamp(2rem, 5vw, 3.4rem);
  color: #9af5ce;
  margin-bottom: 10px;
}

.home-subtitle {
  max-width: 58ch;
  color: #b6c3d8;
  margin-bottom: 26px;
  margin-left: auto;
  margin-right: auto;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.module-card {
  border: 1px solid rgba(108, 219, 170, 0.35);
  background: linear-gradient(140deg, rgba(12, 24, 36, 0.95) 0%, rgba(9, 18, 28, 0.9) 100%);
  color: #d6deeb;
  border-radius: 12px;
  padding: 18px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.module-card:hover {
  transform: translateY(-3px);
  border-color: rgba(145, 255, 203, 0.85);
  background: linear-gradient(140deg, rgba(15, 32, 45, 0.97) 0%, rgba(10, 23, 33, 0.94) 100%);
  box-shadow: 0 10px 26px rgba(17, 52, 39, 0.52);
}

.module-card:hover .module-icon svg {
  filter: drop-shadow(0 0 12px rgba(139, 255, 199, 0.62));
  animation: iconPulse 1.35s ease-in-out infinite;
}

.module-icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
}

.module-icon svg {
  width: 100%;
  height: 100%;
  stroke: #9af5ce;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.module-name {
  font-size: 1.1rem;
  color: #9af5ce;
  font-weight: 700;
}

.module-desc {
  color: #a8b5ca;
  font-size: 0.9rem;
}

.btn-home {
  width: 100%;
  margin-bottom: 14px;
  padding: 9px 11px;
  border-radius: 5px;
  border: 1px solid #7fdbca;
  background: transparent;
  color: #7fdbca;
  font-weight: 600;
  cursor: pointer;
}

.drive-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.drive-placeholder {
  width: min(760px, 100%);
  background: rgba(4, 12, 20, 0.88);
  border: 1px solid rgba(126, 219, 201, 0.35);
  border-radius: 12px;
  padding: 24px;
}

.drive-placeholder h2 {
  color: #90f0cb;
  margin-bottom: 12px;
}

.drive-placeholder p {
  color: #b6c3d8;
  margin-bottom: 18px;
}

@keyframes homeFade {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes iconPulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.07);
  }
  100% {
    transform: scale(1);
  }
}

#app {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR (layout desktop por defecto) */
#sidebar {
  width: clamp(400px, 35vw, 520px);
  background: #01111d;
  border-right: 1px solid #1d3b53;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
}

.tips-title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#sidebar h1 {
  font-size: 1.5rem;
  color: #7fdbca;
  margin-bottom: 20px;
  font-weight: 600;
  text-align: center;
}

.tips-title-row h1 {
  margin-bottom: 20px;
}

/* Botones Agregar / Crear (desktop) */
.sidebar-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.logout-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: #ff8b85;
  cursor: pointer;
}

.logout-icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.logout-icon:hover {
  color: #fff;
}

.sidebar-actions button {
  flex: 1;
}

.btn-primary,
.btn-success,
.btn-danger {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 10px;
}

.btn-primary {
  background: #1d3b53;
  color: #7fdbca;
  border: 1px solid #7fdbca;
}

.btn-secondary {
  width: 100%;
  padding: 10px;
  border: 1px solid #5f7e97;
  border-radius: 4px;
  background: transparent;
  color: #b6c3d8;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn-success {
  background: #22a6b3;
  color: #fff;
}

.btn-danger {
  background: #ef5350;
  color: #fff;
}

#form-agregar-container {
  background: #011627;
  padding: 15px;
  border-radius: 6px;
  border: 1px solid #1d3b53;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: #5f7e97;
  margin-bottom: 5px;
}

.form-group input {
  width: 100%;
  padding: 8px;
  background: #01111d;
  border: 1px solid #1d3b53;
  color: #d6deeb;
  border-radius: 4px;
  outline: none;
}

.hidden {
  display: none !important;
}

.login-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(1, 8, 16, 0.8);
}

.login-panel {
  position: relative;
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 28px;
  border: 1px solid #3d837a;
  border-radius: 10px;
  background: #011627;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.login-panel h2 { color: #7fdbca; }
.login-panel p { color: #b6c3d8; line-height: 1.5; }
.login-error { min-height: 1.2em; color: #ff7b72 !important; font-size: 0.9rem; }
.login-google-note { color: #5f7e97 !important; font-size: 0.85rem; text-align: center; }

button:disabled,
.usuario-invitado .btn-accion-tip {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}

.separator {
  border: 0;
  border-top: 1px solid #1d3b53;
  margin: 10px 0 20px 0;
}

/* Header del buscador (común) */
.search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.search-wrapper {
  position: relative;
  flex: 1;
}

#buscador {
  width: 100%;
  padding: 12px 16px;
  background: #011627;
  border: 1px solid #1d3b53;
  border-radius: 6px;
  color: #d6deeb;
  outline: none;
}

.category-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.category-select {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: #011627;
  border: 1px solid #1d3b53;
  border-radius: 6px;
  color: #d6deeb;
  outline: none;
}

.btn-toggle-tips {
  width: 28px;
  height: 28px;
  border: 0;
  flex-shrink: 0;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle-tips-icon {
  width: 10px;
  height: 10px;
  border-top: 2px solid #7fdbca;
  border-left: 2px solid #7fdbca;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.btn-toggle-tips.collapsed .toggle-tips-icon {
  transform: rotate(225deg);
}

/* Resultados (comportamiento desktop por defecto) */
#resultados-container {
  flex: 1;
  overflow-y: auto;
}

#resultados-container.tips-collapsed {
  flex: 0;
  max-height: 0;
  overflow: hidden;
}

#resultados {
  width: 100%;
  border-collapse: collapse;
}

#resultados tbody tr {
  border-bottom: 1px solid #1d3b53;
}

#resultados tbody tr.tip-seleccionado {
  background: linear-gradient(90deg, rgba(127, 219, 202, 0.2), rgba(29, 59, 83, 0.5));
  box-shadow: inset 0 0 0 1px rgba(127, 219, 202, 0.38), 0 4px 14px rgba(4, 14, 24, 0.32);
  backdrop-filter: blur(6px);
}

#resultados tbody td {
  padding: 0 4px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 4px;
}

#resultados tbody td a {
  color: #d6deeb;
  text-decoration: none;
  flex: 1;
  min-width: 0;
  font-size: 14px;
  line-height: 40px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#resultados tbody td a mark {
  background: #7fdbca;
  color: #011627;
  padding: 0px 2px;
  border-radius: 2px;
}

/* Contenido (desktop) */
#contenido {
  flex: 1;
  background: #011627;
  padding: 40px;
  overflow-y: auto;
  color: #d6deeb;
  line-height: 1.7;
}

/* ESTILOS PARA EL BOTÓN DE EDITAR EN LA VISTA */
.view-header {
  display: flex;
  justify-content: flex-end;
  padding: 10px;
  border-bottom: 1px solid #2d3e4f;
  margin-bottom: 15px;
}

.btn-edit-toggle {
  background-color: #2d3e4f;
  color: #addb67;
  border: 1px solid #addb67;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.btn-edit-toggle:hover {
  background-color: #addb67;
  color: #1a2634;
}

.markdown-body {
  padding: 0 20px;
  line-height: 1.6;
}

/* MARKDOWN CONTENT */
#contenido h1 {
  color: #7fdbca;
  font-size: 2rem;
  margin-bottom: 1.5rem;
}

#contenido h2 {
  color: #82aaff;
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

#contenido h3 {
  color: #addb67;
  font-size: 1.2rem;
  margin-top: 1.5rem;
}

#contenido p {
  margin-bottom: 1.2rem;
}

#contenido ul,
#contenido ol {
  margin-left: 25px;
  margin-bottom: 1.5rem;
}

#contenido li {
  margin-bottom: 0.5rem;
}

#contenido hr {
  border: 0;
  border-top: 1px solid #1d3b53;
  margin: 2rem 0;
}

/* BLOQUES DE CÓDIGO */

#contenido pre,
#contenido pre *,
main#contenido pre,
main#contenido pre * {
  all: unset;
}

#contenido pre,
main#contenido pre {
  display: block !important;
  background: #011627 !important;
  padding: 20px !important;
  border-radius: 8px !important;
  border: 1px solid #1d3b53 !important;
  overflow-x: auto !important;
  margin: 1.5rem 0 !important;
  white-space: pre !important;
}

#contenido pre code,
#contenido pre code[class*="language-"],
main#contenido pre code,
main#contenido pre code[class*="language-"] {
  display: block !important;
  font-family: "Consolas", "Monaco", "Courier New", monospace !important;
  font-size: 0.95rem !important;
  color: #d6deeb !important;
  background: transparent !important;
  line-height: 1.6 !important;
  text-shadow: none !important;
  white-space: pre !important;
  word-spacing: normal !important;
  word-break: normal !important;
  tab-size: 4 !important;
}

#contenido pre .hljs-keyword,
#contenido pre .hljs-selector-tag,
#contenido pre .hljs-literal {
  color: #c792ea !important;
}

#contenido pre .hljs-string,
#contenido pre .hljs-attr,
#contenido pre .hljs-template-variable {
  color: #c3e88d !important;
}

#contenido pre .hljs-number,
#contenido pre .hljs-built_in,
#contenido pre .hljs-title.function_ {
  color: #82aaff !important;
}

#contenido pre .hljs-comment,
#contenido pre .hljs-quote {
  color: #637777 !important;
  font-style: italic !important;
}

#contenido pre .hljs-title,
#contenido pre .hljs-section,
#contenido pre .hljs-function {
  color: #82aaff !important;
}

/* Código en línea */
#contenido code:not(pre code) {
  background: #1d3b53 !important;
  color: #ecc48d !important;
  padding: 2px 6px !important;
  border-radius: 4px !important;
  font-family: "Consolas", monospace !important;
  font-size: 0.9rem !important;
}

#contenido blockquote {
  border-left: 4px solid #7fdbca;
  background: #01111d;
  padding: 10px 20px;
  margin: 1.5rem 0;
  font-style: italic;
  color: #5f7e97;
}

#contenido img {
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem 0;
}

/* EDITOR (sólo desktop visualmente, en mobile no se usa) */
.editor-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 20px;
}

.editor-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-title-input {
  background: #01111d;
  border: 1px solid #1d3b53;
  color: #7fdbca;
  font-size: 1.5rem;
  padding: 10px;
  border-radius: 4px;
  outline: none;
}

.editor-category-select {
  width: 100%;
  background: #01111d;
  border: 1px solid #1d3b53;
  color: #d6deeb;
  font-size: 1rem;
  padding: 10px;
  border-radius: 4px;
  outline: none;
}

.categorias-manager {
  max-width: 760px;
  margin: 0 auto;
}

.categorias-manager h2 {
  color: #7fdbca;
  margin-bottom: 18px;
}

.categoria-manager-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #1d3b53;
}

.categoria-manager-nombre {
  flex: 1;
  min-width: 0;
}

.categoria-manager-total {
  color: #5f7e97;
  font-size: 0.85rem;
  white-space: nowrap;
}

.categoria-manager-actions {
  display: inline-flex;
  gap: 8px;
}

.categoria-manager-actions button {
  width: auto;
  margin: 0;
  padding: 7px 10px;
}

.editor-textarea {
  flex: 1;
  background: #01111d;
  border: 1px solid #1d3b53;
  color: #d6deeb;
  font-family: "Consolas", monospace;
  padding: 20px;
  border-radius: 8px;
  resize: none;
  outline: none;
  font-size: 1rem;
  line-height: 1.6;
}

.editor-preview-area {
  flex: 1;
  background: #01111d;
  border: 1px solid #1d3b53;
  padding: 20px;
  border-radius: 8px;
  overflow-y: auto;
}

.editor-actions {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
}

.btn-save {
  background: #addb67;
  color: #011627;
  padding: 10px 25px;
  border: none;
  border-radius: 4px;
  font-weight: 700;
  cursor: pointer;
}

.btn-preview {
  background: #1d3b53;
  color: #7fdbca;
  padding: 10px 25px;
  border: 1px solid #7fdbca;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

.btn-cancel-edit {
  background: transparent;
  color: #ef5350;
  padding: 10px 25px;
  border: 1px solid #ef5350;
  border-radius: 4px;
  font-weight: 600;
  cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 12px;
}

::-webkit-scrollbar-track {
  background: #01111d;
}

::-webkit-scrollbar-thumb {
  background: #1d3b53;
  border-radius: 6px;
}

/* Utilidades visibilidad */
.desktop-only {
  display: block;
}

.mobile-only {
  display: none;
}

/* ====
   LAYOUT MOBILE
   ==== */
@media (max-width: 768px) {
  .home-content {
    padding: 20px;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .module-card {
    padding: 15px;
  }

  body {
    overflow: hidden;
  }

  #app {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid #1d3b53;
    padding: 12px 12px 8px;
    overflow: visible;
  }

  #sidebar h1 {
    font-size: 1.2rem;
    margin-bottom: 8px;
  }

  /* Ocultamos por completo las acciones de edición en mobile */
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: inline-flex;
  }

  /* Botón toggle resultados */
  .toggle-resultados-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid #7fdbca;
    background: #011627;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    cursor: pointer;
  }

  .toggle-resultados-btn .chevron {
    display: block;
    width: 18px;
    height: 18px;
    border-right: 3px solid #7fdbca;
    border-bottom: 3px solid #7fdbca;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
  }

  /* Estado cerrado (flecha hacia abajo) */
  .toggle-resultados-btn.collapsed .chevron {
    transform: rotate(135deg);
  }

  /* En mobile, el contenedor de resultados es un panel que se muestra/oculta */
  #resultados-container {
    max-height: 45vh; /* altura inicial aproximada para emular tu captura */
    overflow-y: auto;
    transition: max-height 0.25s ease;
  }

  #resultados-container.collapsed {
    max-height: 0;
    overflow: hidden;
  }


  /* El contenido ocupa el resto de la pantalla y hace scroll */
  #contenido {
    flex: none;
    height: calc(100vh - 120px); /* se ajusta a la barra superior */
    padding: 16px 16px 100px; /* +padding inferior para ver el final del contenido */
    overflow-y: auto;
  }

  /* Reducir tamaño de títulos SOLO en mobile */
  #contenido h1 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
  }

  #contenido h2 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
  }

  #contenido h3 {
    font-size: 1rem;
    margin-top: 1.25rem;
  }

  #buscador{
    font-size: 1.2em;
  }

  /* Ajustes para el botón de editar en mobile (aunque no se mostrará por desktop-only) */
  .view-header {
    padding: 8px;
    margin-bottom: 10px;
  }

  .btn-edit-toggle {
    padding: 6px 12px;
    font-size: 0.85rem;
  }
}


/* ====
   ESTILOS ADICIONALES - Botones de acción en tabla y vista
   ==== */

/* Botones de acción (editar/eliminar) en cada fila de la tabla */
.tip-acciones {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
  justify-content: flex-end;
}

.tip-categoria-asignada {
  color: #9af5ce;
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.btn-accion-tip {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px !important;
  width: 16px !important;
  height: 16px !important;
  padding: 0;
  border-radius: 4px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: background 0.2s ease;
}

.btn-accion-tip:hover {
  background: #1d3b53;
}

/* Botón eliminar en la vista de contenido */
.btn-delete-toggle {
  background-color: transparent;
  color: #ef5350;
  border: 1px solid #ef5350;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.btn-delete-toggle:hover {
  background-color: #ef5350;
  color: #fff;
}
