/* -------------------------------------------------------------------------
   CONFIGURACIÓN GLOBAL Y RESET
   ------------------------------------------------------------------------- */
html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'DM Sans', sans-serif;
  box-sizing: border-box;
}

/* -------------------------------------------------------------------------
   CONTENEDOR DE LA HOJA DE CÁLCULO
   ------------------------------------------------------------------------- */
.sheet-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.sheet-scroll {
  flex: 1;
  overflow: auto;
  position: relative;
}

/* -------------------------------------------------------------------------
   ESTILOS DE LA TABLA Y CELDAS
   ------------------------------------------------------------------------- */
table {
  border-collapse: collapse;
  table-layout: fixed;
  width: auto;
}

th,
td {
  border: 1px solid #d1d5db;
  padding: 0;
  height: 28px;
  width: 100px;
  position: relative;
  overflow: hidden;
}

th {
  background: #f0f1f4;
  font-size: 12px;
  font-weight: 600;
  color: #4a5068;
  position: sticky;
  top: 0;
  z-index: 2;
  user-select: none;
}

.row-header {
  background: #f0f1f4;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  width: 50px;
  min-width: 50px;
  max-width: 50px;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 1;
}

.corner {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 3;
  background: #e5e7eb;
}

/* -------------------------------------------------------------------------
   REDIMENSIONAMIENTO (RESIZE)
   ------------------------------------------------------------------------- */
.col-resizer {
  position: absolute;
  right: 0;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
}

.col-resizer:hover,
.col-resizer.resizing {
  background: #3b82f6;
  opacity: 0.5;
}

.row-resizer {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 8px;
  cursor: row-resize;
  z-index: 10;
  background: transparent;
}

.row-resizer:hover,
.row-resizer.resizing {
  background: #3b82f6;
  opacity: 0.5;
}

/* -------------------------------------------------------------------------
   INPUTS DENTRO DE CELDAS
   ------------------------------------------------------------------------- */
td input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 2px 6px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  background: transparent;
}

td input:focus {
  background: #eff6ff;
}

td.selected {
  background: #dbeafe !important;
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
  z-index: 1;
  position: relative;
}

td.cell-color {
  background: var(--cell-bg, transparent) !important;
}

th input {
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  padding: 2px 6px;
  font-size: 12px;
  font-weight: 600;
  background: transparent;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
  color: #4a5068;
}

/* -------------------------------------------------------------------------
   BARRA DE NAVEGACIÓN (NAVBAR)
   ------------------------------------------------------------------------- */
.navbar {
  background: #1e2030;
  color: #c8cad8;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.navbar h1 {
  font-size: 15px;
  font-weight: 700;
  color: #e2e4ed;
  letter-spacing: -0.3px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: transparent;
  color: #a0a3b5;
  transition: all .15s;
}

.nav-btn:hover {
  background: #2a2d42;
  color: #e2e4ed;
}

.nav-btn.danger:hover {
  background: #3b1520;
  color: #f87171;
}

/* -------------------------------------------------------------------------
   BARRA DE FÓRMULAS
   ------------------------------------------------------------------------- */
.formula-bar {
  background: #f8f9fb;
  border-bottom: 1px solid #d1d5db;
  height: 30px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  flex-shrink: 0;
  font-size: 12px;
  color: #6b7280;
  gap: 8px;
}

.formula-bar .cell-ref {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: #3b82f6;
  min-width: 40px;
}

.formula-bar input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
}

/* -------------------------------------------------------------------------
   DIÁLOGOS Y OVERLAYS
   ------------------------------------------------------------------------- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.dialog-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.dialog {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  max-width: 460px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .2);
}

.dialog h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  color: #1e2030;
}

.dialog p {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
  margin-bottom: 12px;
}

/* -------------------------------------------------------------------------
   BOTONES DE EXPORTACIÓN
   ------------------------------------------------------------------------- */
.export-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #333;
  transition: all .15s;
  margin-bottom: 8px;
}

.export-btn:hover {
  background: #f0f5ff;
  border-color: #93b4f8;
}

.export-btn .ext {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  background: #eef2ff;
  color: #4f6ef7;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.close-btn {
  margin-top: 12px;
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #f9fafb;
  cursor: pointer;
  font-size: 13px;
  color: #555;
}

.close-btn:hover {
  background: #f0f0f0;
}

/* -------------------------------------------------------------------------
   TOAST NOTIFICACIONES
   ------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e2030;
  color: #e2e4ed;
  padding: 8px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
}

/* -------------------------------------------------------------------------
   MENÚ CONTEXTUAL (CLIC DERECHO)
   ------------------------------------------------------------------------- */
.context-menu {
  position: fixed;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 4px 0;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
  font-size: 13px;
  min-width: 140px;
}

.context-menu button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 6px 16px;
  cursor: pointer;
  color: #333;
  transition: background .1s;
}

.context-menu button:hover {
  background: #f0f5ff;
  color: #3b82f6;
}

.context-menu hr {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 4px 0;
}

/* -------------------------------------------------------------------------
   PALETA DE COLORES
   ------------------------------------------------------------------------- */
.color-swatch {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid #ddd;
  transition: all .15s;
}

.color-swatch:hover {
  border-color: #3b82f6;
  transform: scale(1.05);
}

/* -------------------------------------------------------------------------
   ENLACES DE APOYO / SOPORTE
   ------------------------------------------------------------------------- */
.support-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  color: inherit;
}

.support-link:hover {
  border-color: #93b4f8;
  background: #f0f5ff;
}

.support-link .name {
  font-weight: 600;
  font-size: 13px;
  color: #1e2030;
}

.support-link .desc {
  font-size: 12px;
  color: #666;
}
