/* =========================================================
   Night Paradise — Rules Extra Styles
   ========================================================= */

/* ----- Meta-блок ----- */
.rules-meta {
  padding: 1.25rem 1.5rem;
  border-radius: 14px;
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.sev-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
  font-size: .82rem;
}
.sev-legend .hint {
  color: rgba(255,255,255,.45);
  margin-right: .25rem;
}
.sev-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .18rem .6rem;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
  letter-spacing: .025em;
}
.sev-badge .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  display: inline-block;
}
.sev-badge.sev-low  { background: rgba(74,222,128,.12);  color: #4ade80; border: 1px solid rgba(74,222,128,.28); }
.sev-badge.sev-low  .dot { background: #4ade80; }
.sev-badge.sev-med  { background: rgba(251,191,36,.12);  color: #fbbf24; border: 1px solid rgba(251,191,36,.28); }
.sev-badge.sev-med  .dot { background: #fbbf24; }
.sev-badge.sev-high { background: rgba(251,146,60,.12);  color: #fb923c; border: 1px solid rgba(251,146,60,.28); }
.sev-badge.sev-high .dot { background: #fb923c; }
.sev-badge.sev-crit { background: rgba(248,113,113,.12); color: #f87171; border: 1px solid rgba(248,113,113,.28); }
.sev-badge.sev-crit .dot { background: #f87171; }

.rules-tip {
  display: flex;
  align-items: flex-start;
  gap: .55rem;
  padding: .65rem 1rem;
  background: rgba(139,92,246,.09);
  border: 1px solid rgba(139,92,246,.22);
  border-radius: 9px;
  font-size: .87rem;
  line-height: 1.55;
  color: rgba(255,255,255,.8);
}
.rules-tip .tip-icon { font-size: 1rem; flex-shrink: 0; margin-top: .05rem; }

.rules-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
}

/* Поиск */
.rules-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.rules-search-wrap .search-icon {
  position: absolute;
  left: .8rem;
  pointer-events: none;
  font-size: .9rem;
  opacity: .5;
}
#rulesFilter {
  flex: 1;
  padding: .55rem 1rem .55rem 2.3rem;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.11);
  border-radius: 9px;
  color: #e2e8f0;
  font-size: .9rem;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
#rulesFilter:focus {
  border-color: var(--accent, #8b5cf6);
  box-shadow: 0 0 0 3px rgba(139,92,246,.14);
}
#rulesFilterCount {
  font-size: .8rem;
  white-space: nowrap;
  min-width: 5.5rem;
  text-align: right;
  color: rgba(255,255,255,.45);
}

/* ----- Layout ----- */
.rules-layout {
  display: grid;
  grid-template-columns: 195px 1fr;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 780px) {
  .rules-layout { grid-template-columns: 1fr; }
  .rules-toc    { position: static !important; }
}

/* ----- TOC ----- */
.rules-toc {
  position: sticky;
  top: 4.5rem;
  border-radius: 13px;
  padding: 1rem .85rem;
  display: flex;
  flex-direction: column;
  gap: .05rem;
}
.toc-title {
  font-family: 'Orbitron', sans-serif;
  font-size: .67rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  margin-bottom: .55rem;
  padding: 0 .45rem;
}
.toc-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .42rem .6rem;
  border-radius: 8px;
  font-size: .82rem;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: background .15s, color .15s;
}
.toc-link:hover,
.toc-link.active {
  background: rgba(139,92,246,.17);
  color: #c4b5fd;
}
.toc-num {
  width: 1.45rem; height: 1.45rem;
  border-radius: 50%;
  background: rgba(139,92,246,.18);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  flex-shrink: 0; color: #a78bfa;
}
.toc-count {
  margin-left: auto;
  font-size: .68rem;
  color: rgba(255,255,255,.3);
  background: rgba(255,255,255,.07);
  padding: .08rem .35rem;
  border-radius: 999px;
}

/* ----- Аккордеон ----- */
.rule-acc {
  border-radius: 13px;
  margin-bottom: .75rem;
  overflow: hidden;
  transition: box-shadow .2s;
}
.rule-acc:hover { box-shadow: 0 4px 22px rgba(139,92,246,.13); }

.rule-acc summary {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .9rem 1.1rem;
  cursor: pointer;
  user-select: none;
  list-style: none;
  border-radius: 13px;
  transition: background .15s;
}
.rule-acc summary::-webkit-details-marker { display: none; }
.rule-acc summary:hover { background: rgba(255,255,255,.035); }

.acc-icon { font-size: 1.1rem; flex-shrink: 0; }
.rule-title { font-size: .97rem; font-weight: 600; flex: 1; }
.acc-badge {
  font-size: .7rem;
  color: rgba(255,255,255,.38);
  background: rgba(255,255,255,.07);
  padding: .13rem .5rem;
  border-radius: 999px;
}
.acc-arrow {
  font-size: .72rem;
  color: rgba(255,255,255,.38);
  transition: transform .25s ease;
  flex-shrink: 0;
}
.rule-acc[open] .acc-arrow { transform: rotate(180deg); }

/* ----- Список правил ----- */
.rules-list {
  list-style: none;
  padding: .25rem .8rem .8rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .32rem;
}
.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: .7rem;
  padding: .58rem .9rem;
  border-radius: 9px;
  background: rgba(255,255,255,.028);
  border-left: 3px solid rgba(255,255,255,.1);
  font-size: .89rem;
  line-height: 1.55;
  transition: background .15s, border-color .15s, transform .15s;
}
.rules-list li:hover {
  background: rgba(255,255,255,.05);
  transform: translateX(3px);
}

/* Severity styling */
.rules-list li[data-sev="info"] { border-left-color: rgba(148,163,184,.35); }
.rules-list li[data-sev="low"]  { border-left-color: #4ade80; background: rgba(74,222,128,.04); }
.rules-list li[data-sev="med"]  { border-left-color: #fbbf24; background: rgba(251,191,36,.04); }
.rules-list li[data-sev="high"] { border-left-color: #fb923c; background: rgba(251,146,60,.05); }
.rules-list li[data-sev="crit"] { border-left-color: #f87171; background: rgba(248,113,113,.06); }

.rules-list .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  padding: .13rem .4rem;
  background: rgba(139,92,246,.18);
  color: #c4b5fd;
  border-radius: 6px;
  font-size: .74rem;
  font-weight: 700;
  font-family: 'Orbitron', monospace;
  flex-shrink: 0;
  letter-spacing: .04em;
}
.rule-text { flex: 1; }
mark, .mark {
  background: rgba(251,191,36,.22);
  color: #fde68a;
  border-radius: 3px;
  padding: 0 2px;
}

/* Compact mode */
.rules-content.dense .rules-list li {
  padding: .33rem .75rem;
  font-size: .82rem;
}
.rules-content.dense .rules-list { gap: .18rem; }

/* ----- Penalty Matrix ----- */
.penalty-matrix {
  margin-top: 1.5rem;
  border-radius: 13px;
  overflow: hidden;
}
.penalty-matrix > summary {
  padding: .9rem 1.25rem;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: .6rem;
  list-style: none;
  font-size: .95rem;
}
.penalty-matrix > summary::-webkit-details-marker { display: none; }

#penaltyTableWrap {
  padding: 0 .85rem .85rem;
  overflow-x: auto;
}
#penaltyTableWrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: .84rem;
}
#penaltyTableWrap th {
  padding: .6rem .85rem;
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: rgba(255,255,255,.45);
  background: rgba(255,255,255,.04);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
#penaltyTableWrap td {
  padding: .58rem .85rem;
  border-bottom: 1px solid rgba(255,255,255,.05);
  vertical-align: middle;
  color: rgba(255,255,255,.85);
}
#penaltyTableWrap tr:last-child td { border-bottom: none; }
#penaltyTableWrap tr:hover td    { background: rgba(255,255,255,.03); }

/* Severity row left border */
#penaltyTableWrap tr[data-sev="low"]  td:first-child { border-left: 3px solid #4ade80; }
#penaltyTableWrap tr[data-sev="med"]  td:first-child { border-left: 3px solid #fbbf24; }
#penaltyTableWrap tr[data-sev="high"] td:first-child { border-left: 3px solid #fb923c; }
#penaltyTableWrap tr[data-sev="crit"] td:first-child { border-left: 3px solid #f87171; }

.rule-code-badge {
  font-family: 'Orbitron', monospace;
  font-size: .73rem;
  color: #c4b5fd;
}
.penalty-cell.max { color: rgba(255,255,255,.55); font-size: .82rem; }
.sev-cell { text-align: center; font-size: 1rem; }

/* ----- RulePicker ----- */
.rp {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 11px;
  overflow: hidden;
  background: rgba(10,10,15,.55);
}
.rp-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
  padding: .5rem .7rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  min-height: 2.9rem;
}
.rp-input {
  flex: 1; min-width: 130px;
  background: none; border: none; outline: none;
  color: #e2e8f0; font-size: .87rem;
  padding: .2rem .15rem;
}
.rp-input::placeholder { color: rgba(255,255,255,.32); }
.rp-clear {
  background: none; border: none;
  color: rgba(255,255,255,.38);
  cursor: pointer; font-size: .9rem;
  padding: .2rem .35rem; border-radius: 5px;
  transition: color .15s, background .15s;
}
.rp-clear:hover { color: #f87171; background: rgba(248,113,113,.1); }
.rp-dropdown {
  max-height: 220px;
  overflow-y: auto;
  padding: .35rem;
}
.rp-dropdown::-webkit-scrollbar { width: 4px; }
.rp-dropdown::-webkit-scrollbar-thumb { background: rgba(139,92,246,.4); border-radius: 2px; }
.rp-group {
  font-size: .7rem;
  text-transform: uppercase; letter-spacing: .08em;
  color: rgba(255,255,255,.32);
  padding: .42rem .65rem .18rem;
  font-weight: 600;
}
.rp-item {
  display: flex; align-items: center; gap: .55rem;
  padding: .43rem .7rem;
  border-radius: 8px; cursor: pointer;
  font-size: .86rem; color: rgba(255,255,255,.8);
  transition: background .12s;
}
.rp-item:hover   { background: rgba(139,92,246,.14); }
.rp-item.selected{ background: rgba(139,92,246,.2); }
.rp-item .code {
  min-width: 2.5rem;
  font-size: .74rem; color: #a78bfa;
  font-weight: 700; font-family: 'Orbitron', monospace;
  flex-shrink: 0;
}
.rp-item .rp-check {
  margin-left: auto;
  color: #a78bfa; font-weight: 700; font-size: .85rem;
  flex-shrink: 0;
}
.rp-empty {
  padding: .8rem;
  text-align: center;
  color: rgba(255,255,255,.35);
  font-size: .85rem;
}
.rp-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: .45rem .7rem;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .79rem;
  flex-wrap: wrap; gap: .4rem;
}
.rp-right { display: flex; flex-wrap: wrap; gap: .35rem; }

/* Chips (rp-chips) */
.rp-chips .chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .58rem;
  background: rgba(139,92,246,.2);
  border: 1px solid rgba(139,92,246,.35);
  border-radius: 999px;
  font-size: .76rem; color: #c4b5fd;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rp-chips .chip:hover { background: rgba(139,92,246,.35); border-color: rgba(167,139,250,.55); }

/* ----- Print ----- */
@media print {
  .rules-actions, .rules-search-wrap, .rules-toc,
  .rp, #rulePicker, .penalty-matrix > summary { display: none !important; }
  .rules-layout  { display: block !important; }
  .rule-acc      { box-shadow: none !important; border: 1px solid #ccc !important; margin-bottom: .5rem; }
  .rules-list li { break-inside: avoid; background: none !important; border-left-width: 2px !important; }
  details, details > * { display: block !important; }
}
