/* Zavlahovy system - karta se zbyvajicim casem, hlavni podstranka s kruhovym odpoctem sekce, prubeh programu,
   rucni start programu / sekce, nastaveni, programy, sekce, zazimovani
   Na desktopu zustava jeden sloupec o sirce 420 px (stejne jako rekuperace)
   Spolecne prvky (.TopBar, .ItemIconBox, .ItemChevron, .Toggle, .OptLabel, .OptList, .OptItem) jsou v css/style.css
   Stav ridi trida IrrigStRun / IrrigStWait / IrrigStIdle / IrrigStBlock / IrrigStWint / IrrigStRain (nastavuje script.js) */

/* ===== Barvy stavu ===== */
:root {
    --irrig-run: #1a8fb0;      --irrig-run-soft: #e3f2f7;      /* Zaleva se */
    --irrig-wait: #e39a26;     --irrig-wait-soft: #fcf1df;     /* Ceka na plny tlak vody, pauza zazimovani */
    --irrig-idle: #8a939d;     --irrig-idle-soft: #eef0f2;     /* Nic nebezi */
    --irrig-block: #d9443a;    --irrig-block-soft: #fbe6e4;    /* Automatika blokovana */
    --irrig-wint: #7b68c9;     --irrig-wint-soft: #eeebf9;     /* Zazimovani */
    --irrig-rain: #3d8fd9;     --irrig-rain-soft: #e4effb;     /* Destove cidlo */
    --irrig-ok: #2e9d62;       --irrig-ok-soft: #e2f4ea;       /* Dokoncena sekce */
}

html[data-theme="dark"] {
    --irrig-run: #45b3d3;      --irrig-run-soft: #16323c;
    --irrig-wait: #eaa53a;     --irrig-wait-soft: #3a2c14;
    --irrig-idle: #8f99a3;     --irrig-idle-soft: #232a31;
    --irrig-block: #e5594f;    --irrig-block-soft: #3a1a18;
    --irrig-wint: #9583e0;     --irrig-wint-soft: #262141;
    --irrig-rain: #5aa3e6;     --irrig-rain-soft: #172a3d;
    --irrig-ok: #43b97a;       --irrig-ok-soft: #14301f;
}

.IrrigStRun   { --irrig-st: var(--irrig-run);   --irrig-st-soft: var(--irrig-run-soft); }
.IrrigStWait  { --irrig-st: var(--irrig-wait);  --irrig-st-soft: var(--irrig-wait-soft); }
.IrrigStIdle  { --irrig-st: var(--irrig-idle);  --irrig-st-soft: var(--irrig-idle-soft); }
.IrrigStBlock { --irrig-st: var(--irrig-block); --irrig-st-soft: var(--irrig-block-soft); }
.IrrigStWint  { --irrig-st: var(--irrig-wint);  --irrig-st-soft: var(--irrig-wint-soft); }
.IrrigStRain  { --irrig-st: var(--irrig-rain);  --irrig-st-soft: var(--irrig-rain-soft); }

/* Ikony vkladane skriptem (IRRIG_ICO) */
.IrrigIco {
    flex: 0 0 15px;
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Misto pro ikonu (plni script.js) */
.IrrigItemIco,
.IrrigNoteIco {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

.IrrigItemIco:empty {
    display: none;
}

/* Tecka stavu, pri zalevani blika */
.IrrigDot {
    display: inline-block;
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.IrrigDot.IrrigLive {
    animation: IrrigPulse 1.6s ease-in-out infinite;
}

@keyframes IrrigPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

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

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

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

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

.IrrigItemState {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

/* Zbyvajici cas sekce, v klidu cas do pristi zavlahy */
.IrrigItemTime {
    flex: 0 0 auto;
    font-size: 20px;
    font-weight: 500;
    letter-spacing: -.02em;
    font-variant-numeric: tabular-nums;
    color: var(--irrig-st, var(--text));
}

.IrrigItemTime.IrrigMuted {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--muted);
}

/* ===== Podstranky - sirka jako ostatni podstranky (do 480 px roztazeni zajisti css/style.css) ===== */
.IrrigMain,
.IrrigOptions,
.IrrigStartProgramList,
.IrrigStartSectionList,
.IrrigEditProgramList,
.IrrigEditProgram,
.IrrigEditSectionList,
.IrrigEditSection,
.IrrigFlushWater {
    width: 420px;
    margin-bottom: 16px;
}

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

/* Spolecna karta podstranek */
.IrrigCard {
    background: var(--card);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 4px 14px;
    margin-bottom: 12px;
}

.IrrigCap {
    margin: 0 4px 12px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--muted);
}

/* Nadpis sekce s odkazem / informaci vpravo */
.IrrigLabel {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.IrrigLabel em,
.IrrigLabel small {
    font-style: normal;
    letter-spacing: 0;
    text-transform: none;
}

.IrrigLabel em {
    color: var(--accent);
    cursor: pointer;
}

/* ===== Kruhovy odpocet ===== */
.IrrigGauge {
    position: relative;
    width: 210px;
    height: 194px;
    margin: 4px auto 0;
}

.IrrigGaugeSvg {
    position: absolute;
    left: 0;
    top: 0;
    width: 210px;
    height: 210px;
}

.IrrigGaugeSvg circle {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
}

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

/* Delku oblouku (stroke-dasharray) nastavuje script.js kazdou sekundu */
.IrrigGaugeVal {
    stroke: var(--irrig-st, var(--irrig-idle));
    transition: stroke-dasharray 1s linear, stroke .3s;
}

.IrrigGaugeCenter {
    position: absolute;
    left: 0;
    right: 0;
    top: 46px;
    text-align: center;
}

.IrrigGaugeKey {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.IrrigGaugeTime {
    font-size: 50px;
    font-weight: 400;
    line-height: 1;
    letter-spacing: -.03em;
    font-variant-numeric: tabular-nums;
    transition: opacity .2s;
}

.IrrigGaugeTime.IrrigLong {
    font-size: 40px;
}

/* Odpocet stoji (ceka na tlak vody) */
.IrrigPaused .IrrigGaugeTime {
    opacity: .55;
}

.IrrigGaugeMode {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 160px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--irrig-st, var(--muted));
}

.IrrigGaugeMode span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Popisky casu pod konci oblouku (konce jsou na x = 44 a 166, oblouk konci na y = 172) */
.IrrigGaugeMin,
.IrrigGaugeMax {
    position: absolute;
    bottom: 0;
    font-size: 11px;
    line-height: 14px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    transform: translateX(-50%);
}

.IrrigGaugeMin {
    left: 44px;
}

.IrrigGaugeMax {
    left: 166px;
}

/* Nazev zalevane sekce pod kruhem */
.IrrigSect {
    margin-top: 4px;
    text-align: center;
}

.IrrigSect b {
    display: block;
    font-size: 22px;
    font-weight: 600;
    line-height: 1.2;
}

.IrrigSect b:empty {
    display: none;
}

.IrrigSect span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}

/* ===== Akcni tlacitka ===== */
.IrrigActs {
    display: flex;
    gap: 10px;
    margin-top: 14px;
}

.IrrigActs:empty {
    display: none;
}

.IrrigBtn {
    flex: 1;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .1s, opacity .2s, filter .15s;
}

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

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

.IrrigBtnPri {
    background: var(--accent);
    color: #fff;
    box-shadow: none;
}

.IrrigBtnWint {
    background: var(--irrig-wint);
    color: #fff;
    box-shadow: none;
}

.IrrigBtnStop {
    color: var(--danger);
}

.IrrigBtnBig {
    height: 52px;
    font-size: 15px;
}

.IrrigBtn.ItemPending {
    opacity: .55;
    cursor: default;
}

/* Mazani - prvni klepnuti jen pozada o potvrzeni */
.IrrigBtnDel {
    background: transparent;
    box-shadow: none;
    color: var(--danger);
    height: 44px;
    margin-top: 6px;
}

.IrrigBtnDel.IrrigConfirm {
    background: var(--danger);
    color: #fff;
}

/* ===== Upozorneni ===== */
.IrrigNote {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--irrig-st-soft, var(--accent-soft));
    color: var(--text);
    font-size: 13px;
    line-height: 1.35;
}

.IrrigNote .IrrigIco {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    stroke: var(--irrig-st, var(--accent));
}

.IrrigNoteText {
    flex: 1;
    min-width: 0;
    margin: 0;
}

.IrrigNoteLink {
    flex: 0 0 auto;
    font-weight: 700;
    color: var(--irrig-st, var(--accent));
    cursor: pointer;
}

.IrrigNoteLink:empty {
    display: none;
}

.IrrigNoteLink.ItemPending {
    opacity: .55;
    cursor: default;
}

/* Upozorneni na podstrankach (bez horniho odsazeni) */
.IrrigNoteTop {
    margin: 0 0 12px;
}

/* ===== Prubeh programu / zazimovani - seznam sekci ===== */
.IrrigSeq {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

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

.IrrigSeqNum {
    flex: 0 0 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--irrig-idle-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.IrrigSeqNum svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

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

.IrrigSeqText > span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.IrrigSeqText small {
    display: block;
    font-size: 11px;
    color: var(--muted);
}

.IrrigSeq em {
    flex: 0 0 auto;
    font-style: normal;
    font-size: 13px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.IrrigSeqDone .IrrigSeqNum {
    background: var(--irrig-ok-soft);
    color: var(--irrig-ok);
}

.IrrigSeqDone .IrrigSeqText {
    color: var(--muted);
}

.IrrigSeqAct .IrrigSeqNum {
    background: var(--irrig-st, var(--accent));
    color: #fff;
}

.IrrigSeqAct .IrrigSeqText > span {
    font-weight: 700;
}

.IrrigSeqAct em {
    color: var(--irrig-st, var(--accent));
    font-weight: 700;
}

.IrrigSeqSkip .IrrigSeqText > span {
    color: var(--muted);
    text-decoration: line-through;
}

/* Prubeh aktivni sekce */
.IrrigBar {
    height: 4px;
    margin-top: 5px;
    border-radius: 2px;
    background: var(--line);
    overflow: hidden;
}

.IrrigBar i {
    display: block;
    height: 100%;
    border-radius: 2px;
    background: var(--irrig-st, var(--accent));
    transition: width 1s linear;
}

/* ===== Prehled programu na hlavni strance ===== */
.IrrigPg {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

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

.IrrigPgTime {
    flex: 0 0 48px;
    font-size: 16px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

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

.IrrigPgName {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.IrrigPgDays {
    display: flex;
    gap: 3px;
    margin-top: 3px;
}

.IrrigPgDays i {
    width: 19px;
    height: 16px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--line);
    color: var(--muted);
    font-style: normal;
    font-size: 10px;
    font-weight: 700;
}

.IrrigPgDays i.IrrigOn {
    background: var(--accent-soft);
    color: var(--accent);
}

.IrrigPg em {
    flex: 0 0 auto;
    font-style: normal;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
}

.IrrigPg.IrrigOff {
    opacity: .5;
}

.IrrigEmpty {
    padding: 12px 0;
    font-size: 13px;
    color: var(--muted);
}

/* ===== Polozky seznamu a nastaveni ===== */
.IrrigOptIcon {
    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);
}

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

.IrrigOptIconBlock {
    background: var(--irrig-block-soft);
    color: var(--irrig-block);
}

.IrrigOptIconWint {
    background: var(--irrig-wint-soft);
    color: var(--irrig-wint);
}

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

.IrrigOptText > span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.IrrigOptText small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.OptItem.IrrigOff .IrrigOptText > span {
    color: var(--muted);
}

/* Po kliknuti, nez server posle nova data (prepinac zobrazi mezistav sam) */
.OptItem.ItemPending {
    pointer-events: none;
}

/* Kulate tlacitko spusteni v seznamu */
.IrrigPlay {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
}

.IrrigPlay svg {
    width: 16px;
    height: 16px;
    margin-left: 2px;
    fill: currentColor;
}

/* Pridat polozku */
.IrrigAdd {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    border-top: 1px dashed var(--line);
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

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

.IrrigAdd svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

/* ===== Krokovac (-, hodnota, +) ===== */
.IrrigStepper {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 4px;
}

.IrrigStepper b {
    min-width: 64px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.IrrigStepBtn {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.IrrigStepBtn:active {
    background: var(--hover);
}

.IrrigStepperSm b {
    min-width: 54px;
    font-size: 14px;
}

/* Radek formulare (nazev vlevo, ovladani vpravo) */
.IrrigField {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 54px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
    font-size: 14px;
}

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

.IrrigFieldName {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.IrrigFieldName.IrrigMuted {
    color: var(--muted);
}

.IrrigFieldSum {
    font-weight: 700;
}

/* Prepinac v radku formulare */
.IrrigField.IrrigSwitch {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Rolovaci vyber casu startu - vzhled knihovny Picker jako obdobi v termostatu (css/picker.css se neupravuje) */
.IrrigTimePicker {
    flex: 0 0 104px;
    width: 104px;
}

.IrrigTimePicker .picker {
    background: transparent;
    color: var(--text);
    font-size: 15px;
}

.IrrigTimePicker .picker-dialog {
    background: var(--bg);
    border: 0;
    border-radius: 10px;
}

.IrrigTimePicker .picker-cell + .picker-cell {
    border-left: 1px solid var(--line);
}

.IrrigTimePicker .picker-cell::before,
.IrrigTimePicker .picker-cell::after {
    background-image: none;
}

/* Prechody nahore a dole v barve pozadi vyberu */
.IrrigTimePicker .picker-cell__body::before {
    background-image: linear-gradient(to top, transparent, var(--bg));
}

.IrrigTimePicker .picker-cell__body::after {
    background-image: linear-gradient(to bottom, transparent, var(--bg));
}

.IrrigTimePicker .picker-item {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.IrrigTimePicker .picker-picked {
    color: var(--accent);
    font-weight: 700;
}

/* Nazev programu / sekce */
.IrrigInput {
    display: block;
    width: 100% !important;
    height: 46px;
    margin: 0 !important;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    outline: none;
}

/* ===== Chipy ===== */
.IrrigChips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
}

.IrrigChip {
    display: inline-flex;
    align-items: center;
    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;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.IrrigChip:active {
    background: var(--hover);
}

.IrrigChip.IrrigChipSel {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

/* ===== Dny v tydnu ===== */
.IrrigDays {
    display: flex;
    gap: 5px;
    margin-bottom: 4px;
}

.IrrigDay {
    flex: 1;
    height: 34px;
    border-radius: 17px;
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.IrrigDay.IrrigDayOn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

    .IrrigStepBtn:hover,
    .IrrigChip:hover,
    .IrrigAdd:hover {
        background: var(--hover);
    }
}

/* ===== Blokace ovladani ze serveru - podstranky jen pro cteni ===== */
.IrrigDisabled .IrrigBtn,
.IrrigDisabled .IrrigPlay,
.IrrigDisabled .IrrigAdd,
.IrrigDisabled .IrrigStepBtn,
.IrrigDisabled .IrrigChip,
.IrrigDisabled .IrrigDay,
.IrrigDisabled .IrrigSwitch,
.IrrigDisabled .IrrigTimePicker,
.IrrigDisabled .IrrigNoteLink,
.IrrigDisabled .OptItem[Ctrl] {
    pointer-events: none;
    opacity: .5;
}

@media only screen and (max-width: 380px) {
    .IrrigStepper b {
        min-width: 54px;
    }

    .IrrigStepperSm b {
        min-width: 46px;
    }

    .IrrigBtn {
        font-size: 13px;
    }
}
