/* ============================================================
   DASHBOARD.CSS — стили пультов (главная и мини-пульты)
   ============================================================ */

/* ===== ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ ===== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--ui-bg);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--ui-border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  color: var(--text-main);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: transform 0.15s ease, background 0.15s ease;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
  font-family: inherit;
}
.theme-toggle:hover { transform: translateY(-1px); background: rgba(128,128,128,0.12); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg { display: block; width: 22px; height: 22px; }

/* ===== БАЗА ДЛЯ ПУЛЬТОВ ===== */
body.dashboard-body,
body.mini-body {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  box-sizing: border-box;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
body.dashboard-body::-webkit-scrollbar { display: none; }

/* Логотип */
.logo { display: none; }
@media (min-height: 800px) {
  .logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #d92b3a;
    font-family: Arial, Helvetica, sans-serif;
    pointer-events: none;
    flex-shrink: 0;
    margin-bottom: 40px;
  }
  .logo svg { display: block; width: 32px; height: 32px; stroke: currentColor; stroke-width: 14; fill: none; stroke-linecap: round; }
  .logo-text { font-size: 20pt; font-weight: bold; letter-spacing: 0.5px; white-space: nowrap; }
}

/* ===== СЕТКИ ПУЛЬТОВ (УНИВЕРСАЛЬНЫЕ) ===== */
.dashboard,
.mini-pult {
  --gap: 12px;
  --pad: 14px;
  --cols: 3; /* База для JS, чтобы не было мигания */

  /* МАГИЯ: Считаем доступную ширину, но не даем плитке превысить 200px */
  --tile-w: calc((100vw - (2 * var(--pad)) - (var(--cols) - 1) * var(--gap)) / var(--cols));
  --tile: min(200px, var(--tile-w));

  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile));
  grid-auto-rows: var(--tile); /* Плитки всегда идеально квадратные */
  gap: var(--gap);
  justify-content: center;
  align-content: center;
  width: 100%;
}

/* ===== ОБЩИЕ СТИЛИ ПЛИТОК ===== */
.tile,
.mini-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 20px;
  text-decoration: none;
  color: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  border: none;
  padding: 0;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(0,0,0,0.10),
              0 12px 28px rgba(0,0,0,0.08),
              inset 0 -2px 4px rgba(0,0,0,0.15),
              inset 0 2px 3px rgba(255,255,255,0.18);
}

.tile:hover,
.mini-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.14),
              0 16px 36px rgba(0,0,0,0.12),
              inset 0 -2px 4px rgba(0,0,0,0.15),
              inset 0 2px 3px rgba(255,255,255,0.18);
}

.tile:active,
.mini-tile:active {
  transform: translateY(-1px) scale(0.98);
}

.tile svg,
.mini-tile svg {
  width: 36px;
  height: 36px;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}

.tile .tile-label,
.mini-tile .label {
  font-size: 11pt;
  font-weight: bold;
  letter-spacing: 0.4px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.20);
  text-align: center;
}

/* ===== СПЕЦИФИЧНЫЕ СТИЛИ (СЧЁТЧИК) ===== */
.tile .tile-value {
  font-size: 28pt;
  font-weight: bold;
  line-height: 1;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.20);
}

.tile.wide {
  grid-column: 1 / -1;
  flex-direction: row;
  gap: 20px;
  min-height: 140px;
}

.tile.wide .tile-value { font-size: 40pt; }
.tile.wide .wide-text { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tile.wide .wide-text .tile-label { font-size: 14pt; }

/* ===== ЦВЕТА (ГЛАВНАЯ) ===== */
.tile-emergency  { background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%); }
.tile-addiction  { background: linear-gradient(135deg, #e63946 0%, #b91c1c 100%); }
.tile-overload   { background: linear-gradient(135deg, #db2777 0%, #9d174d 100%); }
.tile-understand { background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%); }
.tile-breath     { background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%); }
.tile-abyss      { background: linear-gradient(135deg, #334155 0%, #1e293b 100%); }
.tile-counter    { background: linear-gradient(135deg, #22c55e 0%, #15803d 100%); }

/* ===== ЦВЕТА (МИНИ-ПУЛЬТЫ) ===== */
.mini-tile.alcohol    { background: linear-gradient(135deg, #e63946 0%, #b91c1c 100%); }
.mini-tile.vape       { background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%); }
.mini-tile.cigarettes { background: linear-gradient(135deg, #b45309 0%, #78350f 100%); }
.mini-tile.scroll     { background: linear-gradient(135deg, #ea580c 0%, #9a3412 100%); }
.mini-tile.food       { background: linear-gradient(135deg, #84cc16 0%, #4d7c0f 100%); }

.mini-tile.trgz     { background: linear-gradient(135deg, #8b5cf6 0%, #5b21b6 100%); }
.mini-tile.doctors { background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%); }
.mini-tile.brain    { background: linear-gradient(135deg, #0d9488 0%, #115e59 100%); }
.mini-tile.body     { background: linear-gradient(135deg, #b45309 0%, #78350f 100%); }
.mini-tile.habit    { background: linear-gradient(135deg, #10b981 0%, #047857 100%); }
.mini-tile.bottom   { background: linear-gradient(135deg, #b91c1c 0%, #7f1d1d 100%); }

.mini-tile.stress    { background: linear-gradient(135deg, #db2777 0%, #9d174d 100%); }
.mini-tile.prokrutka { background: linear-gradient(135deg, #ea580c 0%, #9a3412 100%); }

/* Призрачная плитка для заполнения пустых мест */
.mini-tile.ghost {
  visibility: visible; /* Делаем видимой */
  pointer-events: none; /* Но кликнуть нельзя */
  box-shadow: none;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  opacity: 0.4; /* Сильно приглушаем */
}

/* ===== АДАПТИВ (УМЕНЬШЕНИЕ ОТСТУПОВ И ШРИФТОВ) ===== */
@media (max-width: 500px) {
  .theme-toggle { top: 14px; right: 14px; width: 44px; height: 44px; }
  .theme-toggle svg { width: 20px; height: 20px; }

  .dashboard, 
  .mini-pult { 
    --gap: 10px; 
    --pad: 12px; 
  }

  .tile svg, .mini-tile svg { width: 32px; height: 32px; }
  .tile .tile-label, .mini-tile .label { font-size: 10pt; }
  
  .tile .tile-value { font-size: 24pt; }
  .tile.wide .tile-value { font-size: 34pt; }
  .tile.wide .wide-text .tile-label { font-size: 12pt; }
}

@media (max-height: 600px) {
  .tile svg, .mini-tile svg { width: 26px; height: 26px; }
  .tile .tile-label, .mini-tile .label { font-size: 9pt; }
  .tile .tile-value { font-size: 20pt; }
  .tile.wide .tile-value { font-size: 28pt; }
}
