/* EPS - karta se stavem, podstranka se stavovym kruhem, tlacitky a cidly, nastaveni, bypass a logy
   Spolecne prvky (.TopBar, .ItemIconBox, .ItemChevron, .Toggle, .OptLabel, .OptList, .OptItem) jsou v css/style.css
   Stav ridi trida EpsStOk / EpsStAlarm / EpsStServ (nastavuje script.js) */

/* ===== Barvy stavu ===== */
:root {
    --eps-ok: #2ea84a;        --eps-ok-soft: #e4f5e8;      /* Klidovy stav */
    --eps-warn: #e39a26;      --eps-warn-soft: #fcf1df;    /* Upozorneni */
    --eps-alarm: #d9443a;     --eps-alarm-soft: #fbe5e3;   /* Poplach, sabotaz */
    --eps-alarm-pulse: #f7d2ce;                            /* Vrchol pulzovani pozadi karty pri poplachu */
    --eps-serv: #7b68c9;      --eps-serv-soft: #eeebf9;    /* Servisni rezim */
    --eps-idle-soft: #eef0f2;                              /* Neutralni podklad */
}

html[data-theme="dark"] {
    --eps-ok: #3dba5a;        --eps-ok-soft: #15301d;
    --eps-warn: #eaa53a;      --eps-warn-soft: #3a2c14;
    --eps-alarm: #e5534b;     --eps-alarm-soft: #3d1a17;
    --eps-alarm-pulse: #4a1f1c;
    --eps-serv: #9583e0;      --eps-serv-soft: #262141;
    --eps-idle-soft: #232a31;
}

.EpsStOk    { --eps-st: var(--eps-ok);    --eps-st-soft: var(--eps-ok-soft); }
.EpsStAlarm { --eps-st: var(--eps-alarm); --eps-st-soft: var(--eps-alarm-soft); }
.EpsStServ  { --eps-st: var(--eps-serv);  --eps-st-soft: var(--eps-serv-soft); }

/* ===== Karta ve vizualizaci ===== */
.EpsItem {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.EpsItemText {
    flex: 1;
    min-width: 0;
}

.EpsItemName {
    font-size: var(--item-name-fs);
    font-weight: var(--item-name-fw);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.EpsItemDesc {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: var(--item-desc-fs);
    font-weight: 600;
    color: var(--eps-st, var(--muted));
    white-space: nowrap;
    overflow: hidden;
}

/* Barevna tecka pred stavem, ma barvu textu */
.EpsItemDesc i {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.EpsItemInfo {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

/* Poplach - cerveny ramecek, pulzujici pozadi (jen jemne, aby text zustal citelny) a blikajici tecka */
.EpsItem.EpsStAlarm {
    box-shadow: 0 0 0 2px var(--eps-alarm), var(--shadow);
    animation: EpsCardPulse 1.4s ease-in-out infinite;
}

.EpsItem.EpsStAlarm .EpsItemDesc i {
    animation: EpsBlink 1s infinite;
}

/* ===== Podstranky - sirka jako ostatni podstranky (do 480 px roztazeni zajisti css/style.css),
   i na desktopu vse v jednom sloupci ===== */
.EpsMain,
.EpsOptions,
.EpsBypassList,
.EpsLogsList {
    width: 420px;
    margin-bottom: 16px;
}

.EpsLayout {
    display: flex;
    flex-direction: column;
}

/* ===== Stavovy kruh ===== */
.EpsHero {
    position: relative;
    width: 184px;
    height: 184px;
    margin: 4px auto 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Pulzujici podklad pri poplachu */
.EpsStAlarm .EpsHero::before {
    content: '';
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: var(--eps-st-soft);
    animation: EpsPulse 1.4s ease-out infinite;
}

.EpsRing {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.EpsRing circle {
    fill: none;
    stroke-width: 10;
}

.EpsRingBg {
    stroke: var(--line);
}

/* Plny kruh v barve stavu */
.EpsRingVal {
    stroke: var(--eps-st);
    stroke-linecap: round;
    transition: stroke .3s;
}

.EpsHeroCenter {
    position: relative;
    text-align: center;
    color: var(--eps-st);
    max-width: 150px;
}

.EpsIco {
    display: none;
    width: 46px;
    height: 46px;
    margin: 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.EpsStOk .EpsIcoOk,
.EpsStAlarm .EpsIcoAlarm,
.EpsStServ .EpsIcoServ {
    display: block;
}

.EpsHeroState {
    display: block;
    margin-top: 2px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}

.EpsHeroSub {
    display: block;
    max-width: 124px;
    margin: 2px auto 0;
    font-size: 13px;
    line-height: 1.3;
    color: var(--muted);
}

.EpsInfo {
    min-height: 18px;
    margin-top: 8px;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

.EpsInfo b {
    color: var(--text);
    font-weight: 600;
}

/* ===== Upozorneni ===== */
.EpsNote {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-top: 10px;
    padding: 9px 11px;
    border-radius: 12px;
    background: var(--eps-warn-soft);
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
}

.EpsNote svg {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--eps-warn);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.EpsNote.EpsNoteRed {
    background: var(--eps-alarm-soft);
}

.EpsNote.EpsNoteRed svg {
    stroke: var(--eps-alarm);
}

.EpsNoteText {
    flex: 1;
    min-width: 0;
}

/* ===== Akcni tlacitka ===== */
.EpsActs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.EpsBtn {
    flex: 1 1 100%;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .1s, opacity .2s, filter .15s;
}

.EpsBtn svg {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.EpsBtn:active {
    transform: scale(.97);
}

.EpsBtnCommit {
    background: var(--eps-alarm);
    color: #fff;
}

.EpsBtnFalse {
    background: transparent;
    color: var(--text);
    box-shadow: inset 0 0 0 1.5px var(--line);
}

/* Po kliknuti, nez server posle nova data */
.EpsBtn.ItemPending {
    opacity: .55;
    cursor: default;
    animation: EpsPending 1s infinite alternate;
}

@media only screen and (hover: hover) and (pointer: fine) {
    .EpsBtn:hover {
        filter: brightness(1.06);
    }
}

/* ===== Filtr cidel ===== */
.EpsFilter {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 18px 0 8px;
}

.EpsChip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 30px;
    padding: 0 11px;
    border-radius: 15px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.EpsChip b {
    font-weight: 600;
}

.EpsChip i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.EpsChipAct i { background: var(--eps-alarm); }
.EpsChipOk i  { background: var(--eps-ok); }
.EpsChipByp i { background: var(--off); }

.EpsChip.EpsChipSel {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Filtrovani seznamu podle atributu EpsFlt */
.EpsMain[EpsFlt="act"] .EpsSensor:not(.EpsSnAct),
.EpsMain[EpsFlt="ok"] .EpsSensor:not(.EpsSnOk),
.EpsMain[EpsFlt="byp"] .EpsSensor:not(.EpsSnByp) {
    display: none;
}

/* ===== Seznam cidel ===== */
.EpsSensors {
    padding: 0 14px;
}

.EpsSensor {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 56px;
    padding: 8px 0;
    border-top: 1px solid var(--line);
}

/* Prvni viditelne cidlo bez oddelovaci cary (tridu nastavuje script.js podle filtru) */
.EpsSensors .EpsSensor.EpsFirst {
    border-top: 0;
}

.EpsSensorIcon {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.EpsSensorIcon .ItemMainIcon {
    height: 26px;
    top: 0;
}

.EpsSensorText {
    flex: 1;
    min-width: 0;
}

.EpsSensorName {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.EpsSensorType {
    margin-top: 1px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Stitek stavu cidla */
.EpsPill {
    flex: 0 0 auto;
    height: 24px;
    padding: 0 9px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--eps-idle-soft);
    color: var(--muted);
}

.EpsSnOk .EpsPill {
    background: var(--eps-ok-soft);
    color: var(--eps-ok);
}

.EpsSnAct .EpsPill {
    background: var(--eps-alarm-soft);
    color: var(--eps-alarm);
}

.EpsSnByp .EpsSensorIcon,
.EpsSnByp .EpsSensorText {
    opacity: .55;
}

/* ===== Nastaveni ===== */
.EpsOptIcon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    color: var(--accent);
}

.EpsOptIcon svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.EpsOptIconServ {
    background: var(--eps-serv-soft);
    color: var(--eps-serv);
}

.EpsOptText {
    flex: 1;
    min-width: 0;
    padding: 9px 0;
}

.EpsOptText small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
}

.EpsOptValue {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--muted);
}

.EpsOptService.ItemOn .Toggle {
    background: var(--eps-serv);
}

/* Polozka bez opravneni; pokud je skryta prvni polozka, druha je bez oddelovaci cary */
.OptItem.EpsHidden {
    display: none;
}

.OptItem.EpsHidden:first-child + .OptItem {
    border-top: 0;
}

/* Blokace vizualizace - ovladani neni mozne */
.EpsDisabled .OptItem,
.EpsDisabled .EpsSegBtn {
    pointer-events: none;
    opacity: .5;
}

/* ===== Bypass ===== */
.EpsBypass {
    padding: 0 14px;
}

.EpsBpItem {
    padding: 12px 0;
    border-top: 1px solid var(--line);
}

.EpsBpItem:first-child {
    border-top: 0;
}

.EpsBpItem .EpsSensor {
    min-height: 0;
    padding: 0;
    border: 0;
}

/* Dvoustavovy prepinac Hlida / Bypass */
.EpsSeg {
    display: flex;
    margin-top: 8px;
    padding: 2px;
    border-radius: 10px;
    background: var(--line);
}

.EpsSegBtn {
    flex: 1;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .15s, color .15s, opacity .2s;
}

.EpsSegBtn.EpsSegOn {
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
    cursor: default;
}

.EpsSegBtn.EpsSegB1.EpsSegOn {
    color: var(--eps-alarm);
}

.EpsSegBtn.ItemPending {
    background: var(--card);
    opacity: .55;
}

.EpsHint {
    margin: 10px 4px 0;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    line-height: 1.4;
}

/* ===== Logy ===== */
.EpsLogList {
    padding: 0 14px;
}

.EpsLog {
    display: flex;
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    font-size: 13px;
    line-height: 1.4;
}

.EpsLog:first-child {
    border-top: 0;
}

.EpsLogTime {
    flex: 0 0 60px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.EpsLogText {
    flex: 1;
    min-width: 0;
}

.EpsEmpty {
    margin-top: 10px;
    padding: 28px 14px;
    border-radius: var(--radius);
    background: var(--card);
    box-shadow: var(--shadow);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

/* ===== Animace ===== */
@keyframes EpsBlink {
    50% { opacity: .25; }
}

@keyframes EpsPulse {
    0% { transform: scale(.85); opacity: .9; }
    100% { transform: scale(1.12); opacity: 0; }
}

@keyframes EpsCardPulse {
    0%, 100% { background-color: var(--card); }
    50% { background-color: var(--eps-alarm-pulse); }
}

@keyframes EpsPending {
    to { opacity: .35; }
}
