/*
 * 360 Statistics — AXES HUB Clean Theme
 * Single CSS file with CSS variables. No dark-theme.css needed.
 * .dark-theme class set by hub-mode.js v4
 */

/* ── Theme Variables ─────────────────────────────────── */
:root {
  --bg: #f5f7fa;
  --bg-card: rgba(255, 255, 255, 0.65);
  --bg-muted: rgba(245, 247, 250, 0.7);
  --fg: #1a1a1a;
  --fg-muted: #666;
  --fg-hint: #888;
  --border: #e2e8f0;
  --border-light: #f0f0f0;
  --primary: #D52B1E;
  --primary-dark: #A01F15;
  --primary-bg: rgba(213, 43, 30, 0.08);
  --primary-border: rgba(213, 43, 30, 0.2);
  --secondary: #667eea;
  --glass-border: rgba(0, 0, 0, 0.06);
  --shadow: rgba(0, 0, 0, 0.08);
  --shadow-strong: rgba(0, 0, 0, 0.15);
  --input-bg: #ffffff;
  --input-border: #ddd;
  --radius: 12px;
  --radius-sm: 8px;
  --danger: #ef476f;
  --warning: #ff9800;
  --success: #10b981;
}

.dark-theme,
html.dark-theme,
body.dark-theme,
html.dark-theme body {
  --bg: #111111;
  --bg-card: rgba(30, 30, 30, 0.75);
  --bg-muted: rgba(34, 34, 34, 0.6);
  --fg: #f1f5f9;
  --fg-muted: #94a3b8;
  --fg-hint: #64748b;
  --border: #333;
  --border-light: #222;
  --primary: #ef4444;
  --primary-dark: #dc2626;
  --primary-bg: rgba(239, 68, 68, 0.1);
  --primary-border: rgba(239, 68, 68, 0.2);
  --secondary: #818cf8;
  --glass-border: rgba(255, 255, 255, 0.06);
  --shadow: rgba(0, 0, 0, 0.2);
  --shadow-strong: rgba(0, 0, 0, 0.3);
  --input-bg: rgba(34, 34, 34, 0.8);
  --input-border: #333;
  --danger: #ef476f;
  --warning: #ffa726;
  --success: #10b981;
  color: #f1f5f9;
  background: transparent;
}

/* ── Base ────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  overflow-x: hidden;
  animation: pageSlideIn 0.3s ease-out forwards;
}

/* Page transition — slide in from right */
@keyframes pageSlideIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

body.hub-mode, .hub-mode body { background: transparent !important; zoom: 0.7; }
.hub-mode header { display: none !important; }

#backgroundCanvas {
  position: fixed; inset: 0;
  z-index: -1; pointer-events: none;
}
.hub-mode #backgroundCanvas { display: none; }

/* ── Container ───────────────────────────────────────── */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px 20px;
  position: relative; z-index: 1;
}
.hub-mode .container { padding-top: 8px; }

/* Карточка результатов — во всю ширину экрана */
#step3 {
  max-width: none !important;
  width: calc(100vw - 40px);
  margin-left: calc((100% - 100vw) / 2 + 20px);
  margin-right: calc((100% - 100vw) / 2 + 20px);
  box-sizing: border-box;
}
@media (max-width: 1440px) {
  #step3 {
    width: calc(100vw - 20px);
    margin-left: calc((100% - 100vw) / 2 + 10px);
    margin-right: calc((100% - 100vw) / 2 + 10px);
  }
}

/* ── Header ──────────────────────────────────────────── */
header {
  text-align: center;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(213, 43, 30, 0.25);
  color: white;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

header h1 { font-size: 2.4em; color: white; }
header .subtitle { font-size: 1.05em; color: rgba(255,255,255,0.9); }

.axes-logo {
  height: 40px;
  filter: brightness(0) invert(1);
  transition: transform 0.3s;
}
.axes-logo:hover { transform: scale(1.05); }

/* ── Step Cards (main content blocks) ────────────────── */
.step-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 4px 20px var(--shadow);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  animation: fadeInUp 0.4s ease;
}

.step-header {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}

.step-number {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2em; font-weight: bold;
  margin-right: 12px;
}

.step-header h2 {
  color: var(--fg);
  font-size: 1.5em;
}

/* ── Upload Area ─────────────────────────────────────── */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-muted);
}

.upload-area:hover,
.upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-bg);
}

.upload-icon { font-size: 3em; margin-bottom: 12px; }
.upload-text { font-size: 1em; color: var(--fg-muted); margin-bottom: 16px; }

/* ── File Info ────────────────────────────────────────── */
.file-info {
  margin-top: 16px;
  padding: 16px;
  background: var(--primary-bg);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
}
.file-info p { margin: 6px 0; color: var(--fg); }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  padding: 10px 24px;
  font-size: 0.9em;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}

.btn-primary, .btn-success {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 10px rgba(213, 43, 30, 0.2);
}
.btn-primary:hover, .btn-success:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-muted);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-warning {
  background: var(--warning);
  color: white;
}
.btn-warning:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%; border: none;
  font-size: 1.1em; cursor: pointer;
  background: var(--bg-muted);
  color: var(--fg);
  transition: all 0.2s;
}
.btn-icon:hover { transform: scale(1.1); }
.btn-open:hover { background: var(--primary); color: white; }
.btn-delete:hover { background: var(--danger); color: white; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: white; text-decoration: none;
  padding: 10px 20px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 600; transition: all 0.2s;
}
.back-link:hover { background: var(--primary-dark); }

/* ── Hint ────────────────────────────────────────────── */
.hint { color: var(--fg-muted); margin-bottom: 16px; font-size: 0.95em; }

/* ── Minimums / Form Grid ────────────────────────────── */
.minimums-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px; margin-bottom: 16px;
}

.minimum-item {
  padding: 14px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.minimum-item label {
  display: block; font-weight: 600;
  margin-bottom: 6px; color: var(--fg);
}

.minimum-item input,
.minimum-item select {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px; font-size: 0.9em;
  background: var(--input-bg); color: var(--fg);
  transition: border-color 0.2s;
}

.minimum-item input:focus,
.minimum-item select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}

/* ── Legend ───────────────────────────────────────────── */
.legend {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--bg-muted);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.legend h3 { margin-bottom: 12px; color: var(--fg); font-size: 1em; }

.legend-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}

.legend-item {
  display: flex; align-items: center;
  font-size: 0.85em; color: var(--fg-muted);
}

.color-box {
  width: 24px; height: 24px;
  border-radius: 4px; margin-right: 8px;
  border: 1px solid var(--border);
}

.color-red { background: #ffcccc; }
.color-yellow { background: #fff9cc; }
.color-white { background: white; }
.color-green { background: #ccffcc; }

.dark-theme .color-red { background: rgba(255, 100, 100, 0.3); }
.dark-theme .color-yellow { background: rgba(255, 230, 100, 0.25); }
.dark-theme .color-white { background: rgba(255, 255, 255, 0.15); }
.dark-theme .color-green { background: rgba(100, 255, 100, 0.25); }

/* ── Table Controls ──────────────────────────────────── */
.table-controls {
  margin-bottom: 16px;
  display: flex; gap: 8px; flex-wrap: wrap;
}

/* ── Results Table ───────────────────────────────────── */
.table-wrapper {
  /* overflow-x убран — sticky должен работать относительно viewport (body),
     а не относительно wrapper. Горизонтальная прокрутка теперь на уровне body. */
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

#resultsTable {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#resultsTable th {
  background: var(--table-header, var(--primary));
  color: white;
  padding: 12px;
  text-align: left;
  font-weight: 600; font-size: 0.85em;
  position: sticky; top: 0; z-index: 10;
}

/* Цветовые гаммы бренда для шапки таблицы */
body.brand-axes, html.brand-axes { --table-header: #c00000; }
body.brand-lagoon, html.brand-lagoon { --table-header: #09005D; }
body.brand-noir, html.brand-noir { --table-header: #263238; }
/* Текст шапки всегда белый */
body[class*="brand-"] #resultsTable th,
html[class*="brand-"] #resultsTable th { color: #fff; }

#resultsTable td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  font-size: 0.85em;
  color: var(--fg);
}

#resultsTable tbody tr:hover {
  background: var(--primary-bg);
}

/* Status cells — keep semantic colors */
.cell-red { background-color: #ffcccc !important; color: #333 !important; }
.cell-yellow { background-color: #fff9cc !important; color: #333 !important; }
.cell-white { background-color: white !important; color: #333 !important; }
.cell-green { background-color: #ccffcc !important; color: #333 !important; }

.dark-theme .cell-red { background-color: rgba(255, 100, 100, 0.25) !important; color: #f1f5f9 !important; }
.dark-theme .cell-yellow { background-color: rgba(255, 230, 100, 0.2) !important; color: #f1f5f9 !important; }
.dark-theme .cell-white { background-color: rgba(255, 255, 255, 0.1) !important; color: #f1f5f9 !important; }
.dark-theme .cell-green { background-color: rgba(100, 255, 100, 0.2) !important; color: #f1f5f9 !important; }

/* ── Room Cards ──────────────────────────────────────── */
.room-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 10px var(--shadow);
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  transition: all 0.2s;
}
.room-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--shadow-strong);
}

.room-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.room-header h3 { color: var(--primary); margin: 0; font-size: 1.2em; }
.room-actions { display: flex; gap: 8px; }
.room-details p { margin: 6px 0; color: var(--fg-muted); font-size: 0.9em; }

/* ── Modal ───────────────────────────────────────────── */
.modal {
  display: none;
  position: fixed; z-index: 9999; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center; justify-content: center;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 90%; max-width: 560px; max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--glass-border);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  animation: fadeInUp 0.3s ease;
}

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; color: var(--primary); font-size: 1.2em; }
.modal-close { font-size: 1.5em; color: var(--fg-hint); cursor: pointer; }
.modal-close:hover { color: var(--fg); }

.modal-body { padding: 20px 24px; }
.modal-body .form-group { margin-bottom: 16px; }
.modal-body .form-group label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--fg); }

.modal-body .form-group input,
.modal-body .form-group textarea,
.modal-body .form-group select {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--input-border);
  border-radius: 6px; font-size: 0.9em;
  background: var(--input-bg); color: var(--fg);
}

.modal-body .form-group input:focus,
.modal-body .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── End Date Editing ────────────────────────────────── */
#endDateInput {
  background: var(--input-bg);
  border: 1px solid var(--primary);
  color: var(--fg);
  padding: 6px 10px; border-radius: 6px;
}
#endDateInput:focus { outline: none; box-shadow: 0 0 0 3px var(--primary-bg); }

#saveEndDateBtn { background: var(--success); color: white; border: none; padding: 6px 14px; border-radius: 6px; font-weight: 600; cursor: pointer; }
#cancelEndDateBtn { background: var(--danger); color: white; border: none; padding: 6px 14px; border-radius: 6px; font-weight: 600; cursor: pointer; }

.edit-date-btn {
  background: none; border: none;
  color: var(--fg-muted); cursor: pointer;
  font-size: 1.1em; margin-left: 8px; padding: 4px 6px; border-radius: 4px;
  transition: all 0.2s;
}
.edit-date-btn:hover { color: var(--primary); background: var(--primary-bg); }

/* ── Inline styles override (for letter generator) ──── */
.dark-theme div[style*="background: rgba(102"] {
  background: var(--bg-muted) !important;
  border-color: var(--secondary) !important;
}
.dark-theme div[style*="background: #f9f9f9"],
.dark-theme div[style*="background: rgb(249"] {
  background: var(--bg-muted) !important;
  color: var(--fg) !important;
  border-color: var(--border) !important;
}
.dark-theme div[style*="background: rgba(255,255,255"] {
  background: rgba(255,255,255,0.08) !important;
}
.dark-theme small[style*="color: rgba(255"] { color: var(--fg-muted) !important; }
.dark-theme span[style*="color: #333"] { color: var(--fg) !important; }
.dark-theme small[style*="color: #666"] { color: var(--fg-hint) !important; }

/* ── Loading Spinner ─────────────────────────────────── */
.loading {
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  width: 40px; height: 40px;
  animation: spin 0.8s linear infinite;
  margin: 16px auto;
}

/* ── Animations ──────────────────────────────────────── */
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar (dark) ────────────────────────────────── */
.dark-theme ::-webkit-scrollbar { width: 5px; height: 5px; }
.dark-theme ::-webkit-scrollbar-track { background: transparent; }
.dark-theme ::-webkit-scrollbar-thumb { background: #4a4d5a; border-radius: 3px; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
  header h1 { font-size: 1.8em; }
  .step-card { padding: 16px; }
  .minimums-container { grid-template-columns: 1fr; }
  .legend-items { grid-template-columns: 1fr; }
  .modal-content { width: 95%; }
  .room-header { flex-direction: column; align-items: flex-start; }
  .room-actions { margin-top: 8px; }
}

/* ── Status Filter (segmented control над таблицей результатов) ────── */
.status-filter {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 12px; padding: 10px 14px;
  background: rgba(0, 0, 0, 0.04); border-radius: 8px;
  border: 1px solid var(--border, #d0d3d7);
}
.status-filter-label {
  font-size: 0.9em; font-weight: 600; opacity: 0.75; margin-right: 4px;
}
.btn-filter {
  padding: 6px 14px; font-size: 0.9em; font-family: inherit;
  background: white; color: inherit;
  border: 1px solid var(--border, #d0d3d7); border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-filter:hover { background: rgba(255, 107, 53, 0.08); border-color: #ff6b35; }
.btn-filter.active {
  background: #ff6b35; color: white; border-color: #ff6b35;
  font-weight: 600;
}
.btn-filter .counter {
  opacity: 0.75; font-size: 0.85em; margin-left: 4px;
  font-variant-numeric: tabular-nums;
}
.btn-filter.active .counter { opacity: 0.95; }

/* Dark theme */
.dark-theme .status-filter { background: rgba(255, 255, 255, 0.05); }
.dark-theme .btn-filter { background: rgba(255, 255, 255, 0.08); color: #eee; border-color: #555; }
.dark-theme .btn-filter:hover { background: rgba(255, 107, 53, 0.2); }
