/* ==========================================================================
   LAB 95 — windows.css
   Gerenciador de janelas: moldura, barra de título, botões, redimensionamento,
   barras de menu e de status, caixas de diálogo modais.
   ========================================================================== */

.window {
  position: absolute;
  container-type: inline-size;
  min-width: min(var(--window-min-width, 160px), calc(100% - 8px));
  min-height: min(var(--window-min-height, 120px), calc(100% - 8px));
  max-width: calc(100% - 4px);
  max-height: calc(100% - 4px);
  display: flex;
  flex-direction: column;
  background: var(--silver);
  padding: 2px;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  box-shadow: 1px 1px #000;
  outline: 1px solid var(--silver-dark);
  outline-offset: -3px;
  overflow: hidden;
}

.window.maximized {
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  max-height: none;
}

.window.dragging, .window.resizing { opacity: .95; }

.window-center-hint {
  position: absolute;
  inset: 0;
  border: 2px dashed #fff;
  background: #00008040;
  pointer-events: none;
  z-index: 5;
}

/* ------------------------------- Barra de título ------------------------------- */
.titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 2px 3px;
  height: 21px;
  min-height: 21px;
  font-size: 12px;
  background: var(--silver-dark);
  color: #d4d0c8;
  cursor: default;
  touch-action: none;
  flex-shrink: 0;
}
.window.active .titlebar { background: var(--navy); color: #fff; }

.titlebar .window-title {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}
.titlebar .window-title svg, .titlebar .window-title .classic-icon { width: 16px; height: 16px; flex-shrink: 0; image-rendering: pixelated; }
.titlebar .window-title b { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.window-controls { display: flex; gap: 2px; flex-shrink: 0; }
.titlebar button {
  width: 17px;
  height: 15px;
  min-width: 17px;
  min-height: 15px;
  padding: 0;
  margin: 0;
  font: bold 12px Arial;
  line-height: 10px;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.titlebar [data-close] { margin-left: 2px; }
.titlebar .museum-history-button {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  height: 15px;
  min-height: 15px;
  padding: 0 4px;
  font: 10px var(--font-ui);
  white-space: nowrap;
}

@container (max-width: 310px) {
  .titlebar .museum-history-button { padding: 0 2px; font-size: 9px; }
  .titlebar .window-title { gap: 2px; }
}

/* ---------------------------------- Conteúdo ---------------------------------- */
.content {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--silver);
  padding: 10px;
  overflow: auto;
}

/* Limites de largura para filhos em layouts flex; evita que listas, tabelas e
   corpos de chat empurrem os controles para fora ao reduzir uma janela. */
.content > *, .app-body > *, .split > *, .row > *, .toolbar > * { min-width: 0; }
.content :where(img, canvas, video, table) { max-width: 100%; }
.content :where(pre, code, p, h1, h2, h3, label, small) { overflow-wrap: anywhere; }
.content :where(input, select, textarea) { max-width: 100%; }

.content > h2:first-child { margin-top: 0; }
.content > p:first-child { margin-top: 0; }

/* Conteúdo "chanfrado": sem padding, com corpo e barra de status próprios */
.content.flat-content { padding: 0; }
.flat-content > .app-body { padding: 10px; overflow: auto; flex: 1; min-width: 0; min-height: 0; }
.flat-content > .statusbar { margin: 0; padding: 3px; }

/* ------------------------------ Barra de menu/app ------------------------------ */
.menubar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 1px 2px;
  border-bottom: 1px solid var(--silver-dark);
  flex-wrap: wrap;
  min-height: 23px;
  flex-shrink: 0;
}
.menubar > span { min-width: 0; overflow-wrap: anywhere; }
.menubar button,
.menubar .menu-label {
  border: 0;
  box-shadow: none;
  background: transparent;
  padding: 3px 7px;
  margin: 0;
  min-height: 20px;
}
.menubar button:hover,
.menubar button:focus-visible,
.menubar button.open { background: navy; color: #fff; outline: none; }

/* Submenu suspenso do aplicativo */
.app-submenu {
  position: absolute;
  min-width: 150px;
  padding: 2px;
  z-index: 20;
  box-shadow: 2px 2px #0005;
}

/* -------------------------------- Barra de status ------------------------------ */
.statusbar {
  display: flex;
  gap: 3px;
  padding: 3px 1px 0;
  margin-top: 6px;
  color: #222;
  font-size: 11px;
  flex-shrink: 0;
}
.statusbar > span,
.statusbar > div {
  border: 1px solid;
  border-color: var(--bevel-thin-in);
  padding: 2px 5px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------- Alças de redimensionamento -------------------------- */
.window > .resize-handle { position: absolute; z-index: 6; touch-action: none; }
.window > .rh-n  { top: -2px; left: 6px; right: 6px; height: 6px; cursor: ns-resize; }
.window > .rh-s  { bottom: -2px; left: 6px; right: 6px; height: 6px; cursor: ns-resize; }
.window > .rh-w  { left: -2px; top: 6px; bottom: 6px; width: 6px; cursor: ew-resize; }
.window > .rh-e  { right: -2px; top: 6px; bottom: 6px; width: 6px; cursor: ew-resize; }
.window > .rh-nw { top: -2px; left: -2px; width: 12px; height: 12px; cursor: nwse-resize; }
.window > .rh-ne { top: -2px; right: -2px; width: 12px; height: 12px; cursor: nesw-resize; }
.window > .rh-sw { bottom: -2px; left: -2px; width: 12px; height: 12px; cursor: nesw-resize; }
.window > .rh-se { bottom: -2px; right: -2px; width: 12px; height: 12px; cursor: nwse-resize; }
.window.maximized > .resize-handle { display: none; }

/* ------------------------------ Diálogos modais -------------------------------- */
.dialog-window { min-width: min(260px, calc(100% - 8px)); }
.dialog-body {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 6px 4px;
}
.dialog-body .dialog-text { white-space: pre-line; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.dialog-body input[type="text"] { width: 100%; margin-top: 6px; }

.dialog-icon {
  font: bold 27px Georgia, "Times New Roman", serif;
  width: 38px;
  height: 38px;
  border-radius: 0;
  border: 1px solid #000;
  background: var(--navy);
  color: #fff;
  text-align: center;
  line-height: 38px;
  flex-shrink: 0;
  user-select: none;
}
.dialog-icon.warning { background: #f7e545; color: #000; border: 1px solid #000; }
.dialog-icon.error { background: #c00; }
.dialog-icon.question { background: var(--navy); }
.dialog-icon.info { background: var(--navy); }
.dialog-icon.ok { background: #006400; }

/* Impede interação com o resto do sistema enquanto um diálogo modal está aberto */
body.modal-open #desktop > .window:not(.dialog-window) { pointer-events: none; }
body.modal-open #taskbar { pointer-events: none; }
body.modal-open .window.dialog-window { z-index: 10050; }

/* Lista de itens selecionáveis (arquivos, contatos, resultados) */
.listview {
  background: #fff;
  flex: 1;
  overflow: auto;
  padding: 3px;
  border: 2px solid;
  border-color: var(--bevel-in);
  min-height: 0;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0 !important;
  box-shadow: none !important;
  background: #fff !important;
  width: 100%;
  text-align: left;
  padding: 2px 4px !important;
  margin: 0 !important;
  min-height: 22px !important;
  color: #000;
}
.file-row svg, .file-row .classic-icon { width: 16px; height: 16px; flex-shrink: 0; image-rendering: pixelated; }
.file-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.file-row small { font-size: 10px; color: #666; flex-shrink: 0; }
.file-row:hover, .file-row:focus-visible { background: navy !important; color: #fff; outline: none; }
.file-row:hover small, .file-row:focus-visible small { color: #fff; }

/* Janela de Buscar/Ajuda/Propriedades: faixa superior com ícone grande */
.app-banner {
  display: flex;
  gap: 15px;
  align-items: center;
  margin: 6px 0 12px;
}
.app-banner > svg, .app-banner > .classic-icon { width: 48px; height: 48px; flex-shrink: 0; image-rendering: pixelated; }
.app-banner > .dialog-icon { width: 48px; height: 48px; line-height: 48px; font-size: 32px; }
.app-banner h2 { margin: 0 0 5px; }
.app-banner p { margin: 0; }

.split { min-width: 0; min-height: 0; }
.split > .sidebar { max-width: 38%; overflow: auto; }
.split > .listview, .split > .chatlog, .split > .mail-list { min-width: 0; min-height: 0; }

@container (max-width: 440px) {
  .split:has(> .sidebar) { flex-direction: column; }
  .split > .sidebar { width: auto !important; max-width: none; max-height: 110px; border-right: 0; border-bottom: 2px groove #fff; }
  .split > .listview[style*="flex: 0 0 220px"] { flex: 1 1 auto !important; }
  .museum-history dl { grid-template-columns: 1fr; }
  .museum-history dd { margin-bottom: 4px; }
}

@container (max-width: 650px) {
  .content { padding: 7px; }
  .titlebar { height: 24px; min-height: 24px; }
  .titlebar button { height: 19px; width: 21px; min-width: 21px; }
  .sidebar { width: 105px; padding: 4px; }
}

/* Fallback para navegadores sem consultas de container. */
@media (max-width: 440px) {
  .split:has(> .sidebar) { flex-direction: column; }
  .split > .sidebar { width: auto !important; max-width: none; max-height: 110px; border-right: 0; border-bottom: 2px groove #fff; }
  .split > .listview[style*="flex: 0 0 220px"] { flex: 1 1 auto !important; }
  .museum-history dl { grid-template-columns: 1fr; }
  .museum-history dd { margin-bottom: 4px; }
}
@media (max-width: 650px) {
  .content { padding: 7px; }
  .titlebar { height: 24px; min-height: 24px; }
  .titlebar button { height: 19px; width: 21px; min-width: 21px; }
  .sidebar { width: 105px; padding: 4px; }
}
