/* --- style.css --- */

/* --- ESTILS GENERALS --- */
body {
    margin: 0;
    padding: 0;
    background-color: #FAFAFA;
    padding-top: 100px;
    padding-bottom: 50px;
    font-family: sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
}

header {
    background-color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 1000;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 20px;
    box-sizing: border-box;
}

.logo {
    font-weight: 700;
    font-size: 1.5rem;
    color: #3c559f;
    text-decoration: none;
    text-transform: uppercase;
}

.btn-home-nav {
    position: absolute;
    left: 20px;
    text-decoration: none;
    color: white;
    background-color: #3c559f;
    padding: 8px 15px;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.9rem;
}

/* --- CONTENIDOR BLANC --- */
#main-container {
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);

    /* Mòbil per defecte */
    width: calc(100% - 40px);
    max-width: 500px;
    height: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    position: relative;
    box-sizing: border-box;
    margin-bottom: 20px;
}

/* --- TEXTOS (Classes generals) --- */
.text-label {
    font-family: sans-serif;
    color: black;
    text-align: center;
    position: relative;
    width: 100%;
}

.text-previous {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: -20px;
    z-index: 5;
}

.text-instruction {
    font-size: 24px;
    font-weight: 400;
    top: -1%;
}

/* --- DISPOSITIUS --- */
.device-wrapper {
    position: relative;
    width: 270px;
    height: 270px;
    flex-shrink: 0;
}

.device-box {
    background: #E6421D;
    border-radius: 15px;
    padding: 5px;
    display: inline-flex;
    justify-content: flex-start;
    align-items: center;
    gap: 10px;
    position: relative;
}

/* --- CARA I ELEMENTS --- */
.face-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 738 / 716;
    margin-top: 20px;

    left: -6.5%;
    top: -3%;

}

.face-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.coil-img {
    position: absolute;
    width: 50%;
    height: auto;
    left: 48%;
    top: 45%;
    object-fit: contain;
}

/* --- LÍNIES I ELEMENTS SOBRE LA CARA --- */
/* Configuració MÒBIL per defecte */
.line-h,
.stick-highlight {
    position: absolute;
    left: 14%;
    width: 99%;
    height: 2%;
    top: 42%;
    object-fit: fill;
}

.stick-highlight-vertical {
    position: absolute;
    left: 44%;
    width: 2%;
    height: 76%;
    top: 7%;
    object-fit: fill;
}


.line-h-torta {
    position: absolute;
    top: 4%;
    height: 76%;
    width: 68%;
    left: 12%;
    object-fit: fill;
}

.cylon-highlight {
    position: absolute;
    left: 14%;
    width: 2%;
    height: 2%;
    top: 42%;
    object-fit: fill;
    border-radius: 50%;
}

.cylon-highlight-vertical {
    position: absolute;
    left: 44%;
    width: 2%;
    height: 2%;
    top: 10%;
    object-fit: fill;
    border-radius: 50%;
}

.line-v {
    position: absolute;
    top: 7%;
    height: 76%;
    width: 2%;
    left: 44%;
    object-fit: fill;
}

.line-v-torta {
    position: absolute;
    top: 7%;
    height: 76%;
    width: 90%;
    left: 0%;
    object-fit: fill;
}

/* LED Indicator */
.led-indicator {
    position: absolute;
    width: 3%;
    height: auto;
    aspect-ratio: 1/1;
    left: 111%;
    /* Mòbil */
    top: 42.3%;
    border-radius: 50%;
}

/* Zona Clicable */
.click-area {
    position: absolute;
    left: 14%;
    top: 40%;
    width: 90%;
    height: 6%;
    cursor: pointer;
    background: transparent;
    z-index: 10;
}

/* --- IMATGES LATERALS --- */
.side-images-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.side-image-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.side-image {
    width: 100%;
    max-width: 363px;
    height: auto;
    border-radius: 15px;
    border: 10px solid white;
}

/* --- ANIMACIONS --- */
@keyframes blink-led {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.1;
    }

    100% {
        opacity: 1;
    }
}

.led-parpadejant {
    animation: blink-led 1s infinite;
}

@keyframes blink-ui {
    0% {
        opacity: 0.9;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 0.9;
    }
}
@keyframes blink-ui-suau {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 0;
    }

    100% {
        opacity: 0.5;
    }
}
.animacio-parpadejant {
    animation: blink-ui 3s infinite;
    pointer-events: none;
}

.animacio-parpadejant-suau {
    animation: blink-ui-suau 3s infinite;
    pointer-events: none;
}

@keyframes moure-lateral {
    0% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(428px);
        /* Arriba al final a la meitat del temps */
    }

    100% {
        transform: translateX(0);
        /* Torna al principi per aturar-se */
    }
}

@keyframes moure-vertical {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(465px);
        /* Arriba al final a la meitat del temps */
    }

    100% {
        transform: translateY(0);
        /* Torna al principi per aturar-se */
    }
}

.moviment-cylon {
    /* S'executa 1 sola vegada durant 3 segons */
    animation: moure-lateral 10s ease-in-out 1 forwards;
}

.moviment-cylon-vertical {
    animation: moure-vertical 10s ease-in-out 1 forwards;
}

@media (min-width: 1280px) {

    #main-container {
        width: 1280px;
        height: 1342px;
        max-width: none;
        display: block;
        padding: 0;
        transform-origin: top center;
        margin-top: 20px;
    }

    /* TEXTOS */
    .text-label {
        text-align: left;
        position: absolute;
        width: auto;
    }

    .text-previous {
        left: 490px;
        top: 29px;
        font-size: 24px;
        margin-bottom: 0;
    }

    .text-instruction {
        left: 130px;
        top: 345px;
        font-size: 32px;
    }

    /* POSICIONS DISPOSITIUS */
    .device-pos-1 {
        position: absolute;
        left: 125px;
        top: 75px;
        z-index: 20;
    }

    .device-pos-2 {
        position: absolute;
        left: 500px;
        top: 75px;
        z-index: 20;
    }

    /* Si només hi ha un dispositiu, el posem a l'esquerra per defecte */
    .device-wrapper:not(.device-pos-1):not(.device-pos-2) {
        position: absolute;
        left: 125px;
        top: 75px;
        z-index: 20;
    }

    /* CARA */
    .face-wrapper {
        position: absolute;
        width: 738px;
        height: 716px;
        left: 0px;
        top: 375px;
        z-index: 10;
        margin-top: 0;
    }

    /* AJUSTOS ELEMENTS CARA EN ESCRIPTORI */
    .line-h,
    .stick-highlight,
    .click-area {
        left: 18%;
        width: 88%;
    }

    .line-h-torta {
        top: 4%;
        height: 76%;
        width: 60%;
        left: 17%;
    }

    .cylon-highlight {
        left: 18%;
        width: 2%;
    }

    .cylon-highlight-vertical {
        left: 44%;
        width: 2%;
        height: 2%;
    }

    .led-indicator {
        left: 104%;
        top: 42.1%;
    }

    /* --- IMATGES LATERALS (ARREGLAT) --- */

    .side-images-group {
        display: block;
    }

    /* REGLA D'OR: Qualsevol contenidor d'imatge lateral es posa a la dreta absolutament */
    .side-image-wrapper {
        display: block;
        position: absolute;
        left: 840px;
        top: 100px;
        /* Posició per defecte (Dalt) */
        width: auto;
        z-index: 5;
    }

    /* Si necessitem una segona imatge a baix, només canviem el TOP */
    .side-img-pos-2 {
        top: 740px;
    }

    /* Fixem la mida de la imatge perquè no s'estiri com al mòbil */
    .side-image {
        width: 363px;
        height: auto;
    }

    @keyframes moure-lateral {
        0% {
            transform: translateX(0);
        }

        50% {
            /* Canvia el 650px pels píxels que necessitis en escriptori */
            transform: translateX(632px);
        }

        100% {
            transform: translateX(0);
        }
    }

    @keyframes moure-vertical {
        0% {
            transform: translateY(0);
        }

        50% {
            /* Canvia el 700px pels píxels que necessitis en escriptori */
            transform: translateY(692px);
        }

        100% {
            transform: translateY(0);
        }
    }
}

@media (min-width: 1280px) and (max-width: 1400px) {
    #main-container {
        transform: scale(0.85);
        margin-top: 0;
    }
}

/* ========================================================= */
/* --- ESTILS EXCLUSIUS PER A LA PÀGINA "WORKSPACE" --- */
/* ========================================================= */

/* Adaptem el body exclusivament per a l'índex per no trencar l'estil Flexbox del teu demo */
body.page-workspace {
    display: block; 
    padding-top: 100px;
    font-family: 'Inter', sans-serif;
    color: #333;
}

#workspace {
    padding: 2rem 2rem;
    width: calc(100% - 40px);
    max-width: 1000px;       
    margin: 0 auto;           
}

.demo-header { text-align: center; margin-bottom: 3rem; }
.demo-header h2 { margin-bottom: 0.5rem; font-size: 2.2rem; color: #333; }
.demo-header p { text-align: center; color: #777; font-size: 1.1rem; margin-top: 0;}

.demo-flex-container {
    display: flex;
    flex-direction: row;
    gap: 30px;
    align-items: stretch;
    width: 100%;
}

.demo-side {
    flex: 1;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.03);
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
}

.demo-side h3 { font-size: 1.6rem; margin-bottom: 1.5rem; color: #3c559f; }

/* Selector de Diagrama */
.diagram-select {
    width: 100%;
    max-width: 350px;
    padding: 10px 15px;
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    color: #333;
    background-color: #f9f9f9;
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.diagram-select:hover, .diagram-select:focus {
    border-color: #3c559f;
    box-shadow: 0 0 5px rgba(60, 85, 159, 0.2);
}

/* Contenidor Esquema */
.schema-img-container {
    width: 100%;
    max-width: 350px;
    cursor: zoom-in;
    transition: transform 0.3s ease;
    display: flex; 
    flex-direction: column;
    align-items: center;
    margin: auto 0;
}
.schema-img-container:hover { transform: scale(1.03); }
.schema-img-container img { width: 100%; border-radius: 10px; box-shadow: 0 8px 25px rgba(0,0,0,0.1); border: 1px solid #eee; }
.schema-hint { font-size: 0.85rem; margin-top: 15px; color: #888; background: #f0f0f0; padding: 5px 15px; border-radius: 20px; }

/* Mini dispositiu recreat per a l'esquema */
.demo-container { display: flex; flex-direction: column; align-items: center; gap: 40px; margin: auto 0; }
.mini-device-card {
    width: 260px; height: 260px;
    background-color: #E6421D;
    border-radius: 15px;
    position: relative;
    box-shadow: 0 10px 30px rgba(60, 85, 159, 0.2); 
    overflow: hidden;
}
.mini-screen-black { width: 249px; height: 249px; background: black; border-radius: 15px; position: absolute; top: 5px; left: 5px; }
.mini-screen-grey {
    width: 217px; height: 172px; background: #F2F2F2;
    position: absolute; top: 38px; left: 20px;
    display: flex; justify-content: center; align-items: center; text-align: center;
}
.mini-screen-text { color: black; font-size: 24px; font-weight: 400; line-height: 1.2; }
.mini-device-btn { width: 50px; height: 25px; background: #D9D9D9; border-radius: 5px; position: absolute; bottom: 15px; }
.mini-device-card .btn-1 { left: 37px; } 
.mini-device-card .btn-2 { left: 105px; } 
.mini-device-card .btn-3 { left: 173px; }

/* Botó Start Demo */
.start-btn {
    width: 260px; height: 70px; background: #3c559f; border-radius: 35px; 
    display: flex; justify-content: center; align-items: center;
    text-decoration: none; transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer; box-shadow: 0 4px 15px rgba(60, 85, 159, 0.3);
}
.start-btn:hover { transform: translateY(-5px); box-shadow: 0 8px 20px rgba(60, 85, 159, 0.5); }
.start-text { color: white; font-size: 20px; font-weight: 500; }

/* Modal Imatge Pantalla Completa */
.modal {
    display: none; position: fixed; z-index: 2000; top: 0; left: 0;
    width: 100%; height: 100%; background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px); justify-content: center; align-items: center; cursor: zoom-out;
}
.modal img { max-width: 90%; max-height: 90vh; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); background-color: white; padding: 20px; }
.close-modal { position: absolute; top: 30px; right: 40px; color: white; font-size: 50px; font-weight: 300; cursor: pointer; transition: color 0.3s; }
.close-modal:hover { color: #E6421D; }

/* Responsivitat del Workspace */
@media (max-width: 850px) { .demo-flex-container { flex-direction: column; } }
@media (max-width: 768px) { .start-btn { width: 100%; max-width: 300px; } }

.tests-diagram-box {
    background-color: #ffffff; /* Fons blanc */
    border-radius: 20px; /* Cantonades arrodonides com les altres capses */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05); /* Ombra suau */
    padding: 2.5rem; /* Espai interior de la capsa */
    margin-bottom: 2rem; /* Separació amb les dues capses de sota */
    width: 100%; /* Ocupa tot l'ample de la secció */
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center; /* Centra el contingut horitzontalment */
}

/* Estil del títol perquè sigui igual que "Clinical Flow Diagram" */
.tests-diagram-box h3 { font-size: 1.6rem; margin-bottom: 1.5rem; color: #3c559f; }

/* Forcem la imatge a créixer fins als límits de la capsa */
.svg-fluid {
    width: 100% !important;
    min-width: 100% !important; /* Això evita que l'SVG es quedi amb la seva mida original */
    height: auto !important;
    display: block;
}

.tests-diagram-box svg {
    cursor: zoom-in;
    transition: transform 0.2s ease-in-out;
}

.tests-diagram-box svg:hover {
    transform: scale(1.02);
}

/* Estils per al fons fosc del modal */
.modal {
    display: none; 
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.85); /* Fons negre transparent */
}

/* Contenidor de l'SVG dins del modal */
.modal-content {
    margin: 5% auto;
    display: block;
    width: 90%; /* Ocuparà el 90% de la pantalla */
    max-width: 1400px;
}

.modal-content svg {
    width: 100%;
    height: auto;
    background-color: white; /* Fons blanc perquè l'SVG es llegeixi bé */
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

/* Estils per al text inferior */
.click-to-enlarge {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin-top: 15px;
    font-style: italic;
    cursor: pointer;
    transition: color 0.2s ease;
}

.click-to-enlarge:hover {
    color: #3d85c6; /* Un blau perquè sembli un enllaç al passar el ratolí */
}

/* Assegurem que la creu estigui SEMPRE per sobre i es pugui clicar */
.close-modal {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 9999; /* Afegit per arreglar el problema del clic */
}

.close-modal:hover,
.close-modal:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

.svg-diagram-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; /* Això fa que la píndola quedi centrada i amb la mida justa */
    cursor: zoom-in;
    transition: transform 0.2s ease-in-out;
}

.svg-diagram-container:hover {
    transform: scale(1.02);
}