/* ==========================================================================
   xp.css - a hand-rolled Luna widget kit
   Windows, title bars, buttons, fields, tabs, lists, dialogs and scrollbars.
   Nothing here knows anything about football.
   ========================================================================== */

:root {
  --luna-blue:        #0058ee;
  --luna-blue-light:  #3f8cf3;
  --luna-frame:       #0054cf;
  --face:             #ece9d8;
  --face-dark:        #d6d2c2;
  --field:            #ffffff;
  --field-border:     #7f9db9;
  --button-border:    #003c74;
  --text:             #000000;
  --text-dim:         #6d6d6d;
  --select:           #316ac5;
  --shadow:           rgba(0, 0, 0, .35);
  --title-h:          28px;
}

* { box-sizing: border-box; }

/* Layout rules below set `display` on these overlays, which would otherwise
   beat the user-agent's [hidden] rule and leave an invisible sheet swallowing
   every click. Keep this above everything else. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: Tahoma, "Segoe UI", "DejaVu Sans", Verdana, sans-serif;
  font-size: 11px;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- the Windows flag ----------------------------------------------------- */

.flag {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  width: 34px;
  height: 30px;
  transform: perspective(70px) rotateY(-14deg);
  flex: none;
}
.flag span { border-radius: 2px 3px 2px 3px; }
.flag span:nth-child(1) { background: #f34f22; }
.flag span:nth-child(2) { background: #7bb711; }
.flag span:nth-child(3) { background: #00a3ee; }
.flag span:nth-child(4) { background: #ffb900; }
.flag.small { width: 26px; height: 23px; }
.flag.tiny  { width: 19px; height: 17px; gap: 1.5px; }

/* --- window --------------------------------------------------------------- */

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  min-width: 260px;
  min-height: 140px;
  background: var(--face);
  border: 1px solid var(--luna-frame);
  border-top: none;
  border-radius: 8px 8px 0 0;
  box-shadow: 2px 3px 10px var(--shadow);
  overflow: hidden;
}
.window.inactive { box-shadow: 1px 2px 6px rgba(0, 0, 0, .22); }
.window.maximised { border-radius: 0; }

.title-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--title-h);
  padding: 0 3px 0 5px;
  border-radius: 7px 7px 0 0;
  background: linear-gradient(to bottom,
    #0058ee 0%, #3593ff 8%, #288eff 40%, #127dff 88%,
    #036ffc 93%, #0060df 95%, #0054cf 96%, #0054cf 100%);
  cursor: default;
  user-select: none;
  flex: none;
}
.window.maximised .title-bar { border-radius: 0; }
.window.inactive .title-bar {
  background: linear-gradient(to bottom,
    #7ba2e7 0%, #a3c0f0 8%, #93b4ee 40%, #7ea7ea 88%,
    #7ba2e7 93%, #6e97e0 95%, #6a92da 100%);
}

.title-bar-icon { width: 16px; height: 16px; flex: none; }

.title-bar-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: .2px;
  text-shadow: 1px 1px 1px rgba(0, 0, 0, .55);
}
.window.inactive .title-bar-text { color: #e7eefb; }

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

.title-bar-controls button {
  width: 21px;
  height: 21px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 3px;
  background: linear-gradient(to bottom, #4c93ff, #1272f2 45%, #0d5fd8);
  color: #fff;
  font: 700 12px/1 Tahoma, sans-serif;
  display: grid;
  place-items: center;
  cursor: default;
}
.title-bar-controls button:hover  { filter: brightness(1.18); }
.title-bar-controls button:active { filter: brightness(.85); }
.title-bar-controls button.close {
  background: linear-gradient(to bottom, #f37f65, #e4593b 45%, #c72d10);
  width: 23px;
}

/* Glyphs drawn in CSS so no icon font is needed. */
.tb-glyph { display: block; width: 9px; height: 9px; position: relative; }
.tb-min::after {
  content: ""; position: absolute; left: 0; bottom: 1px;
  width: 8px; height: 3px; background: #fff;
}
.tb-max::after {
  content: ""; position: absolute; inset: 0;
  border: 1px solid #fff; border-top-width: 3px;
}
.tb-restore::before {
  content: ""; position: absolute; left: 2px; top: 0; width: 7px; height: 6px;
  border: 1px solid #fff; border-top-width: 2px;
}
.tb-restore::after {
  content: ""; position: absolute; left: 0; top: 3px; width: 7px; height: 6px;
  border: 1px solid #fff; border-top-width: 2px; background: linear-gradient(#1272f2, #1272f2);
}
.tb-close::before, .tb-close::after {
  content: ""; position: absolute; left: 0; top: 4px;
  width: 10px; height: 2px; background: #fff;
}
.tb-close::before { transform: rotate(45deg); }
.tb-close::after  { transform: rotate(-45deg); }

.window-body {
  flex: 1;
  min-height: 0;
  padding: 8px;
  overflow: auto;
  background: var(--face);
}
.window-body.flush { padding: 0; }

.status-bar {
  flex: none;
  display: flex;
  gap: 3px;
  padding: 2px 3px;
  border-top: 1px solid #fff;
  background: var(--face);
}
.status-bar > span {
  padding: 2px 6px;
  border: 1px solid var(--face-dark);
  border-right-color: #fff;
  border-bottom-color: #fff;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status-bar > span:first-child { flex: 1; }

.resize-handle {
  position: absolute;
  right: 0; bottom: 0;
  width: 16px; height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 45%, #a9a795 45%, #a9a795 55%, transparent 55%),
    linear-gradient(135deg, transparent 65%, #a9a795 65%, #a9a795 75%, transparent 75%);
}

/* --- buttons -------------------------------------------------------------- */

.btn {
  min-width: 75px;
  height: 23px;
  padding: 0 12px;
  border: 1px solid var(--button-border);
  border-radius: 3px;
  background: linear-gradient(to bottom, #fff 0%, #f2f1e9 46%, #e3e1d3 47%, #ece9d8 100%);
  box-shadow: inset 0 0 0 1px #fff;
  cursor: default;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  border-color: #ea9d1c;
  box-shadow: inset 0 0 0 1px #fee9a2;
}
.btn:active:not(:disabled) {
  background: linear-gradient(to bottom, #cdcabb 0%, #dedbcd 8%, #e6e3d6 100%);
  box-shadow: inset 1px 1px 2px rgba(0, 0, 0, .2);
}
.btn:disabled { color: #adaa9f; text-shadow: 1px 1px 0 #fff; }
.btn.default { box-shadow: inset 0 0 0 1px #fff, 0 0 0 1px #4a7fca; }
.btn.small { min-width: 0; height: 20px; padding: 0 8px; }

/* --- fields --------------------------------------------------------------- */

.field, input[type="text"], input[type="password"], input[type="search"], select {
  height: 21px;
  padding: 2px 4px;
  border: 1px solid var(--field-border);
  background: var(--field);
  box-shadow: inset 1px 1px 1px rgba(0, 0, 0, .12);
}
input:focus, select:focus { outline: 1px dotted #444; outline-offset: -3px; }

label { user-select: none; }

.group {
  margin: 0 0 10px;
  padding: 10px 10px 8px;
  border: 1px solid #d0cdc0;
  border-radius: 3px;
  background: rgba(255, 255, 255, .35);
  position: relative;
}
.group > legend, .group > .legend {
  padding: 0 4px;
  color: #0046d5;
  font-weight: 700;
}

/* --- tabs ----------------------------------------------------------------- */

.tabs { display: flex; gap: 2px; padding: 0 4px; margin-bottom: -1px; }
.tab {
  padding: 3px 12px 4px;
  border: 1px solid #92918b;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to bottom, #fbfaf6, #e6e3d5);
  cursor: default;
  position: relative;
  top: 2px;
}
.tab[aria-selected="true"] {
  top: 0;
  padding-bottom: 6px;
  background: linear-gradient(to bottom, #fff, #f4f2ea);
  font-weight: 700;
  z-index: 2;
}
.tab-panel {
  border: 1px solid #92918b;
  border-radius: 0 3px 3px 3px;
  background: var(--face);
  padding: 8px;
}

/* --- lists and tables ----------------------------------------------------- */

.list {
  border: 1px solid var(--field-border);
  background: var(--field);
  overflow: auto;
  box-shadow: inset 1px 1px 1px rgba(0, 0, 0, .1);
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 11px;
}
table.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 6px;
  text-align: left;
  font-weight: 400;
  white-space: nowrap;
  border-right: 1px solid #d5d2c6;
  border-bottom: 1px solid #a5a396;
  background: linear-gradient(to bottom, #fff, #ece9d8);
  cursor: default;
  user-select: none;
}
table.grid th.sortable:hover { background: linear-gradient(to bottom, #fff, #dfe8f6); }
table.grid th .arrow { color: #0046d5; font-size: 9px; }
table.grid td {
  padding: 3px 6px;
  border-bottom: 1px solid #eeecE3;
  white-space: nowrap;
}
table.grid tbody tr:nth-child(even) { background: #f6f5ee; }
table.grid tbody tr:hover  { background: #eaf1fb; }
table.grid tbody tr.selected { background: var(--select); color: #fff; }
table.grid tbody tr.selected td { border-bottom-color: var(--select); }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- dialogs -------------------------------------------------------------- */

.dialogs { position: fixed; inset: 0; pointer-events: none; z-index: 9000; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .18);
  pointer-events: auto;
  display: grid;
  place-items: center;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }

.dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--luna-frame);
  border-top: none;
  border-radius: 8px 8px 0 0;
  background: var(--face);
  box-shadow: 3px 5px 18px rgba(0, 0, 0, .45);
  animation: pop .12s ease-out;
}
@keyframes pop { from { transform: scale(.96); opacity: .4; } }

.dialog-body { display: flex; gap: 12px; padding: 16px 14px 10px; }
.dialog-icon { width: 32px; height: 32px; flex: none; }
.dialog-message { flex: 1; line-height: 1.45; }
.dialog-message h4 { margin: 0 0 6px; font-size: 11px; }
.dialog-message ul { margin: 6px 0 0; padding-left: 18px; }
.dialog-message li { margin: 2px 0; }
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 6px 12px 12px;
}

/* --- scrollbars ----------------------------------------------------------- */

* { scrollbar-color: #b6c7e4 #f0efe6; scrollbar-width: thin; }
::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track {
  background: #f0efe6;
  border-left: 1px solid #d6d2c2;
}
::-webkit-scrollbar-thumb {
  border: 1px solid #6d92cd;
  border-radius: 2px;
  background: linear-gradient(to right, #fff, #cfe0f7 30%, #9dbdec);
}
::-webkit-scrollbar-thumb:hover { filter: brightness(1.06); }
::-webkit-scrollbar-corner { background: #f0efe6; }

/* --- helpers -------------------------------------------------------------- */

.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.dim { color: var(--text-dim); }
.strong { font-weight: 700; }
.right { text-align: right; }
.hidden { display: none !important; }
.pill {
  display: inline-block;
  padding: 1px 7px;
  border: 1px solid #b9c7dd;
  border-radius: 9px;
  background: linear-gradient(to bottom, #fff, #e8effa);
  font-size: 10px;
  white-space: nowrap;
}
.pill.warn   { border-color: #e0b487; background: linear-gradient(to bottom, #fff8ec, #ffe6c4); }
.pill.danger { border-color: #dda2a2; background: linear-gradient(to bottom, #fff0f0, #ffd8d8); }
.pill.good   { border-color: #a8d0a0; background: linear-gradient(to bottom, #f3fff0, #d8f2d0); }

.spin {
  width: 13px; height: 13px;
  border: 2px solid #c8d6ee;
  border-top-color: #1a6fe0;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
