/* ==========================================================================
   TetriFast 1.14 Authentic Windows 95 Client Stylesheet
   ========================================================================== */

:root {
  --win-bg: #c0c0c0;
  --win-dark: #808080;
  --win-light: #ffffff;
  --win-darkest: #000000;
  --win-teal: #008080;
  --win-navy: #000080;
  --win-blue-grad: #1084d0;
  --win-text: #000000;
  --win-highlight: #000080;
  --win-highlight-text: #ffffff;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--win-teal);
  font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, Arial, sans-serif;
  font-size: 11px;
  color: var(--win-text);
  overflow: auto;
}

/* 3D Borders */
.border-raised {
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-darkest);
  border-bottom: 2px solid var(--win-darkest);
  box-shadow: inset 1px 1px 0 var(--win-light), inset -1px -1px 0 var(--win-dark);
}

.border-sunken {
  border-top: 2px solid var(--win-darkest);
  border-left: 2px solid var(--win-darkest);
  border-right: 2px solid var(--win-light);
  border-bottom: 2px solid var(--win-light);
  box-shadow: inset 1px 1px 0 var(--win-dark), inset -1px -1px 0 var(--win-light);
}

.border-etched {
  border: 2px groove var(--win-light);
}

/* Win95 Window Container */
#app-window {
  width: 820px;
  min-height: 600px;
  margin: 16px auto;
  background-color: var(--win-bg);
  padding: 3px;
  display: flex;
  flex-direction: column;
}

/* Title Bar */
.title-bar {
  background: linear-gradient(90deg, var(--win-navy), var(--win-blue-grad));
  color: var(--win-highlight-text);
  padding: 3px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: bold;
  font-size: 12px;
  height: 24px;
}

.title-bar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.title-bar-icon {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

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

.title-bar-btn {
  width: 16px;
  height: 14px;
  background-color: var(--win-bg);
  border-top: 1px solid var(--win-light);
  border-left: 1px solid var(--win-light);
  border-right: 1px solid var(--win-darkest);
  border-bottom: 1px solid var(--win-darkest);
  font-size: 9px;
  line-height: 12px;
  text-align: center;
  cursor: pointer;
  font-weight: bold;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.title-bar-btn:active {
  border-top: 1px solid var(--win-darkest);
  border-left: 1px solid var(--win-darkest);
  border-right: 1px solid var(--win-light);
  border-bottom: 1px solid var(--win-light);
  padding: 1px 0 0 1px;
}

/* Buttons */
button, .win-btn {
  background-color: var(--win-bg);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-darkest);
  border-bottom: 2px solid var(--win-darkest);
  box-shadow: inset 1px 1px 0 var(--win-light), inset -1px -1px 0 var(--win-dark);
  font-family: inherit;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
}

button:active, .win-btn:active {
  border-top: 2px solid var(--win-darkest);
  border-left: 2px solid var(--win-darkest);
  border-right: 2px solid var(--win-light);
  border-bottom: 2px solid var(--win-light);
  box-shadow: inset 1px 1px 0 var(--win-dark), inset -1px -1px 0 var(--win-light);
  padding: 4px 7px 2px 9px;
}

button:disabled, .win-btn:disabled {
  color: var(--win-dark);
  text-shadow: 1px 1px 0 var(--win-light);
  cursor: default;
}

/* Inputs */
input[type="text"], input[type="number"], select, textarea {
  background-color: #ffffff;
  color: #000000;
  border-top: 2px solid var(--win-darkest);
  border-left: 2px solid var(--win-darkest);
  border-right: 2px solid var(--win-light);
  border-bottom: 2px solid var(--win-light);
  box-shadow: inset 1px 1px 0 var(--win-dark), inset -1px -1px 0 var(--win-light);
  font-family: inherit;
  font-size: 11px;
  padding: 2px 4px;
  outline: none;
  user-select: text;
  -webkit-user-select: text;
}

input:focus, textarea:focus, select:focus {
  background-color: #ffffff;
}

/* Multi-Session Lobby Bar */
#lobby-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--win-bg);
  padding: 4px 6px;
  margin: 3px 0;
  gap: 8px;
}

.lobby-bar-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.status-badge {
  padding: 2px 6px;
  font-size: 10px;
  font-weight: bold;
}

.badge-connected {
  background-color: #008000;
  color: #ffffff;
}

.badge-disconnected {
  background-color: #800000;
  color: #ffffff;
}

.badge-role {
  background-color: #000080;
  color: #ffffff;
}

.badge-waiting {
  background-color: #006000;
  color: #ffffff;
}

.badge-inplay {
  background-color: #b00000;
  color: #ffffff;
}

.badge-ended {
  background-color: #606060;
  color: #ffffff;
}

/* Pixelated Canvases */
canvas {
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background-color: #000000;
}

/* Tabs System */
#tab-content-area {
  flex: 1;
  background-color: var(--win-bg);
  padding: 8px;
  min-height: 480px;
}

.tab-panel {
  display: none;
  height: 100%;
}

.tab-panel.active {
  display: block;
}

#tab-bar {
  display: flex;
  gap: 2px;
  padding: 4px 6px 0 6px;
  background-color: var(--win-bg);
  border-top: 1px solid var(--win-light);
}

.tab-btn {
  padding: 4px 12px;
  background-color: var(--win-bg);
  border-top: 2px solid var(--win-light);
  border-left: 2px solid var(--win-light);
  border-right: 2px solid var(--win-darkest);
  border-bottom: none;
  box-shadow: inset 1px 1px 0 var(--win-light), inset -1px 0 0 var(--win-dark);
  font-weight: bold;
  font-size: 11px;
  cursor: pointer;
}

.tab-btn.active {
  padding-bottom: 6px;
  margin-top: -2px;
  background-color: var(--win-bg);
}

/* ==========================================================================
   Tab 1: Fields (F1) Layout
   ========================================================================== */
#fields-container {
  display: grid;
  grid-template-columns: 200px 170px 1fr;
  gap: 8px;
  height: 100%;
}

.field-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.field-header {
  width: 100%;
  background-color: var(--win-navy);
  color: #ffffff;
  padding: 2px 4px;
  font-weight: bold;
  font-size: 11px;
  text-align: center;
  margin-bottom: 2px;
}

#primary-field-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

#primary-field {
  width: 192px;
  height: 352px;
}

/* HUD Panel */
#hud-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background-color: var(--win-bg);
  padding: 4px;
}

.hud-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-label {
  font-size: 10px;
  font-weight: bold;
  margin-bottom: 2px;
}

.hud-value-box {
  background-color: #000000;
  color: #00ff00;
  font-family: "Courier New", monospace;
  font-size: 14px;
  font-weight: bold;
  padding: 2px 6px;
  min-width: 60px;
  text-align: center;
}

#next-piece {
  width: 64px;
  height: 66px;
}

#attack-log {
  width: 100%;
  height: 120px;
  background-color: #000000;
  color: #00ffff;
  font-family: "Courier New", monospace;
  font-size: 10px;
  padding: 4px;
  overflow-y: auto;
  user-select: text;
  -webkit-user-select: text;
}

.attack-entry {
  line-height: 13px;
}

/* Mini Fields (5 Opponents) */
#mini-fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  gap: 6px;
}

.mini-field-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--win-bg);
  padding: 3px;
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.mini-field-box:hover {
  background-color: #d8d8d8;
}

.mini-field-box.focused-border {
  outline: 2px dashed #ffff00;
}

.mini-field-header {
  width: 100%;
  background-color: #000080;
  color: #ffffff;
  font-size: 10px;
  font-weight: bold;
  padding: 1px 2px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-field-canvas {
  width: 96px;
  height: 176px;
  margin-top: 2px;
}

/* Inventory Bar */
#inventory-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: var(--win-bg);
  padding: 4px 6px;
  margin-top: 4px;
}

#inv-desc {
  font-weight: bold;
  font-size: 11px;
  min-width: 120px;
  color: #000080;
}

#inventory-canvas {
  width: 288px;
  height: 16px;
}

/* In-game Chat Overlay */
#ingame-chat-area {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

#ingame-chat-log {
  height: 50px;
  background-color: #ffffff;
  color: #000000;
  overflow-y: auto;
  padding: 2px 4px;
  font-size: 11px;
  user-select: text;
  -webkit-user-select: text;
}

#ingame-chat-input {
  width: 100%;
}

/* ==========================================================================
   Tab 2: Partyline (F2) Layout
   ========================================================================== */
#partyline-container {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 8px;
  height: 440px;
}

#partyline-chat-box {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 4px;
}

#partyline-chat {
  flex: 1;
  background-color: #ffffff;
  color: #000000;
  padding: 6px;
  overflow-y: auto;
  font-size: 11px;
  line-height: 16px;
  user-select: text;
  -webkit-user-select: text;
}

.chat-entry {
  margin-bottom: 2px;
}

.chat-action {
  color: #008000;
  font-style: italic;
}

.chat-system {
  color: #800080;
  font-weight: bold;
}

#partyline-input-bar {
  display: flex;
  gap: 4px;
}

#partyline-input {
  flex: 1;
}

#partyline-sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#partyline-player-list {
  flex: 1;
  background-color: #ffffff;
  overflow-y: auto;
  padding: 4px;
}

.player-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px;
  border-bottom: 1px solid #e0e0e0;
}

.player-list-item.is-self {
  font-weight: bold;
}

.player-list-item.is-mod::before {
  content: "★ ";
  color: #b08000;
}

.player-actions {
  display: flex;
  gap: 2px;
}

.btn-mini {
  font-size: 9px;
  padding: 1px 4px;
}

/* ==========================================================================
   Tab 3: Winlist (F3) Layout
   ========================================================================== */
#winlist-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 440px;
}

.win95-table-wrap {
  flex: 1;
  background-color: #ffffff;
  overflow-y: auto;
}

table.win95-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

table.win95-table th {
  background-color: var(--win-bg);
  border-top: 1px solid var(--win-light);
  border-left: 1px solid var(--win-light);
  border-right: 1px solid var(--win-darkest);
  border-bottom: 1px solid var(--win-darkest);
  padding: 3px 6px;
  text-align: left;
  position: sticky;
  top: 0;
}

table.win95-table td {
  padding: 3px 6px;
  border-bottom: 1px solid #e0e0e0;
}

table.win95-table tr:hover {
  background-color: #000080;
  color: #ffffff;
}

/* ==========================================================================
   Tab 4: Misc (F4) Layout
   ========================================================================== */
#misc-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.misc-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.misc-splash-area {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: center;
  margin-top: 16px;
}

.splash-img {
  image-rendering: pixelated;
  border: 2px solid var(--win-darkest);
}

/* ==========================================================================
   Tab 5: Client / Multi-Session Lobby Browser (F5) Layout
   ========================================================================== */
#client-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 440px;
}

.section-box {
  padding: 8px;
  background-color: var(--win-bg);
}

.section-title {
  font-weight: bold;
  margin-bottom: 6px;
  font-size: 12px;
  color: #000080;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.form-label {
  min-width: 90px;
  font-weight: bold;
}

/* ==========================================================================
   Tab 6: Server Moderator Settings (F6) Layout
   ========================================================================== */
#server-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  height: 440px;
  overflow-y: auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 16px;
  padding: 8px;
}

/* ==========================================================================
   Modals: TForm3 (Occurancies) & TForm4 (Key Config)
   ========================================================================== */
.win-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.win-modal-overlay.open {
  display: flex;
}

.win-dialog {
  background-color: var(--win-bg);
  min-width: 380px;
  padding: 3px;
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.5);
}

.dialog-body {
  padding: 10px;
}

.occurancy-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.keybind-table {
  width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background-color: #ffffff;
  margin-bottom: 10px;
}

.keybind-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.keybind-row.selected {
  background-color: #000080;
  color: #ffffff;
}

.dialog-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
