/* ════════════════════════════════════════════════
   Traffic Tracker — Windows 95 theme
   ════════════════════════════════════════════════ */

/* ── Win95 palette ────────────────────────────── */
:root {
  --c-bg:        #008080;  /* teal desktop */
  --c-face:      #C0C0C0;  /* button face / window */
  --c-face-2:   #DFDFDF;  /* lighter face */
  --c-shadow:    #808080;  /* dark shadow */
  --c-shadow-2:  #404040;  /* darker shadow */
  --c-light:     #FFFFFF;  /* highlight */
  --c-text:      #000000;
  --c-text-dis:  #808080;
  --c-title:     #000080;  /* active title bar blue */
  --c-title-2:   #1084D0;  /* gradient end */
  --c-title-tx:  #FFFFFF;
  --c-title-in:  #808080;  /* inactive */
  --c-input-bg:  #FFFFFF;

  /* Rarity (Win95-adapted) */
  --c-red:       #FF0000;
  --c-red-dk:    #800000;
  --c-blue:      #0000FF;
  --c-blue-dk:   #000080;
  --c-green:     #008000;
  --c-green-dk:  #004000;
  --c-grey:      #808080;
  --c-grey-dk:   #404040;

  /* Confidence bar (как просили — фиксированный синий) */
  --c-conf:      #3B82F6;
}

/* ── Reset / base ─────────────────────────────── */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--c-bg);
  font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, sans-serif;
  font-size: 11px;
  color: var(--c-text);
  -webkit-font-smoothing: none;
  font-smooth: never;
}

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

/* ── 3D borders mixin (через классы) ─────────── */
/* "raised" = выпуклая поверхность (кнопка, окно) */
/* "sunken" = вдавленная (input, group) */

#desktop {
  min-height: 100vh;
  padding: 8px;
}

/* ════════════════════════════════════════════════
   WINDOW
   ════════════════════════════════════════════════ */
.window {
  background: var(--c-face);
  border-top:    2px solid var(--c-light);
  border-left:   2px solid var(--c-light);
  border-right:  2px solid var(--c-shadow-2);
  border-bottom: 2px solid var(--c-shadow-2);
  box-shadow:
    inset -1px -1px 0 0 var(--c-shadow),
    inset  1px  1px 0 0 var(--c-face);
  padding: 2px;
}

.main-window {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 16px);
}

/* ── Title bar ──────────────────────────────── */
.title-bar {
  background: linear-gradient(90deg, var(--c-title) 0%, var(--c-title-2) 100%);
  color: var(--c-title-tx);
  font-weight: bold;
  padding: 2px 2px 2px 4px;
  display: flex;
  align-items: center;
  user-select: none;
  height: 20px;
}

.title-bar-text {
  flex: 1;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.tb-btn {
  width: 16px;
  height: 14px;
  background: var(--c-face);
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow-2);
  border-bottom: 1px solid var(--c-shadow-2);
  box-shadow: inset -1px -1px 0 0 var(--c-shadow);
  color: var(--c-text);
  font-size: 10px;
  line-height: 10px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}
.tb-btn:active {
  border-top:    1px solid var(--c-shadow-2);
  border-left:   1px solid var(--c-shadow-2);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  box-shadow: inset 1px 1px 0 0 var(--c-shadow);
}

/* ── Menu bar ──────────────────────────────── */
.menu-bar {
  display: flex;
  padding: 2px 4px;
  border-bottom: 1px solid var(--c-shadow);
  margin-top: 1px;
}
.menu-item {
  padding: 2px 8px;
  cursor: default;
  user-select: none;
}
.menu-item:hover {
  background: var(--c-title);
  color: var(--c-title-tx);
}

/* ── Toolbar (top stat strip) ───────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-shadow);
  flex-wrap: wrap;
}
.stat-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 80px;
  padding: 2px 6px;
  border-top:    1px solid var(--c-shadow);
  border-left:   1px solid var(--c-shadow);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  background: var(--c-face);
}
.stat-label { font-size: 10px; color: var(--c-shadow-2); }
.stat-value { font-weight: bold; font-size: 12px; }
.toolbar-spacer { flex: 1; }

/* ── Buttons ──────────────────────────────── */
.win-btn {
  background: var(--c-face);
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow-2);
  border-bottom: 1px solid var(--c-shadow-2);
  box-shadow:
    inset -1px -1px 0 0 var(--c-shadow),
    inset  1px  1px 0 0 var(--c-face);
  color: var(--c-text);
  padding: 4px 12px;
  cursor: pointer;
  min-width: 70px;
  font-size: 11px;
  user-select: none;
}
.win-btn:hover { background: var(--c-face-2); }
.win-btn:active,
.win-btn.active {
  border-top:    1px solid var(--c-shadow-2);
  border-left:   1px solid var(--c-shadow-2);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  box-shadow:
    inset  1px  1px 0 0 var(--c-shadow),
    inset -1px -1px 0 0 var(--c-face);
  padding: 5px 11px 3px 13px;
}
.win-btn.primary {
  border-width: 2px;
}
.win-btn:disabled {
  color: var(--c-text-dis);
  text-shadow: 1px 1px 0 var(--c-light);
  cursor: not-allowed;
}

/* ── Content area ─────────────────────────── */
.content-area {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 8px;
  align-content: start;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 16px;
  color: var(--c-shadow-2);
}
.empty-icon { font-size: 48px; margin-bottom: 8px; }
.empty-text { font-size: 13px; line-height: 1.6; }

/* ── Status bar ───────────────────────────── */
.status-bar {
  display: flex;
  padding: 2px;
  gap: 2px;
  border-top: 1px solid var(--c-shadow);
}
.status-cell {
  border-top:    1px solid var(--c-shadow);
  border-left:   1px solid var(--c-shadow);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  padding: 2px 6px;
  font-size: 11px;
}
.status-cell:first-child { flex: 1; }

/* ════════════════════════════════════════════════
   KEYWORD CARD
   ════════════════════════════════════════════════ */
.card {
  display: flex;
  flex-direction: column;
}

.card-body {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-geo {
  display: inline-block;
  background: var(--c-face);
  color: var(--c-text);
  padding: 0 4px;
  margin-right: 4px;
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow-2);
  border-bottom: 1px solid var(--c-shadow-2);
  font-size: 10px;
}

.card-keyword {
  font-weight: bold;
}

.card-meta {
  font-size: 10px;
  color: var(--c-text);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  padding: 2px 0;
}
.meta-chip {
  background: var(--c-face-2);
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow);
  border-bottom: 1px solid var(--c-shadow);
  padding: 1px 4px;
}
.meta-sep { color: var(--c-shadow); }

/* ── Sunken panel (fieldset) ───────────────── */
.panel.sunken {
  border-top:    1px solid var(--c-shadow);
  border-left:   1px solid var(--c-shadow);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  background: transparent;
  padding: 6px 8px 8px;
  margin: 0;
}
.panel.sunken > legend {
  font-size: 10px;
  padding: 0 4px;
  color: var(--c-shadow-2);
  background: var(--c-face);
}

/* ── Stats grid ──────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px 8px;
  font-size: 11px;
}
.stats-label { color: var(--c-shadow-2); }

/* ── CR rows ─────────────────────────────── */
.cr-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  align-items: center;
}
.cr-value {
  display: flex;
  gap: 6px;
  align-items: center;
}
.cr-value b { font-size: 13px; }

.tier-badge {
  font-size: 10px;
  padding: 1px 4px;
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow);
  border-bottom: 1px solid var(--c-shadow);
  background: var(--c-face-2);
}
.tier-badge.tier-red    { background: var(--c-red);   color: #fff; }
.tier-badge.tier-blue   { background: var(--c-blue);  color: #fff; }
.tier-badge.tier-green  { background: var(--c-green); color: #fff; }
.tier-badge.tier-grey   { background: var(--c-grey);  color: #fff; }

.cr-expected {
  font-size: 10px;
  margin-top: 4px;
  color: var(--c-shadow-2);
}
.cr-expected b { color: var(--c-text); }

/* ── Progress bar (Win95 style: segmented blue blocks) ── */
.progress-bar {
  height: 16px;
  border-top:    1px solid var(--c-shadow);
  border-left:   1px solid var(--c-shadow);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  background: var(--c-face);
  position: relative;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      var(--c-title) 0 8px,
      transparent  8px 10px
    );
  background-color: var(--c-title);
  transition: width 0.3s ease, background-color 0.2s;
}

/* CR Click→Reg colors */
.progress-fill.tier-red    { background-color: var(--c-red);
  background-image: repeating-linear-gradient(90deg, var(--c-red-dk) 0 8px, transparent 8px 10px); }
.progress-fill.tier-blue   { background-color: var(--c-blue);
  background-image: repeating-linear-gradient(90deg, var(--c-blue-dk) 0 8px, transparent 8px 10px); }
.progress-fill.tier-green  { background-color: var(--c-green);
  background-image: repeating-linear-gradient(90deg, var(--c-green-dk) 0 8px, transparent 8px 10px); }
.progress-fill.tier-grey   { background-color: var(--c-grey);
  background-image: repeating-linear-gradient(90deg, var(--c-shadow-2) 0 8px, transparent 8px 10px); }

/* Confidence bar — фиксированный синий */
.progress-bar-confidence .progress-fill {
  background-color: var(--c-conf);
  background-image: repeating-linear-gradient(90deg, #1E40AF 0 8px, transparent 8px 10px);
}

.conf-remaining {
  font-size: 10px;
  margin-top: 4px;
  color: var(--c-shadow-2);
}
.conf-remaining b { color: var(--c-text); }

/* ── Action row ──────────────────────────── */
.action-row {
  display: flex;
  gap: 4px;
}
.action-row .win-btn {
  flex: 1;
  min-width: 0;
}

/* ── Drops grid ──────────────────────────── */
.drops-panel { min-height: 80px; }

.drops-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 64px);
  gap: 4px;
  min-height: 64px;
}

.drop-slot {
  width: 64px;
  height: 64px;
  background: #000;          /* dark canvas inside Win95 frame */
  border-top:    2px solid var(--c-shadow);
  border-left:   2px solid var(--c-shadow);
  border-right:  2px solid var(--c-light);
  border-bottom: 2px solid var(--c-light);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}
.drop-slot[data-color="red"]   { background: #2a0000; }
.drop-slot[data-color="blue"]  { background: #00002a; }
.drop-slot[data-color="green"] { background: #002a00; }
.drop-slot[data-color="grey"]  { background: #1a1a1a; }

/* Inner rarity ring */
.drop-slot::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid transparent;
  pointer-events: none;
}
.drop-slot[data-color="red"]::before   { border-color: var(--c-red); }
.drop-slot[data-color="blue"]::before  { border-color: var(--c-blue); }
.drop-slot[data-color="green"]::before { border-color: var(--c-green); }
.drop-slot[data-color="grey"]::before  { border-color: var(--c-grey); }

.drop-icon {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.drop-dep-marker {
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: 14px;
  color: #FFD700;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}
.drop-slot.is-dep {
  outline: 2px solid #FFD700;
  outline-offset: -2px;
}

.drop-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: #FFFFE1;
  color: var(--c-text);
  border: 1px solid var(--c-text);
  padding: 4px 6px;
  font-size: 10px;
  white-space: nowrap;
  z-index: 100;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.1s 0.4s; /* tooltip delay */
}
.drop-slot:hover .drop-tooltip { opacity: 1; }
.dt-name   { font-weight: bold; }
.dt-status { color: var(--c-shadow-2); margin-top: 2px; }

/* ════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════ */
input[type=text],
input[type=number],
textarea,
select {
  background: var(--c-input-bg);
  border-top:    2px solid var(--c-shadow);
  border-left:   2px solid var(--c-shadow);
  border-right:  2px solid var(--c-light);
  border-bottom: 2px solid var(--c-light);
  box-shadow:
    inset  1px  1px 0 0 var(--c-shadow-2),
    inset -1px -1px 0 0 var(--c-face);
  padding: 3px 4px;
  width: 100%;
  font-family: inherit;
  font-size: 11px;
  color: var(--c-text);
  outline: none;
}
input:focus, textarea:focus, select:focus {
  outline: 1px dotted var(--c-text);
  outline-offset: -3px;
}
select { padding: 2px 2px; }
textarea { resize: vertical; }

label {
  display: block;
  font-size: 11px;
  margin-bottom: 2px;
}

.form-row { margin-bottom: 8px; }
.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.form-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 12px;
  border-top: 1px solid var(--c-shadow);
  padding-top: 8px;
}

/* ════════════════════════════════════════════════
   MODALS
   ════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-overlay[hidden] { display: none; }

.modal-window {
  width: 480px;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-small { width: 320px; }
.modal-large { width: 720px; }

.modal-window .modal-body,
.modal-window > .modal-body {
  padding: 10px;
  overflow-y: auto;
}

/* ── Accounts table ─────────────────────────── */
.accounts-toolbar {
  margin-bottom: 8px;
}
.accounts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  border-top:    1px solid var(--c-shadow);
  border-left:   1px solid var(--c-shadow);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  background: var(--c-input-bg);
}
.accounts-table th {
  background: var(--c-face);
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow);
  border-bottom: 1px solid var(--c-shadow);
  padding: 3px 6px;
  text-align: left;
  font-weight: bold;
}
.accounts-table td {
  padding: 3px 6px;
  border-bottom: 1px dotted var(--c-shadow);
}
.accounts-table tr:last-child td { border-bottom: none; }
.accounts-table select,
.accounts-table input {
  padding: 1px 3px;
  font-size: 10px;
}
.acc-status-alive   { color: var(--c-green-dk); font-weight: bold; }
.acc-status-banned  { color: var(--c-red-dk);   font-weight: bold; }
.acc-status-appeal  { color: #b45309; font-weight: bold; }

.account-form { margin-bottom: 12px; }

/* ── Pick-reg list ─────────────────────────── */
.pick-reg-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
  padding: 4px;
  border-top:    1px solid var(--c-shadow);
  border-left:   1px solid var(--c-shadow);
  border-right:  1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  background: var(--c-input-bg);
  margin-bottom: 8px;
}
.pick-reg-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--c-face);
  border-top:    1px solid var(--c-light);
  border-left:   1px solid var(--c-light);
  border-right:  1px solid var(--c-shadow-2);
  border-bottom: 1px solid var(--c-shadow-2);
  cursor: pointer;
  text-align: center;
  font-size: 10px;
}
.pick-reg-item:hover { background: var(--c-face-2); }
.pick-reg-item.is-dep { opacity: 0.4; cursor: not-allowed; }
.pick-reg-item img {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
}

/* ════════════════════════════════════════════════
   DROP ANIMATION LAYER
   ════════════════════════════════════════════════ */
#drop-animation-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 2000;
  overflow: hidden;
}

.dropping-item {
  position: absolute;
  width: 64px;
  height: 64px;
  image-rendering: pixelated;
  animation: drop-fall 0.8s cubic-bezier(0.36, 0, 0.66, 1) forwards;
}

@keyframes drop-fall {
  0%   { transform: translateY(-100vh) scale(1.2) rotate(-15deg); opacity: 0; }
  20%  { opacity: 1; }
  85%  { transform: translateY(0)      scale(1.1) rotate(8deg); }
  100% { transform: translateY(0)      scale(1)   rotate(0deg); opacity: 1; }
}

.drop-slot.is-new {
  animation: slot-pulse 0.6s ease-out;
}
@keyframes slot-pulse {
  0%   { transform: scale(1);   filter: brightness(2); }
  50%  { transform: scale(1.15); filter: brightness(1.6); }
  100% { transform: scale(1);   filter: brightness(1); }
}

/* ════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════ */
@media (max-width: 600px) {
  .content-area { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .cr-row { grid-template-columns: 1fr; }
  .toolbar { gap: 4px; }
  .stat-group { min-width: 60px; }
}

/* Table mode (tracker1) */
.table-area {
  display: block;
  padding: 8px;
}

.table-wrap {
  border-top: 1px solid var(--c-shadow);
  border-left: 1px solid var(--c-shadow);
  border-right: 1px solid var(--c-light);
  border-bottom: 1px solid var(--c-light);
  background: var(--c-input-bg);
  overflow: auto;
  max-height: calc(100vh - 210px);
}

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

.keywords-table thead th {
  position: sticky;
  top: 0;
  background: var(--c-face);
  border-top: 1px solid var(--c-light);
  border-left: 1px solid var(--c-light);
  border-right: 1px solid var(--c-shadow);
  border-bottom: 1px solid var(--c-shadow);
  padding: 4px 6px;
  text-align: left;
  z-index: 2;
}

.keywords-table td {
  border-bottom: 1px dotted var(--c-shadow);
  padding: 4px 6px;
  vertical-align: top;
}

.keywords-table tbody tr:hover {
  background: #f2f2f2;
}

.keywords-table .cell-sub {
  color: var(--c-shadow-2);
  font-size: 10px;
}

.table-progress {
  margin-top: 3px;
  height: 12px;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}

.row-actions .win-btn {
  min-width: 56px;
  padding: 2px 4px;
}

.drops-mini {
  display: flex;
  gap: 2px;
  min-height: 18px;
  align-items: center;
}

.drop-mini {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}
