* { box-sizing: border-box; }
body, html {
    margin: 0; padding: 0; width: 100%; height: 100%;
    overflow: hidden; background-color: #1a1a1a;
    display: flex; justify-content: center; align-items: center;
    font-family: Arial, sans-serif;
}

/* Okvir uređaja sada ima samo jedan glavni stupac */
.hmi-frame {
    width: 100vw; height: 100vh;
    background-color: #000;
    display: flex;
    flex-direction: column;
    padding: 1vh 3vw;
    border: 15px solid #333;
}

.hmi-header {
    display: flex; justify-content: space-between; align-items: center;
    color: white; height: 8vh; padding: 0 0px;
} 

.systal-logo { background: #df1111; padding: 7px 15px; font-weight: bold; }

/* --- ZASLON --- */
.hmi-screen {
    flex-grow: 1;
    background-color: #b5b5b5;
    border: 5px solid #222;
    display: flex; flex-direction: column;
    position: relative; /* Ovo omogućuje pozicioniranje stop tipke unutar njega */
    box-shadow: inset 0 0 40px rgba(0,0,0,0.4);
    overflow: hidden;
}

/* POZICIONIRANJE STOP TIPKE GORE LIJEVO */
.stop-zone {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 999;
}

.stop-base {
    width: 90px; height: 90px;
    background: #ffd700;
    border-radius: 10px;
    display: flex; justify-content: center; align-items: center;
    border: 3px solid #b8860b;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 999;
}

.stop-button {
    width: 65px; height: 65px;
    background: radial-gradient(circle, #ff4d4d 0%, #b30000 100%);
    border-radius: 50%;
    border: 3px solid #660000;
    cursor: pointer;
    box-shadow: 0 5px 0 #660000;
    transition: all 0.1s;
    color: white; font-weight: bold; font-size: 12px;
    z-index: 999;
}

.stop-button:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 #660000;
    z-index: 999;
}

/* SREDIŠNJI DIO */
.screen-content {
    opacity: 1;
    flex-grow: 1;
    display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    overflow: hidden;
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.image-label {
    margin-top: 15px;       
    width: 100%;            /* Tekst prati širinu slike */
    text-align: center;     /* Centriranje teksta ISPOD slike */
    color: #000;
    font-weight: bold;
    font-size: 1.2rem;
    text-transform: uppercase;
    font-family: Arial, sans-serif;
}    

.image-flag {
    position: absolute; /* Omogućuje precizno pomicanje */
    top: 20px;          /* Udaljenost od vrha */
    right: 20px;        /* Udaljenost s lijeve strane */
    width: 120px;       /* Širina slike */
    height: 60px;
    display: block !important;
    object-fit: cover;
    z-index: 999;
    object-fit: contain
}

.image-flag img {
    width: 100%;   
    height: 100%;   
    object-fit: cover;
    z-index: 999;
    
}

.image-item {
    display: flex;
    flex-direction: column; 
    align-items: center;    
    width: 100%;            
    object-fit: cover;
}

.hmi-overlay-image {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 75%; 
    height: auto;
    z-index: 999;
    opacity: 1;          
    pointer-events: none;      
    background: none;
    border: none;
}

.hmi-image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);   
    row-gap: 10px;      
    position: absolute;
    top: 110px;         
    left: 12%;
    right: 15%;
    width: 80%;
    height: auto;
    object-fit: cover;
}

.hmi-image-grid img {
    width: 300px;      
    aspect-ratio: 16 / 9;
    height: auto;
    object-fit: cover;
    display: block;
    border: 2px solid #555; 
    background: #ccc;      
}

.hmi-image-grid-horizontal {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: flex-start;
    gap: 10px;
    top: 52%;
    left: 50%;
    right: auto;
    width: auto;
    transform: translate(-50%, -50%);
}

.hmi-image-grid-horizontal .image-item {
    width: auto;
    flex: 0 0 auto;
}

.hmi-image-grid-horizontal img {
    width: clamp(220px, 22vw, 340px);
}

.contact-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    height: calc(100% - 60px); /* Ostavlja prostor za donji meni */
}

/* Pojedinačna kartica za svakog inženjera */
.contact-card {
    text-align: center;
    width: 40%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Stil za logo unutar kartice */
.card-logo {
    width: 35%;
    margin-bottom: 20px;
}

/* Ime i prezime */
.contact-name {
    font-size: 24px;
    color: #333;
    margin: 10px 0 5px 0;
    font-family: Arial, sans-serif;
}

/* Titula */
.contact-title {
    font-size: 16px;
    color: #777;
    margin-bottom: 20px;
}

.divider {
    width: 80%;
    height: 1px;
    background-color: #eee;
    margin-bottom: 20px;
}

.contact-link {
    display: block;
    font-size: 16px;
    color: #555;
    text-decoration: none;
    margin-bottom: 5px;
    border-bottom: 1px solid transparent;
}

.contact-link:hover {
    border-bottom: 1px solid #555;
}

.status-led { width: 60px; height: 60px; background: #00ff00; border-radius: 50%; margin-bottom: 20px; box-shadow: 0 0 20px #00ff00; }
.exit-button { background: #a94442; color: white; padding: 15px 30px; border: 2px solid #000; cursor: pointer; font-weight: bold; }

/* DONJI MENI */
.hmi-bottom-nav {
    height: 55px;
    background: #d1d1d1;
    display: flex;
    border-top: 3px solid #666;
    z-index: 999;
}

.nav-item {
    flex: 1;
    border-right: 1px solid #999;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, #eeeeee 0%, #cccccc 100%);
    cursor: pointer; font-size: 20px;
}

/* Kontejner gumba mora biti relative */
.gear-item {
    position: relative;
}

/* Osnovni stil za popup koji je sakriven */
.settings-popup {
    position: absolute;
    bottom: 100%; /* Postavlja ga točno iznad navigacije */
    left: 50%;
    transform: translateX(-50%) translateY(20px) scale(0.8); /* Pomaknut dolje i smanjen */
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 15px; /* Razmak od gumba */
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 2000;
}

/* Stil kada je gumb nav-item active */
.nav-item.active .settings-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0) scale(1); /* Skače prema gore */
}

/* Izgled 3 pravokutnika */
.popup-box {
    width: 130px;
    height: 45px;
    background-color: #f0f0f0;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: pointer;
}

.home-icon-hmi {
    width: 45%;
    height: 100%;
    display: block;
    opacity: 1;
    transition: opacity 0.5s ease;
    -webkit-tap-highlight-color: transparent;
    object-fit: contain
}

.work-icon-hmi {
    width: 65%;
    height: 110%;
    display: block;
    opacity: 1;
    transition: opacity 0.5s ease;
    -webkit-tap-highlight-color: transparent;
    object-fit: contain
}

.social-icon-hmi {
    width: 50%;
    height: 120%;
    display: block;
    opacity: 1;
    transition: opacity 0.5s ease;
    -webkit-tap-highlight-color: transparent;
    object-fit: contain
}



.popup-box:hover {
    background-color: #e0e0e0;
    border-color: #999;
}

.background-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.background-video video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
}

.nav-item.active { background: #bbb; }
.info-icon { border-right: none; }

/* Animated PLC screen */
.animated-screen {
    background:
        radial-gradient(circle at 15% 25%, rgba(255, 255, 255, 0.25), transparent 45%),
        radial-gradient(circle at 85% 75%, rgba(0, 170, 255, 0.35), transparent 45%),
        linear-gradient(120deg, #808080, #a8a8a8, #7f7f7f);
    background-size: 120% 120%;
    animation: screenFlow 9s ease-in-out infinite;
}

.animated-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: repeating-linear-gradient(
        to right,
        rgba(255, 255, 255, 0.08) 0,
        rgba(255, 255, 255, 0.08) 2px,
        transparent 2px,
        transparent 32px
    );
    mix-blend-mode: soft-light;
    animation: layerSweep 14s linear infinite;
}

.animated-screen .hmi-overlay-image {
    animation: logoPulse 3.8s ease-in-out infinite;
}

.hmi-top-nav {
    position: absolute;
    top: 20px;
    left: 128px;
    right: 20px;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(5, 100px);
    justify-content: end;
    gap: 0;
}

.status-square {
    min-height: 64px;
    background: linear-gradient(180deg, #efefef 0%, #cfcfcf 100%);
    border: 2px solid #787878;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
    font: 700 12px/1.2 "Consolas", monospace;
    color: #222;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 2px 4px rgba(0, 0, 0, 0.25);
}

.status-square .value {
    margin-top: 3px;
    font-size: 15px;
    color: #122f12;
}

.status-square .ok {
    color: #118011;
}

.flag-square {
    padding: 4px;
}

.flag-square a {
    display: flex;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
}

.top-flag-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border: 1px solid #555;
}

@media (max-width: 768px) {
    .hmi-top-nav {
        top: 120px;
        left: 12px;
        right: 12px;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 0;
    }

    .hmi-image-grid {
        top: 190px;
    }

    .hmi-image-grid-horizontal {
        top: 56%;
        gap: 20px;
        width: calc(100% - 24px);
        overflow-x: auto;
        justify-content: flex-start;
        padding: 0 8px;
    }

    .hmi-image-grid-horizontal img {
        width: 180px;
    }

    .status-square {
        min-height: 52px;
        font-size: 10px;
    }

    .status-square .value {
        font-size: 12px;
    }
}

@keyframes screenFlow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes layerSweep {
    0% { transform: translateX(-10%); opacity: 0.5; }
    50% { transform: translateX(10%); opacity: 0.8; }
    100% { transform: translateX(-10%); opacity: 0.5; }
}

@keyframes logoPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.95; }
    50% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
}
