/* ============================================================
   RESET
============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ============================================================
   DESKTOP — classic Win98 teal
============================================================ */
body {
  background-color: #008080;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 48px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ============================================================
   WINDOW CHROME
   The raised 3D border trick: light edges top/left, dark bottom/right
============================================================ */
.window {
  width: min(1140px, 100%);
  background: #c0c0c0;
  border: 2px solid;
  border-color: #ffffff #808080 #808080 #ffffff;
  box-shadow: 2px 2px 0 #000;
  display: flex;
  flex-direction: column;
  min-height: 560px;
}

/* Title bar */
.title-bar {
  background: linear-gradient(90deg, #000080 0%, #1084d0 100%);
  color: #fff;
  padding: 3px 4px 3px 6px;
  display: flex;
  align-items: center;
  gap: 5px;
  user-select: none;
  flex-shrink: 0;
}

.title-bar-icon { font-size: 12px; }

.title-bar-text {
  flex: 1;
  font-size: 11px;
  font-weight: bold;
  font-family: 'Arial', sans-serif;
}

.title-bar-buttons {
  display: flex;
  gap: 2px;
}

.title-btn {
  width: 16px;
  height: 14px;
  background: #c0c0c0;
  color: #000;
  border: 1px solid;
  border-color: #fff #808080 #808080 #fff;
  font-size: 9px;
  font-weight: bold;
  font-family: 'Arial', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

.title-btn:hover  { background: #d4d0c8; }
.title-btn:active { border-color: #808080 #fff #fff #808080; }

/* Menu bar */
.menu-bar {
  background: #c0c0c0;
  display: flex;
  border-bottom: 1px solid #808080;
  padding: 1px 2px;
  flex-shrink: 0;
}

.menu-item {
  font-size: 11px;
  font-family: 'Arial', sans-serif;
  padding: 2px 8px;
  cursor: default;
  color: #000;
}

.menu-item:hover {
  background: #000080;
  color: #fff;
}

/* Toolbar */
.toolbar {
  background: #c0c0c0;
  padding: 3px 6px;
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
  border-bottom: 1px solid #808080;
  flex-shrink: 0;
}

.toolbar-btn {
  font-size: 11px;
  font-family: 'Arial', sans-serif;
  padding: 2px 9px;
  background: #c0c0c0;
  color: #000;
  border: 1px solid;
  border-color: #fff #808080 #808080 #fff;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.toolbar-btn:hover  { background: #d4d0c8; }
.toolbar-btn:active {
  border-color: #808080 #fff #fff #808080;
  padding: 3px 8px 1px 10px;
}

/* Hide the real file input */
#file-input { display: none; }

.toolbar-sep {
  width: 1px;
  height: 18px;
  background: #808080;
  border-right: 1px solid #fff;
  margin: 0 4px;
}

/* ============================================================
   CONTENT AREA — two panels side by side
============================================================ */
.content-area {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.left-panel  { flex: 1.1; min-width: 0; }
.right-panel { flex: 1;   min-width: 0; }

.panel-divider {
  width: 4px;
  background: #c0c0c0;
  border-left:  1px solid #808080;
  border-right: 1px solid #fff;
  flex-shrink: 0;
}

.panel-label {
  font-size: 9px;
  font-family: 'Arial', sans-serif;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: #555;
  padding: 4px 8px 2px;
  border-bottom: 1px solid #808080;
  flex-shrink: 0;
}

/* ============================================================
   DROP ZONE
============================================================ */
.drop-zone {
  margin: 6px 8px 4px;
  border: 2px dashed #999;
  background: #d4d0c8;
  padding: 7px;
  text-align: center;
  cursor: default;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}

.drop-zone.drag-over {
  background: #c8d8f0;
  border-color: #000080;
}

.drop-zone span {
  font-size: 11px;
  font-family: 'Arial', sans-serif;
  color: #555;
  pointer-events: none;
}

/* ============================================================
   SPREADSHEET TABLE
   Classic spreadsheet: gray headers, white cells, thin grid lines
============================================================ */
.sheet-wrapper {
  flex: 1;
  overflow: auto;
  margin: 0 8px 8px;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #fff;
}

#editor-table {
  border-collapse: collapse;
  width: 100%;
  table-layout: fixed;
}

/* Column header row */
#editor-table thead th {
  background: #c0c0c0;
  border: 1px solid;
  border-color: #fff #808080 #808080 #fff;
  font-size: 11px;
  font-family: 'Arial', sans-serif;
  font-weight: bold;
  text-align: center;
  padding: 2px 4px;
  min-width: 72px;
  position: sticky;
  top: 0;
  z-index: 2;
  color: #000;
  user-select: none;
}

#editor-table thead th.corner {
  min-width: 28px;
  width: 28px;
}

#editor-table thead th.active-header {
  background: #000080;
  color: #fff;
}

/* Row number cells */
.row-num {
  background: #c0c0c0;
  border: 1px solid;
  border-color: #fff #808080 #808080 #fff;
  font-size: 10px;
  font-family: 'Arial', sans-serif;
  text-align: right;
  padding: 1px 5px;
  width: 28px;
  min-width: 28px;
  color: #555;
  user-select: none;
  position: sticky;
  left: 0;
  z-index: 1;
}

/* Data cells */
.data-cell {
  border: 1px solid #d8d8d8;
  padding: 2px 5px;
  font-size: 12.5px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 22px;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  color: #111;
  cursor: text;
}

.data-cell:focus {
  background: #e8f0fe;
  border: 1px solid #4285f4;
  position: relative;
  z-index: 1;
  box-shadow: inset 0 0 0 1px #4285f4;
}

/* ============================================================
   JSON OUTPUT PANEL
   Dark-theme code view — modern, clean, high contrast
============================================================ */
.json-wrapper {
  flex: 1;
  overflow: auto;
  margin: 6px 8px 4px;
  border: 2px solid;
  border-color: #808080 #fff #fff #808080;
  background: #1e1e2e;
}

#json-output {
  padding: 14px 18px;
  font-family: 'Cascadia Code', 'Fira Code', 'Consolas', 'Monaco', monospace;
  font-size: 12.5px;
  line-height: 1.75;
  color: #cdd6f4;
  white-space: pre;
  min-height: 100%;
}

/* Syntax highlight classes (set in app.js via highlight()) */
.j-k { color: #89b4fa; }           /* key */
.j-s { color: #a6e3a1; }           /* string value */
.j-n { color: #fab387; }           /* number */
.j-b { color: #f38ba8; }           /* boolean */
.j-z { color: #6c7086; font-style: italic; }  /* null */
.j-empty { color: #585b70; font-style: italic; }
.j-err   { color: #f38ba8; }

.copy-bar {
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#copy-msg {
  font-size: 11px;
  font-family: 'Arial', sans-serif;
  color: #333;
}

/* ============================================================
   STATUS BAR
============================================================ */
.status-bar {
  display: flex;
  border-top: 2px solid;
  border-color: #808080 #fff #fff #808080;
  flex-shrink: 0;
}

.status-cell {
  font-size: 11px;
  font-family: 'Arial', sans-serif;
  padding: 2px 8px;
  border: 1px solid;
  border-color: #808080 #fff #fff #808080;
  color: #000;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-right {
  flex: 0 0 auto;
  color: #666;
}

.mail-link {
  color: #000080;
  text-decoration: none;
  font-size: 13px;
}

.mail-link:hover {
  text-decoration: underline;
}
