/* === KOMPLETNÍ CSS (style.css) - Verze s instrukcemi v placeholderu === */

/* --- Styly pro Trigger Button/Icon (Mimo Popup) --- */
.face-shape-trigger {
    margin-bottom: 1em;
    display: inline-block;
}
.face-shape-icon-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 5px 10px 5px;;
    color:#363636;
    cursor: pointer;
    font-size: inherit;
    transition: background-color 0.2s ease;
    vertical-align: middle;
    /* background: none; border: none; */ /* Pokud nechcete žádné pozadí/rámeček */
}
.face-shape-icon-button:hover {
    background-color: #eee; /* Jemné zvýraznění při najetí */
}
.face-shape-icon-button svg {
    width: 1.2em;
    height: 1.2em;
    flex-shrink: 0;
}


/* --- Styly pro Popup --- */
.face-detector-popup-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 15px;
    overflow-y: auto;
}
.face-detector-popup-content {
    background-color: #0000008c;
    padding: 25px 30px;
    border-radius: 5px;
    max-width: 550px; 
    width: 100%;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    max-height: 90vh;
    overflow-y: auto;
    color: #ccc;
}
.face-detector-popup-close {
    position: absolute;
    top: 8px;
    right: 20px;
    background: none;
    border: none;
    font-size: 40px;
    line-height: 1;
    cursor: pointer;
    color: #aaa;
    padding: 5px;
    font-weight: bold;
    transition: color 0.2s ease;
}
.face-detector-popup-close:hover {
    color: #fff;
}
.face-detector-popup-content.loading {
    position: relative;
    min-height: 200px;
}
/* Overlay pro stav načítání */
.face-detector-popup-content.loading::after {
    content: attr(data-loading-text);
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #fff;
    z-index: 10;
    border-radius: 5px;
    text-align: center;
    padding: 20px;
}


/* --- Styly pro vnitřek popupu --- */
#face-shape-detector {
    padding: 0;
    border: none;
    margin: 0;
}

/* --- Styly pro hlavní interakční oblast (Placeholder/Video/Ořez) --- */
#face-interaction-area {
    position: relative; /* Nutné pro absolutní pozicování vnitřních prvků */
    max-width: 400px; /* Maximální šířka oblasti */
    width: 100%;      /* Zabere dostupnou šířku do max-width */
    aspect-ratio: 3 / 4; /* Poměr stran (šířka / výška) */
    margin: 30px auto 20px auto; /* Centrování a mezera pod */
    /*background-color: #111;  Tmavé pozadí placeholderu */
    border: 1px solid #444; /* Rámeček */
    overflow: hidden; /* Skryje co přetéká */
    display: flex; /* Pro centrování obsahu v #face-initial-instructions */
    align-items: center;
    justify-content: center;
    border-radius: 3px; /* Volitelné zaoblení */
}

/* Společné styly pro placeholdery uvnitř interakční oblasti */
.interaction-placeholder {
    width: 100%;
    height: 100%;
    position: absolute; /* Důležité - všechny se překrývají */
    top: 0;
    left: 0;
    display: none; /* Defaultně skryté, JS/CSS třídy je zobrazí */
    box-sizing: border-box; /* Zahrne padding/border do rozměrů */
}

/* Styly specificky pro počáteční instrukce */
#face-initial-instructions {
    display: flex; /* Pro centrování textu */
    flex-direction: column; /* Text pod sebou */
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px; /* Vnitřní odsazení textu */
    background-color: #00000052;
    color: #aaa; /* Barva textu instrukcí */
    font-size: 0.8em; /* Velikost písma instrukcí */
    line-height: 1.5; /* Řádkování */
}
#face-initial-instructions p {
    margin: 0; /* Odstranit defaultní margin odstavce */
    color: inherit; /* Dědit barvu */
    text-align: center; /* Explicitní zarovnání */
}
#face-initial-instructions strong {
     color: #bf9b30; /* Zvýraznění důležitých částí */
     font-weight: 600; /* Mírně tučnější */
}


/* Styly pro oblast ořezu (upraveno pro absolutní pozici) */
#face-crop-area {
    border: none; /* Rámeček je na #face-interaction-area */
    background-color: transparent; /* Pozadí je na #face-interaction-area */
}
#face-crop-area img#face-image-to-crop {
    display: block;
    max-width: 100%;
    max-height: 100%; /* Zajistí, že se obrázek vejde */
    /* Cropper.js si sám nastaví pozici a rozměry, 'position: absolute' není nutné */
}
/* Styly pro Cropper.js - Můžete přidat vlastní, pokud potřebujete */
/* .cropper-view-box, .cropper-face { ... } */


/* Styly pro oblast videa/canvas (upraveno pro absolutní pozici) */
#face-display {
   border: none; /* Rámeček je na #face-interaction-area */
   background-color: transparent; /* Pozadí je na #face-interaction-area */
   line-height: 0; /* Zabraňuje nechtěným mezerám */
}
#face-display > video,
#face-display > canvas {
    position: absolute; /* Nutné pro překrytí a správné rozměry */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain; /* Zachová poměr stran videa/canvasu */
}
#face-display > canvas { z-index: 2; pointer-events: none; background-color: transparent;}
#face-display > video { z-index: 1; }


/* --- Ovládání viditelnosti placeholderů pomocí tříd na #face-shape-detector --- */

/* Výchozí stav: Zobrazí instrukce */
.initial-state #face-interaction-area #face-initial-instructions {
    display: flex; /* Zobrazit jako flexbox pro centrování */
}
/* V ostatních stavech je #face-initial-instructions skryté (kvůli .interaction-placeholder { display: none; }) */

/* Stav videa: Zobrazí video/canvas */
.video-active #face-interaction-area #face-display {
    display: block; /* Zobrazit kontejner pro video/canvas */
}
/* V ostatních stavech je #face-display skryté */

/* Stav ořezu: Zobrazí ořezávač */
.crop-active #face-interaction-area #face-crop-area {
    display: block; /* Zobrazit kontejner pro ořez */
}
/* V ostatních stavech je #face-crop-area skryté */

/* Odstranění starého bloku instrukcí (pokud by omylem zůstal v HTML) */
.face-display-instructions {
    display: none !important;
}


/* --- Stavový řádek --- */
#face-status {
    margin-top: 15px;
    margin-bottom: 15px;
    font-weight: bold;
    min-height: 1.5em;
    text-align: center;
    color: #aaa;
}

/* --- Oblast výsledku se select boxem --- */
.face-result-area {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #444;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px;
}
.face-result-area label {
    margin-right: 0;
    font-weight: bold;
    color: #ccc;
    vertical-align: middle;
}
.face-result-area select {
    padding: 8px 12px;
    min-width: 200px;
    border: 1px solid #555;
    border-radius: 3px;
    font-size: 1em;
    color: #e0e0e0;
    background-color: #333;
    vertical-align: middle;
    box-sizing: border-box;
}
.face-result-area select option {
    background-color: #333;
    color: #e0e0e0;
}


/* --- Oblast doporučení --- */
#face-shape-recommendation {
    background-color: #252525;
    padding: 15px;
    border-radius: 4px;
    margin-top: 20px;
    text-align: left;
    color: #ccc;
    line-height: 1.6;
}
#face-shape-recommendation h5 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
}
#face-shape-recommendation p {
    margin-top: 0;
    margin-bottom: 12px;
    font-size: 0.95em;
    color: #bbb;
    text-align: left;
}
#face-shape-recommendation p:last-child {
    margin-bottom: 0;
}


/* --- Checkbox pro uložení profilu --- */
.save-preference-option {
    margin-top: 20px;
    text-align: left;
    padding-top: 15px;
    border-top: 1px solid #444;
    /* display: none; JS řídí zobrazení */
}
.save-preference-option label {
    display: inline-flex;
    align-items: center;
    margin-bottom: 0;
    font-weight: normal;
    color:#ccc;
    cursor: pointer;
}
.save-preference-option input[type="checkbox"] {
    margin-right: 8px;
    vertical-align: middle;
    width: 16px;
    height: 16px;
    accent-color: #70b122;
}
.save-preference-option small {
    display: block;
    color: #bf9b30;
    margin-top: 4px;
    font-size: 0.85em;
}


/* === Styly pro Spodní Akční Lištu === */
#face-controls.modal-actions-bottom {
    margin-top: 25px;
    text-align: center;
    border-top: 1px solid #444;
    padding-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
}

/* Styl pro tlačítka s ikonami v liště */
#face-controls.modal-actions-bottom .button.icon-button {
    padding: 8px;
    line-height: 1;
    min-width: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    border-radius: 3px; /* Přidáno pro konzistenci */
    border: 1px solid #555; /* Výchozí rámeček */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
#face-controls.modal-actions-bottom .button.icon-button svg {
    width: 30px;
    height: 30px;
    vertical-align: middle;
    fill: currentColor;
}

/* Specifické barvy pro tlačítka v liště */
#face-controls.modal-actions-bottom label.icon-button[for="face-upload"] {
     background-color: #70b122; border-color: #70b122; color: #fff;
}
#face-controls.modal-actions-bottom label.icon-button[for="face-upload"]:hover { background-color: #5a901b; border-color: #5a901b; }

#face-controls.modal-actions-bottom button#face-webcam-button {
    background-color: #0073aa; border-color: #0073aa; color: #fff;
}
#face-controls.modal-actions-bottom button#face-webcam-button:hover { background-color: #005f8c; border-color: #005f8c; }

#face-controls.modal-actions-bottom button#face-capture-button {
    background-color: #d63638; border-color: #d63638; color: #fff;
}
#face-controls.modal-actions-bottom button#face-capture-button:hover { background-color: #b02a2c; border-color: #b02a2c; }

#face-controls.modal-actions-bottom button#confirm-crop-button {
     background-color: #FFD700; border-color: #FFD700; color: #fff;
}
#face-controls.modal-actions-bottom button#confirm-crop-button:hover { background-color: #FFD700; border-color: #FFD700; }

/* Tlačítko "Použít tvar" - ikona + text */
#face-controls.modal-actions-bottom button#confirm-face-shape {
    background-color: #22c55e; border-color: #16a34a; color: #fff;
    padding: 8px 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 1em;
    margin: 0;
    border-radius: 3px;
    border: 1px solid #16a34a; /* Přidáno pro konzistenci */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
#face-controls.modal-actions-bottom button#confirm-face-shape:hover { background-color: #15803d; border-color: #14532d; }
#face-controls.modal-actions-bottom button#confirm-face-shape svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}
#face-controls.modal-actions-bottom button#confirm-face-shape .button-text {
     line-height: 1.2;
}

/* Disabled stav pro všechna tlačítka v nové liště */
#face-controls.modal-actions-bottom .button:disabled,
#face-controls.modal-actions-bottom button:disabled,
#face-controls.modal-actions-bottom label.button:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    background-color: #555 !important;
    border-color: #666 !important;
    color: #aaa !important;
    box-shadow: none !important;
}
#face-controls.modal-actions-bottom #confirm-face-shape:disabled {
     background-color: #555 !important;
     border-color: #666 !important;
     color: #aaa !important;
}

/* === KONEC STYLŮ PRO SPODNÍ LIŠTU === */


/* --- Responzivita --- */
@media (max-width: 480px) { /* Upraveno breakpoint */
    .face-detector-popup-content {
        padding: 15px 20px; /* Více místa po stranách */
        max-width: 95%;    /* Téměř plná šířka */
    }

    /* Úprava pro interakční oblast na mobilu */
    #face-interaction-area {
        max-width: 100%; /* Plná šířka rodiče */
        aspect-ratio: 4 / 5; /* Vyšší poměr */
        margin-bottom: 15px;
    }
    #face-initial-instructions {
        font-size: 0.9em;
        padding: 15px;
    }

    /* Úprava pro novou spodní lištu */
    #face-controls.modal-actions-bottom {
        gap: 8px; /* Mírně větší mezery */
        padding-top: 15px;
        margin-top: 20px;
    }
     #face-controls.modal-actions-bottom .button.icon-button {
         padding: 7px;
         min-width: 38px;
     }
     #face-controls.modal-actions-bottom .button.icon-button svg {
         width: 18px;
         height: 18px;
     }
     #face-controls.modal-actions-bottom button#confirm-face-shape {
         padding: 7px 12px;
         font-size: 0.95em;
         gap: 6px;
         /* Volitelně: roztáhnout na celou šířku?
         width: 100%; justify-content: center; */
     }
      #face-controls.modal-actions-bottom button#confirm-face-shape svg {
         width: 17px;
         height: 17px;
     }

    .face-result-area {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .face-result-area label { text-align: center; font-size: 0.9em; }
    .face-result-area select { min-width: auto; width: 100%; max-width: none; padding: 8px; font-size: 0.9em; }

    #face-shape-recommendation { padding: 10px; margin-top: 15px; }
    #face-shape-recommendation h5 { font-size: 1em; margin-bottom: 5px; }
    #face-shape-recommendation p { font-size: 0.85em; margin-bottom: 10px; }

    .save-preference-option { margin-top: 15px; padding-top: 10px; }
    .save-preference-option label { font-size: 0.85em; }
    .save-preference-option small { font-size: 0.8em; }
}

@media (min-width: 481px) and (max-width: 768px) { /* Tablet a větší mobily */
    .face-detector-popup-content {
        padding: 20px 25px;
        max-width: 500px; /* Stále relativně úzké */
    }
    
    #face-interaction-area {
        max-width: 350px; /* Omezení šířky i na tabletu */
        aspect-ratio: 3 / 4; /* Zpět k původnímu poměru */
        margin-bottom: 20px;
    }
    #face-initial-instructions {
        font-size: 0.95em; /* Standardní velikost */
    }

    #face-controls.modal-actions-bottom { gap: 10px; } /* Standardní mezery */
    #face-controls.modal-actions-bottom .button.icon-button { padding: 8px; min-width: 40px; }
    #face-controls.modal-actions-bottom button#confirm-face-shape { padding: 8px 15px; font-size: 1em; gap: 8px; }


    .face-result-area { flex-direction: row; align-items: center; gap: 10px; justify-content: center; }
    .face-result-area label { margin-right: 0; text-align: left; font-size: 1em; }
    .face-result-area select { min-width: 180px; width: auto; max-width: 250px; font-size: 1em; }

    #face-shape-recommendation { padding: 12px 15px; margin-top: 20px; }
    #face-shape-recommendation h5 { font-size: 1.05em; margin-bottom: 6px; }
    #face-shape-recommendation p { font-size: 0.95em; margin-bottom: 10px; }

     .save-preference-option { margin-top: 18px; padding-top: 12px; }
     .save-preference-option label { font-size: 0.9em; }
     .save-preference-option small { font-size: 0.8em; }
}

/* Landscape na mobilu - může vyžadovat specifické úpravy výšky/šířky #face-interaction-area */
@media (max-height: 500px) and (orientation: landscape) {
    .face-detector-popup-content { max-height: 95vh; padding: 15px; }

    #face-interaction-area {
        max-width: 280px; /* Výrazně užší na šířku */
        margin-bottom: 10px;
        aspect-ratio: 3 / 4; /* Možná upravit? */
    }
    
    #face-initial-instructions { font-size: 0.8em; padding: 10px; }

    #face-controls.modal-actions-bottom { margin-top: 15px; padding-top: 15px; gap: 5px; }
    #face-shape-recommendation { margin-top: 15px; padding: 10px; }
    #face-shape-recommendation h5 { font-size: 1em; }
    #face-shape-recommendation p { font-size: 0.85em; }
    .save-preference-option { margin-top: 10px; padding-top: 10px; }
}

/* loader animation pro #confirm-face-shape */
#confirm-face-shape.loading svg {
    animation: spin 1s linear infinite; !important;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}