/* =========================================================
   RetroNotes — Estilos principales
   Estética Windows 95/98 con fuentes Pixelify Sans e IBM Plex Mono
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Pixelify+Sans:wght@400;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* === RESET Y VARIABLES === */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --win-title:          #000080;
  --win-title-inactive: #808080;
  --win-face:           #c0c0c0;
  --win-light:          #ffffff;
  --win-shadow:         #808080;
  --win-dark:           #404040;
  --win-black:          #000000;
  --win-highlight:      #000080;
  --win-highlight-text: #ffffff;
  --win-btn-face:       #c0c0c0;
  --editor-bg:          #ffffff;
  --editor-text:        #000000;
  --scrollbar:          #c0c0c0;
}

body {
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  background: var(--win-face);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  cursor: default;
}

/* === BORDES RAISED / SUNKEN (estilo Win95) === */
.raised {
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.sunken {
  border-top:    2px solid var(--win-dark);
  border-left:   2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-light);
  border-right:  2px solid var(--win-light);
}

/* === VENTANA / CONTENEDOR DE LA APP === */
.window {
  flex: 1;
  background: var(--win-face);
  padding: 3px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* === BARRA DE TÍTULO === */
.window-title {
  background: linear-gradient(90deg, var(--win-title), #1084d0);
  color: white;
  font-family: 'Pixelify Sans', monospace;
  font-weight: 700;
  font-size: 13px;
  padding: 3px 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: default;
  letter-spacing: 0.5px;
}
.window-title .title-icon {
  width: 16px; height: 16px;
  image-rendering: pixelated;
  flex-shrink: 0;
}
.window-title span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Los title-btn solo se usan en los diálogos */
.title-buttons { display: flex; gap: 2px; flex-shrink: 0; }
.title-btn {
  width: 18px; height: 16px;
  background: var(--win-btn-face);
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: 'Pixelify Sans', monospace;
  color: #000;
  line-height: 1;
  padding-bottom: 1px;
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.title-btn:active {
  border-top-color:    var(--win-dark);
  border-left-color:   var(--win-dark);
  border-bottom-color: var(--win-light);
  border-right-color:  var(--win-light);
}

/* === BARRA DE MENÚ === */
.menu-bar {
  display: flex;
  gap: 0;
  padding: 2px 2px;
  background: var(--win-face);
  font-size: 12px;
}
.menu-item {
  padding: 2px 8px;
  cursor: pointer;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11.5px;
  position: relative;
}
.menu-item:hover,
.menu-item:focus { background: var(--win-highlight); color: var(--win-highlight-text); outline: none; }
.menu-item .underline { text-decoration: underline; }

.menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--win-face);
  min-width: 200px;
  z-index: 100;
  padding: 3px;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.3);
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.menu-item:hover .menu-dropdown,
.menu-item:focus-within .menu-dropdown { display: block; }

.menu-dropdown .dropdown-item {
  padding: 3px 24px 3px 8px;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  white-space: nowrap;
  align-items: center;
}
.menu-dropdown .dropdown-item:hover,
.menu-dropdown .dropdown-item:focus {
  background: var(--win-highlight);
  color: var(--win-highlight-text);
  outline: none;
}
.menu-dropdown .dropdown-item.disabled {
  color: var(--win-shadow);
  cursor: default;
}
.menu-dropdown .dropdown-item.disabled:hover {
  background: transparent;
  color: var(--win-shadow);
}
.menu-dropdown .separator {
  height: 1px;
  margin: 3px 4px;
  border-top: 1px solid var(--win-shadow);
  border-bottom: 1px solid var(--win-light);
}
.dropdown-shortcut { color: var(--win-shadow); font-size: 10px; }
.dropdown-item:hover .dropdown-shortcut { color: var(--win-highlight-text); }

/* === ÁREA DEL EDITOR === */
.editor-container {
  flex: 1;
  margin: 0 2px 2px 2px;
  background: var(--editor-bg);
  display: flex;
  position: relative;
  overflow: hidden;
}
.editor {
  flex: 1;
  background: var(--editor-bg);
  color: var(--editor-text);
  border: none;
  outline: none;
  resize: none;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  font-size: 14px;
  padding: 4px 6px;
  line-height: 1.5;
  overflow-y: auto;
  tab-size: 4;
  user-select: text;
  cursor: text;
}
.editor::selection {
  background: var(--win-highlight);
  color: var(--win-highlight-text);
}
.editor::-webkit-scrollbar { width: 16px; }
.editor::-webkit-scrollbar-track {
  background: repeating-conic-gradient(var(--win-face) 0% 25%, #fff 0% 50%) 50% / 2px 2px;
}
.editor::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}

/* === BARRA DE ESTADO === */
.status-bar {
  display: flex;
  gap: 2px;
  padding: 2px 3px;
  font-size: 11px;
  background: var(--win-face);
}
.status-section {
  padding: 1px 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-section:nth-child(1) { flex: 3; min-width: 80px; }
.status-section:nth-child(2) { flex: 2; min-width: 90px; }
.status-section:nth-child(3) { flex: 2; min-width: 110px; }
.status-section:nth-child(4) { flex: 3; min-width: 100px; }

/* === SIDEBAR (panel de notas) === */
.sidebar {
  width: 200px;
  background: var(--win-face);
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--win-dark);
  flex-shrink: 0;
}
.sidebar-title {
  font-family: 'Pixelify Sans', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  background: var(--win-face);
  border-bottom: 1px solid var(--win-shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Campo de búsqueda (estilo Win95 sunken) */
.search-box {
  width: calc(100% - 8px);
  margin: 4px;
  padding: 2px 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  background: var(--editor-bg);
  color: var(--editor-text);
  border-top:    2px solid var(--win-dark);
  border-left:   2px solid var(--win-dark);
  border-bottom: 2px solid var(--win-light);
  border-right:  2px solid var(--win-light);
  outline: none;
  user-select: text;
  cursor: text;
}
.search-box::placeholder { color: #808080; }
.search-box:focus {
  outline: 1px dotted var(--win-dark);
  outline-offset: -2px;
}

/* Lista de notas */
.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px;
}
.notes-list::-webkit-scrollbar { width: 16px; }
.notes-list::-webkit-scrollbar-track {
  background: repeating-conic-gradient(var(--win-face) 0% 25%, #fff 0% 50%) 50% / 2px 2px;
}
.notes-list::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}

/* Entrada de nota */
.note-entry {
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.note-entry:hover { background: #d4d0c8; }
.note-entry.active {
  background: var(--win-highlight);
  color: var(--win-highlight-text);
}
.note-entry:focus { outline: 1px dotted var(--win-dark); }
.note-entry.active:focus { outline: 1px dotted var(--win-light); }

/* Encabezado de nota (título + botón eliminar) */
.note-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.note-title-text {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.note-date {
  font-size: 9px;
  color: var(--win-shadow);
}
.note-entry.active .note-date { color: #aac; }

/* Botón eliminar en nota (oculto por defecto, aparece en hover) */
.note-delete-btn {
  background: var(--win-btn-face);
  border-top:    1px solid var(--win-light);
  border-left:   1px solid var(--win-light);
  border-bottom: 1px solid var(--win-dark);
  border-right:  1px solid var(--win-dark);
  font-size: 9px;
  width: 14px; height: 14px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  font-family: 'Pixelify Sans', monospace;
  color: #000;
}
.note-delete-btn:active {
  border-top-color:    var(--win-dark);
  border-left-color:   var(--win-dark);
  border-bottom-color: var(--win-light);
  border-right-color:  var(--win-light);
}
.note-entry:hover .note-delete-btn { display: flex; }
.note-entry.active .note-delete-btn { display: flex; background: var(--win-highlight); color: white; border-color: #4444aa; }
.note-entry.active .note-delete-btn:hover { background: #cc0000; border-color: #ff6666 #880000 #880000 #ff6666; }

/* Botón nueva nota */
.new-note-btn {
  font-family: 'Pixelify Sans', monospace;
  font-size: 11px;
  background: var(--win-btn-face);
  cursor: pointer;
  padding: 3px 8px;
  margin: 3px;
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.new-note-btn:active {
  border-top-color:    var(--win-dark);
  border-left-color:   var(--win-dark);
  border-bottom-color: var(--win-light);
  border-right-color:  var(--win-light);
}
.new-note-btn:focus { outline: 1px dotted var(--win-dark); outline-offset: -3px; }

/* === DIÁLOGOS === */
.dialog-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.15);
  z-index: 999;
  align-items: center;
  justify-content: center;
}
.dialog-overlay.active { display: flex; }

.dialog {
  background: var(--win-face);
  padding: 3px;
  min-width: 300px;
  max-width: 90vw;
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.dialog .window-title { cursor: default; }

.dialog-body {
  padding: 16px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  font-size: 12px;
  line-height: 1.5;
}
.dialog-icon { font-size: 32px; flex-shrink: 0; }
.dialog-buttons {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 16px 12px;
  flex-wrap: wrap;
}
.dialog-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 4px 24px;
  cursor: pointer;
  background: var(--win-btn-face);
  min-width: 72px;
  text-align: center;
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.dialog-btn:active {
  border-top-color:    var(--win-dark);
  border-left-color:   var(--win-dark);
  border-bottom-color: var(--win-light);
  border-right-color:  var(--win-light);
}
.dialog-btn:focus { outline: 1px dotted var(--win-dark); outline-offset: -4px; }

/* === MENÚ CONTEXTUAL === */
.context-menu {
  position: fixed;
  background: var(--win-face);
  padding: 3px;
  min-width: 160px;
  z-index: 500;
  display: none;
  box-shadow: 2px 2px 0px rgba(0,0,0,0.3);
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.context-menu.active { display: block; }
.context-menu .dropdown-item {
  padding: 3px 24px 3px 8px;
  font-size: 11px;
  cursor: pointer;
}
.context-menu .dropdown-item:hover {
  background: var(--win-highlight);
  color: white;
}

/* === BARRA DE HERRAMIENTAS MÓVIL (solo visible en pantallas pequeñas) === */
.mobile-toolbar {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  background: var(--win-face);
  border-bottom: 1px solid var(--win-shadow);
}

.hamburger-btn {
  font-family: 'Pixelify Sans', monospace;
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
  background: var(--win-btn-face);
  white-space: nowrap;
  border-top:    2px solid var(--win-light);
  border-left:   2px solid var(--win-light);
  border-bottom: 2px solid var(--win-dark);
  border-right:  2px solid var(--win-dark);
}
.hamburger-btn:active {
  border-top-color:    var(--win-dark);
  border-left-color:   var(--win-dark);
  border-bottom-color: var(--win-light);
  border-right-color:  var(--win-light);
}

.mobile-note-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #000;
}

/* Overlay oscuro para el sidebar en móvil */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 40;
}
.sidebar-overlay.active { display: block; }

/* === RESPONSIVE: MÓVIL (< 768px) === */
@media (max-width: 767px) {
  /* Mostrar barra de herramientas móvil */
  .mobile-toolbar { display: flex; }

  /* Sidebar: posición fija como drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: -210px;
    height: 100%;
    width: 200px;
    z-index: 50;
    transition: left 0.2s ease;
    box-shadow: 2px 0 4px rgba(0,0,0,0.3);
  }
  .sidebar.mobile-open {
    left: 0;
  }

  /* Barra de estado: menos secciones visibles */
  .status-section:nth-child(4) { display: none; }
  .status-section:nth-child(3) { display: none; }

  /* Menú más táctil */
  .menu-item { padding: 4px 8px; }
  .dropdown-item { padding: 6px 24px 6px 8px !important; }
}

/* === ACCESIBILIDAD: FOCO VISIBLE === */
:focus-visible {
  outline: 2px dotted var(--win-dark);
  outline-offset: 1px;
}

/* Ocultar el outline por defecto en elementos que tienen su propio estilo de foco */
button:focus:not(:focus-visible),
.menu-item:focus:not(:focus-visible),
.note-entry:focus:not(:focus-visible) {
  outline: none;
}

/* Mensaje "sin notas" en la lista */
.notes-empty-msg {
  padding: 8px;
  font-size: 11px;
  color: var(--win-shadow);
  text-align: center;
  font-style: italic;
}
