/* ===================================================================
   BLITZZIP MN - MODALS & OVERLAYS
   Componentes de modales, lightbox y overlays
   =================================================================== */

/* === Modal Base === */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: var(--space-lg);
  animation: fadeIn var(--transition-base);
}

.modal[hidden] {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-card {
  width: min(900px, 96vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-canvas);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--transition-base);
}

/* Modal de licencia más estrecho */
#license-modal .modal-card {
  width: min(500px, 92vw);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-light);
}

.modal-head h3 {
  margin: 0;
  font-size: var(--font-size-xl);
  color: var(--text-primary);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-md);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--border-light);
}

/* === Path Browser Modal === */
.modal-path-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.modal-path-bar input {
  flex: 1;
}

.browse-roots {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.root-chip {
  border-radius: var(--radius-full);
  padding: 6px 12px;
  font-size: var(--font-size-sm);
}

.browse-list {
  margin-top: var(--space-md);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  min-height: 200px;
  max-height: 400px;
  overflow: auto;
  background: var(--bg-main);
}

.browse-item {
  width: 100%;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-md);
  background: transparent;
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: var(--font-size-base);
}

.browse-item:last-child {
  border-bottom: none;
}

.browse-item:hover,
.browse-item.active {
  background: var(--bg-hover);
}

.browse-item .meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

/* === Browse modal: iconos y mejoras === */
.browse-item { display: flex; align-items: center; gap: 8px; }
.browse-icon { font-size: 16px; flex-shrink: 0; }
.browse-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.browse-empty { color: var(--text-muted); font-size: var(--font-size-sm); padding: 20px; justify-content: center; }
.browse-comment { margin-left: auto; font-size: 11px; color: var(--text-muted); white-space: nowrap; padding-left: 12px; }

/* === Browse modal: roots con stats de disco === */
.root-chip { border-radius: 8px !important; display: flex !important; flex-direction: column; align-items: flex-start !important; padding: 8px 12px !important; font-size: 13px !important; }
.root-label { font-weight: 600; }
.root-disk { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* === Browse modal: pestañas Local / Red === */
.browse-tabs { display: flex; gap: 4px; margin-top: 12px; border-bottom: 2px solid var(--border-light); }
.browse-tab { border: 0; background: none; padding: 8px 14px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.browse-tab:hover { color: var(--text); }
.browse-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* === Browse modal: panel red SMB === */
.smb-connect-bar { display: flex; gap: 8px; margin-top: 10px; }
.smb-connect-bar input { flex: 1; }
.smb-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; margin-top: 8px; min-height: 24px; font-size: 13px; }
.smb-crumb { border: 0; background: none; padding: 2px 6px; cursor: pointer; color: var(--primary); border-radius: 4px; font-size: 13px; }
.smb-crumb:hover { background: var(--bg-hover); }
.smb-sep { color: var(--text-muted); padding: 0 2px; }
.modal-current-path { margin-top: 8px; padding: 6px 10px; background: var(--bg-hover); border-radius: 8px; font-size: 12px; color: var(--primary); word-break: break-all; }

/* === Lightbox Modal === */
.modal.lightbox {
  z-index: var(--z-modal);
  padding: 0;
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: blur(14px);
}

.lightbox-card {
  position: relative;
  width: 100vw;
  height: 100dvh;
  max-height: none;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #020304;
  box-shadow: none;
}

.lightbox-head {
  position: absolute;
  z-index: 3;
  inset: 18px 18px auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--space-sm);
  padding: 0;
  border: 0;
  pointer-events: none;
}

.lightbox-head > * {
  pointer-events: auto;
}

.lightbox-head .btn,
.lightbox-head .pill {
  min-height: 44px;
  color: white;
  background: rgba(10, 14, 18, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

#lightbox-close {
  position: absolute;
  right: 0;
}

.lightbox-body {
  min-height: 0;
  max-height: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: #020304;
  padding: 70px 3vw 20px;
  overflow: hidden;
}

.lightbox-body img {
  width: 100%;
  height: 100%;
  max-width: 94vw;
  max-height: calc(100dvh - 180px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.65);
}

.lightbox-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 20px;
  padding: 14px 24px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(7, 10, 13, 0.92), #050709);
}

.lightbox-name {
  grid-column: 1;
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-lg);
  color: var(--text-primary);
}

.lightbox-path {
  grid-column: 1;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
  font-family: var(--font-mono);
}

.lightbox-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin: 0;
}

/* === Responsive Modals === */
@media (max-width: 768px) {
  .modal {
    padding: var(--space-md);
  }

  .modal-card {
    padding: var(--space-md);
  }

  .lightbox-head {
    inset: 10px 10px auto;
    justify-content: flex-start;
    flex-wrap: nowrap;
  }

  .lightbox-head .pill {
    min-width: 58px;
    justify-content: center;
  }

  .lightbox-body {
    max-height: none;
    padding: 62px 8px 10px;
  }

  .lightbox-body img {
    width: 100%;
    height: 100%;
    max-width: calc(100vw - 16px);
    max-height: calc(100dvh - 230px);
  }

  .browse-list {
    max-height: 300px;
  }
}

/* === Stitch modal treatment === */
.modal {
  backdrop-filter: blur(10px);
}

.modal-card {
  background: linear-gradient(145deg, #151c23, #0d1217);
  border-color: var(--border-color);
  border-top: 2px solid var(--brand-primary);
}

.modal-head {
  position: sticky;
  top: calc(var(--space-lg) * -1);
  z-index: 2;
  background: #131a21;
}

.browse-list,
.lightbox-body {
  background: #080c10;
  border-color: var(--border-color);
}

.browse-item {
  color: var(--text-primary);
}

.browse-item:hover,
.browse-item.active {
  background: #1a2630;
}

@media (max-width: 480px) {
  .modal {
    padding: var(--space-sm);
  }

  .modal-card {
    width: 98vw;
    padding: var(--space-sm);
  }

  .modal-head,
  .modal-foot,
  .lightbox-head,
  .lightbox-meta {
    gap: var(--space-xs);
  }

  .lightbox-head {
    padding: 0;
  }

  .lightbox-meta {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .lightbox-name {
    font-size: var(--font-size-base);
  }

  .lightbox-path {
    font-size: var(--font-size-xs);
  }

  .lightbox-actions {
    grid-column: 1;
    grid-row: auto;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .lightbox-actions .btn {
    width: 100%;
  }

  .modal-path-bar {
    flex-wrap: wrap;
  }

  .browse-item {
    padding: var(--space-sm);
  }
}


.settings-card {
  width: min(680px, 94vw);
}

.avatar-editor-card {
  width: min(520px, 94vw);
}

.avatar-editor-help {
  margin-bottom: 14px;
  text-align: center;
}

.avatar-editor-stage {
  width: min(320px, 78vw);
  aspect-ratio: 1;
  margin: 0 auto;
  border: 1px dashed rgba(85, 169, 208, 0.55);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #080b0f;
  touch-action: none;
}

#avatar-editor-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#avatar-editor-canvas:active {
  cursor: grabbing;
}

.avatar-zoom-control {
  width: min(320px, 78vw);
  margin: 16px auto 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.settings-grid .toggle {
  grid-column: 1 / -1;
}

#settings-runtime-info {
  margin-top: var(--space-md);
}

@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
