/* Interkom - karta s ikonou, nazvem a sipkou do podstranky; podstranka s videem, hovorem, vystupy a historii
   Spolecne prvky (.ItemIconBox, .ItemChevron, .PushArea, .PushBtn, .OptLabel, .OptList) jsou v css/style.css */

/* ===== Karta ve vizualizaci ===== */
.IntercomItem {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    cursor: pointer;
}

.IntercomName {
    flex: 1;
    min-width: 0;
    font-size: var(--item-name-fs);
    font-weight: var(--item-name-fw);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Podstranka - rozlozeni (video, hovor, vystupy a historie pod sebou) ===== */
/* Podstranky jsou i na desktopu v jednom sloupci se stejnou sirkou jako ostatni (selector, rekuperace, ...),
   do 480 px roztazeni na celou sirku zajisti .PageContainer > div v css/style.css */
.IntercomMain,
.IntercomHistory {
    width: 420px;
}

.IntercomLayout {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.IntercomControls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.IntercomControls .OptLabel {
    margin-top: 4px;
}

.IntercomControls .OptList {
    margin-bottom: 0;
}

/* ===== Video ===== */
.IntercomVideo {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: var(--radius);
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 95%, #4b5866 0, #2a333c 45%, #151a1f 100%);
    box-shadow: var(--shadow);
}

.IntercomVideoImg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    cursor: zoom-in;
}

.IntercomVideoLive .IntercomVideoImg {
    display: block;
}

.IntercomVideoLoad {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #9aa4ae;
    font-size: 13px;
}

.IntercomVideoLive .IntercomVideoLoad {
    display: none;
}

.IntercomSpinner {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid #3a434c;
    border-top-color: #9aa4ae;
    animation: IntercomSpin 1s linear infinite;
}

/* Kamera neodpovida - misto toceni jen text */
.IntercomVideoFail .IntercomSpinner {
    display: none;
}

.IntercomVideoMsgFail,
.IntercomVideoFail .IntercomVideoMsgLoad {
    display: none;
}

.IntercomVideoFail .IntercomVideoMsgFail {
    display: inline;
}

.IntercomVideoTag,
.IntercomVideoTime {
    position: absolute;
    top: 10px;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 11px;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    font-size: 11px;
    pointer-events: none;
}

.IntercomVideoTag {
    left: 10px;
    font-weight: 700;
    letter-spacing: .05em;
}

.IntercomVideoTag i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #e5483d;
    animation: IntercomBlink 1.4s infinite;
}

.IntercomVideoTime {
    right: 10px;
    font-variant-numeric: tabular-nums;
}

.IntercomVideoLive .IntercomVideoTag,
.IntercomVideoLive .IntercomVideoTime {
    display: flex;
}

/* Tlacitko zvetseni vpravo dole */
.IntercomFullBtn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .45);
    color: #fff;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.IntercomVideoLive .IntercomFullBtn {
    display: flex;
}

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

.IntercomIconShrink,
.IntercomVideoFull .IntercomIconExpand {
    display: none;
}

.IntercomVideoFull .IntercomIconShrink {
    display: block;
}

/* Zobrazeni pres celou obrazovku */
.IntercomVideo.IntercomVideoFull {
    position: fixed;
    inset: 0;
    z-index: 1000;
    aspect-ratio: auto;
    border-radius: 0;
    background: #000;
}

.IntercomVideoFull .IntercomVideoImg {
    object-fit: contain;
    cursor: zoom-out;
}

/* ===== Hovor ===== */
.IntercomCall {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--card);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.IntercomCallName {
    font-size: 15px;
    font-weight: 600;
}

.IntercomCallDesc {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 13px;
    color: var(--muted);
}

.IntercomCallDesc span {
    min-width: 0;
}

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

.IntercomCall.ItemOn .IntercomCallDesc {
    color: var(--call);
}

.IntercomCall.ItemPending .IntercomCallDesc {
    color: var(--accent);
}

.IntercomCall.IntercomError .IntercomCallDesc {
    color: var(--hang);
}

/* Indikator mikrofonu - jen pri hovoru */
.IntercomMic {
    display: none;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
    margin-left: 4px;
}

.IntercomCall.ItemOn:not(.ItemPending) .IntercomMic {
    display: flex;
}

.IntercomMic b {
    width: 3px;
    border-radius: 2px;
    background: currentColor;
    animation: IntercomLevel .9s infinite ease-in-out;
}

.IntercomMic b:nth-child(1) { height: 6px; }
.IntercomMic b:nth-child(2) { height: 12px; animation-delay: .15s; }
.IntercomMic b:nth-child(3) { height: 8px; animation-delay: .3s; }
.IntercomMic b:nth-child(4) { height: 11px; animation-delay: .45s; }

/* Kulate tlacitko hovoru - zelene volat, pri hovoru cervene zavesit */
.IntercomCallBtn {
    flex: 0 0 52px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--call);
    color: #fff;
    -webkit-tap-highlight-color: transparent;
    transition: background .2s, transform .1s, opacity .2s;
}

.IntercomCallBtn svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform .2s;
}

.IntercomCallBtn:active {
    transform: scale(.92);
}

.IntercomCall.ItemOn .IntercomCallBtn {
    background: var(--hang);
}

.IntercomCall.ItemOn .IntercomCallBtn svg {
    transform: rotate(135deg);
}

.IntercomCall.ItemPending .IntercomCallBtn {
    opacity: .6;
    cursor: default;
    animation: IntercomPulse 1.2s infinite;
}

/* ===== Vystupy Q1..Q4 ===== */
.IntercomOut {
    position: relative;     /* pro .PushArea */
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 56px;
    padding: 0 56px 0 14px;     /* vpravo misto pro ctverec .PushArea (vyska radku 56) */
    border-top: 1px solid var(--line);
}

/* Prvni viditelny radek bez oddelovaci cary (tridu nastavuje script.js) */
.IntercomOut.IntercomOutFirst {
    border-top: 0;
}

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

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

.IntercomOutDesc {
    margin-top: 1px;
    font-size: 12px;
    color: var(--muted);
}

.IntercomOutDesc:empty {
    display: none;
}

.IntercomOut.IntercomOutOn .IntercomOutDesc {
    color: var(--push-on);
}

/* Kruh tlacitka sviti jen po dobu drzeni prstu / mysi, sepnuty vystup ukazuje jen popis "Sepnuto" */
.IntercomOut .PushBtnPressed .PushBtn::after {
    background: var(--push-on);
}

/* ===== Odkaz na historii ===== */
.IntercomLink {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 52px;
    padding: 0 14px;
    background: var(--card);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: background-color .2s;
}

.IntercomLink svg {
    flex: 0 0 24px;
    width: 24px;
    height: 24px;
    fill: none;
    stroke: var(--muted);
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.IntercomLinkText {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
}

@media only screen and (hover: hover) and (pointer: fine) {
    .IntercomLink:hover {
        background-color: var(--hover);
    }
}

/* ===== Historie zvoneni ===== */
.IntercomHistory {
    margin-bottom: 16px;
}

.IntercomShots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.IntercomShot {
    position: relative;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    overflow: hidden;
    background: #151a1f;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.IntercomShot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.IntercomShot span {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 16px 8px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, .65));
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

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

/* Zvetseny snimek - prekryti pres celou obrazovku */
.IntercomViewer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .75);
}

.IntercomViewer.IntercomViewerOpen {
    display: flex;
}

.IntercomViewerBox {
    position: relative;
    width: 100%;
    max-width: 900px;
    border-radius: var(--radius);
    overflow: hidden;
    background: #151a1f;
}

.IntercomViewerImg {
    width: 100%;
    display: block;
}

.IntercomViewerHead {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: linear-gradient(rgba(0, 0, 0, .6), transparent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
}

.IntercomViewerClose {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
}

/* ===== Animace ===== */
@keyframes IntercomSpin {
    to { transform: rotate(360deg); }
}

@keyframes IntercomBlink {
    50% { opacity: .25; }
}

@keyframes IntercomLevel {
    50% { transform: scaleY(.4); }
}

@keyframes IntercomPulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 168, 74, .45); }
    100% { box-shadow: 0 0 0 10px rgba(46, 168, 74, 0); }
}
