/* EZS - 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 EzsStDis / EzsStArm / EzsStPart / EzsStWait / EzsStAlarm / EzsStServ (nastavuje script.js) */

/* ===== Barvy stavu ===== */
:root {
    --ezs-dis: #8a939d;       --ezs-dis-soft: #eef0f2;     /* Odjisteno */
    --ezs-arm: #2ea84a;       --ezs-arm-soft: #e4f5e8;     /* Zajisteno */
    --ezs-part: #1a8fb0;      --ezs-part-soft: #e3f2f7;    /* Castecne zajisteno */
    --ezs-wait: #e39a26;      --ezs-wait-soft: #fcf1df;    /* Odchodove / prichodove zpozdeni */
    --ezs-alarm: #d9443a;     --ezs-alarm-soft: #fbe5e3;   /* Poplach, sabotaz */
    --ezs-alarm-pulse: #f7d2ce;                            /* Vrchol pulzovani pozadi karty pri poplachu */
    --ezs-serv: #7b68c9;      --ezs-serv-soft: #eeebf9;    /* Servisni rezim */
}

html[data-theme="dark"] {
    --ezs-dis: #8f99a3;       --ezs-dis-soft: #232a31;
    --ezs-arm: #3dba5a;       --ezs-arm-soft: #15301d;
    --ezs-part: #45b3d3;      --ezs-part-soft: #16323c;
    --ezs-wait: #eaa53a;      --ezs-wait-soft: #3a2c14;
    --ezs-alarm: #e5534b;     --ezs-alarm-soft: #3d1a17;
    --ezs-alarm-pulse: #4a1f1c;
    --ezs-serv: #9583e0;      --ezs-serv-soft: #262141;
}

.EzsStDis   { --ezs-st: var(--ezs-dis);   --ezs-st-soft: var(--ezs-dis-soft); }
.EzsStArm   { --ezs-st: var(--ezs-arm);   --ezs-st-soft: var(--ezs-arm-soft); }
.EzsStPart  { --ezs-st: var(--ezs-part);  --ezs-st-soft: var(--ezs-part-soft); }
.EzsStWait  { --ezs-st: var(--ezs-wait);  --ezs-st-soft: var(--ezs-wait-soft); }
.EzsStAlarm { --ezs-st: var(--ezs-alarm); --ezs-st-soft: var(--ezs-alarm-soft); }
.EzsStServ  { --ezs-st: var(--ezs-serv);  --ezs-st-soft: var(--ezs-serv-soft); }

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

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

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

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

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

/* Zbyvajici cas zpozdeni - jen pri odpoctu (trida EzsCounting), cislo plni script.js */
.EzsItemTime {
    display: none;
    flex: 0 0 auto;
    padding: 1px 7px;
    border-radius: 9px;
    background: var(--ezs-st-soft);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.EzsItem.EzsCounting .EzsItemTime {
    display: inline-block;
}

.EzsItemInfo {
    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 */
.EzsItem.EzsStAlarm {
    box-shadow: 0 0 0 2px var(--ezs-alarm), var(--shadow);
    animation: EzsCardPulse 1.4s ease-in-out infinite;
}

.EzsItem.EzsStAlarm .EzsItemDesc i,
.EzsItem.EzsStWait .EzsItemDesc i {
    animation: EzsBlink 1s infinite;
}

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

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

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

/* Pulzujici podklad pri poplachu a prichodovem zpozdeni */
.EzsStAlarm .EzsHero::before,
.EzsEntry .EzsHero::before {
    content: '';
    position: absolute;
    inset: 14px;
    border-radius: 50%;
    background: var(--ezs-st-soft);
    animation: EzsPulse 1.4s ease-out infinite;
}

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

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

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

/* Prubeh - plny kruh v barve stavu, pri odpoctu ubyva (stroke-dashoffset nastavuje script.js) */
.EzsRingVal {
    stroke: var(--ezs-st);
    stroke-linecap: round;
    stroke-dasharray: 515.22;
    transition: stroke-dashoffset .25s linear, stroke .3s;
}

/* Odjisteno - jen sedy podklad */
.EzsStDis .EzsRingVal {
    stroke: transparent;
}

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

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

.EzsStDis .EzsIcoDis,
.EzsStArm .EzsIcoArm,
.EzsStPart .EzsIcoPart,
.EzsStWait .EzsIcoWait,
.EzsStAlarm .EzsIcoAlarm,
.EzsStServ .EzsIcoServ {
    display: block;
}

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

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

/* Odpocet - mensi ikona, velke cislo */
.EzsCount {
    display: none;
    font-size: 34px;
    font-weight: 600;
    line-height: 1.1;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.EzsCounting .EzsCount {
    display: block;
}

.EzsCounting .EzsIco {
    width: 28px;
    height: 28px;
}

.EzsCounting .EzsHeroState {
    font-size: 15px;
}

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

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

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

.EzsNote svg {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--ezs-wait);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.EzsNote.EzsNoteRed {
    background: var(--ezs-alarm-soft);
}

.EzsNote.EzsNoteRed svg {
    stroke: var(--ezs-alarm);
}

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

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

.EzsBtn {
    flex: 1 1 0;
    min-width: 120px;
    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;
}

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

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

.EzsBtnArm {
    background: var(--ezs-arm);
    color: #fff;
}

.EzsBtnPart {
    background: var(--card);
    color: var(--ezs-part);
    box-shadow: inset 0 0 0 1.5px var(--ezs-part);
}

.EzsBtnDis {
    background: var(--text);
    color: var(--bg);
}

/* Pri prichodovem zpozdeni je odjisteni hlavni akce - zelene a vetsi (trida EzsEntry nastavuje script.js) */
.EzsEntry .EzsBtnDis {
    height: 58px;
    background: var(--ezs-arm);
    color: #fff;
    font-size: 16px;
}

.EzsBtnCommit {
    flex-basis: 100%;
    background: var(--ezs-alarm);
    color: #fff;
}

.EzsBtnFalse {
    flex-basis: 100%;
    background: transparent;
    color: var(--text);
    box-shadow: inset 0 0 0 1.5px var(--line);
}

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

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

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

.EzsChip {
    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;
}

.EzsChip b {
    font-weight: 600;
}

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

.EzsChipAct i { background: var(--ezs-wait); }
.EzsChipOk i  { background: var(--ezs-arm); }
.EzsChipByp i { background: var(--off); }

.EzsChip.EzsChipSel {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* Filtrovani seznamu podle atributu EzsFlt */
.EzsMain[EzsFlt="act"] .EzsSensor:not(.EzsSnAct),
.EzsMain[EzsFlt="ok"] .EzsSensor:not(.EzsSnOk),
.EzsMain[EzsFlt="byp"] .EzsSensor:not(.EzsSnByp) {
    display: none;
}

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

.EzsSensor {
    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) */
.EzsSensors .EzsSensor.EzsFirst {
    border-top: 0;
}

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

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

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

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

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

/* Stitek stavu cidla */
.EzsPill {
    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(--ezs-dis-soft);
    color: var(--muted);
}

.EzsSnOk .EzsPill {
    background: var(--ezs-arm-soft);
    color: var(--ezs-arm);
}

.EzsSnAct .EzsPill {
    background: var(--ezs-wait-soft);
    color: var(--ezs-wait);
}

.EzsSnRed .EzsPill {
    background: var(--ezs-alarm-soft);
    color: var(--ezs-alarm);
}

.EzsSnByp .EzsSensorIcon,
.EzsSnByp .EzsSensorText {
    opacity: .55;
}

/* ===== Nastaveni ===== */
.EzsOptIcon {
    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);
}

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

.EzsOptIconServ {
    background: var(--ezs-serv-soft);
    color: var(--ezs-serv);
}

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

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

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

.EzsOptService.ItemOn .Toggle {
    background: var(--ezs-serv);
}

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

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

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

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

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

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

.EzsBpItem .EzsSensor {
    min-height: 0;
    padding: 0;
    border: 0;
}

/* Trojstavovy prepinac Hlida / Jednorazove / Trvale */
.EzsSeg {
    display: flex;
    margin-top: 8px;
    padding: 2px;
    border-radius: 10px;
    background: var(--line);
}

.EzsSegBtn {
    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;
}

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

.EzsSegBtn.EzsSegB2.EzsSegOn {
    color: var(--ezs-wait);
}

.EzsSegBtn.EzsSegB1.EzsSegOn {
    color: var(--ezs-alarm);
}

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

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

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

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

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

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

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

.EzsEmpty {
    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 EzsBlink {
    50% { opacity: .25; }
}

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

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

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