/* Základní styly pro tělo stránky a globální nastavení */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* Modernější font */
    background-color: #1a1a1a;
    color: #f0f0f0;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Zarovná obsah nahoru */
    min-height: 100vh;
    box-sizing: border-box;
}

/* Hlavní kontejner aplikace */
.container {
    background-color: #282828;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    max-width: 600px;
    width: 100%;
    box-sizing: border-box;
    display: flex; /* Použijeme flexbox pro rozložení uvnitř kontejneru */
    flex-direction: column;
    gap: 20px; /* Mezery mezi sekcemi */
}

h1 {
    text-align: center;
    color: #e0e0e0;
    margin-bottom: 5px; /* Menší mezera */
    font-size: 2em;
}

/* Sekce pro zobrazení výsledné smíchané barvy */
.result-color-display {
    width: 100%;
    height: 100px;
    background-color: #282828; /* Výchozí tmavá barva */
    border: 2px solid #555;
    border-radius: 5px;
    transition: background-color 0.3s ease-in-out; /* Plynulý přechod barvy */
}

p {
    text-align: center;
    margin-top: -10px; /* Posunout blíž k výsledné barvě */
    margin-bottom: 20px;
    color: #b0b0b0;
    font-size: 0.9em;
}

/* Sekce pro vstupní barvy */
.input-colors {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Mezery mezi panely barev */
    margin-bottom: 10px;
}

.color-input-panel {
    background-color: #3a3a3a;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative; /* Pro pozicování tlačítka odstranění */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.color-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid #555;
    flex-shrink: 0; /* Zabrání zmenšení */
    box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.3);
}

.color-sliders {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Mezery mezi RGB slidery */
}

.color-sliders label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    color: #c0c0c0;
}

.color-sliders input[type="range"] {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none; /* pro standardizaci vzhledu */
    height: 10px;
    background: linear-gradient(to right, #000, #fff); /* Obecný gradient */
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

/* Specifické gradienty pro RGB slidery */
.color-sliders label:nth-child(1) input[type="range"] { /* R slider */
    background: linear-gradient(to right, #000, #F00);
}
.color-sliders label:nth-child(2) input[type="range"] { /* G slider */
    background: linear-gradient(to right, #000, #0F0);
}
.color-sliders label:nth-child(3) input[type="range"] { /* B slider */
    background: linear-gradient(to right, #000, #00F);
}


.color-sliders input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: grab;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
    transition: background-color 0.2s ease-in-out;
}

.color-sliders input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: grab;
    border: 2px solid #fff;
    box-shadow: 0 0 5px rgba(0, 123, 255, 0.5);
    transition: background-color 0.2s ease-in-out;
}

/* Tlačítka */
.add-color-button,
.export-button,
.pick-from-camera-btn {
    display: block;
    width: fit-content; /* Přizpůsobí se obsahu */
    padding: 10px 18px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    transition: background-color 0.3s ease, transform 0.2s ease;
    align-self: center; /* Vycentrovat tlačítka ve flex kontejneru */
}

.add-color-button {
    margin: 0 auto; /* Centrování */
    margin-top: 10px; /* Mezera nad */
}

.export-button {
    margin: 0 auto;
    margin-top: 20px;
    background-color: #6f42c1; /* Fialová pro export */
}
.export-button:hover {
    background-color: #5b36a1;
    transform: translateY(-2px);
}


.add-color-button:hover,
.pick-from-camera-btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.add-color-button:disabled {
    background-color: #555;
    cursor: not-allowed;
    transform: none;
}

/* Tlačítko pro odstranění barvy */
.remove-color-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #dc3545; /* Červená */
    color: white;
    border: none;
    border-radius: 4px;
    width: 30px; /* Větší pro snadnější kliknutí */
    height: 30px;
    font-size: 1.1em;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1; /* Zarovnání X */
    transition: background-color 0.2s ease;
}

.remove-color-btn:hover {
    background-color: #c82333;
}

/* Tlačítko "Z kamery" */
.pick-from-camera-btn {
    background-color: #28a745; /* Zelená */
    margin-top: 5px;
    padding: 6px 10px; /* Menší padding */
    font-size: 0.85em;
    align-self: flex-end; /* Zarovnání doprava v panelu */
}
.pick-from-camera-btn:hover {
    background-color: #218838;
}

/* --- Poměr míchání barev --- */
.ratio-master-slider {
    margin-top: 25px;
    background-color: #3a3a3a;
    padding: 20px;
    border-radius: 8px;
    position: relative;
    overflow: hidden; /* Důležité pro skrytí přeplývajících handle */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.ratio-master-slider label {
    display: block;
    margin-bottom: 15px;
    font-size: 1.1em;
    color: #e0e0e0;
    text-align: center;
    font-weight: bold;
}

.ratio-track-container {
    position: relative;
    width: 100%;
    height: 25px; /* Větší výška pro lepší viditelnost */
    background-color: #555; /* Výchozí barva pozadí tracku */
    border-radius: 12px;
    display: flex; /* Flexbox pro rozložení jednotlivých tracků */
    overflow: hidden; /* Důležité pro správné zaoblení a ořez */
    border: 1px solid #666;
}

.ratio-track {
    position: absolute; /* Použijeme absolutní pozicování pro individuální tracky */
    height: 100%;
    border-radius: 12px; /* Zaoblení rohů */
    transition: width 0.1s ease, left 0.1s ease; /* Plynulý přechod pro šířku a pozici */
}

.ratio-handle-zone {
    position: absolute;
    top: 0; /* Pokrývá celý container pro snadnější tažení */
    left: 0;
    width: 100%;
    height: 100%;
    cursor: grab;
    z-index: 10; /* Zajistit, že handle jsou nad tracky */
}

.ratio-handle {
    position: absolute;
    width: 28px; /* Větší handle */
    height: 28px;
    background-color: #007bff;
    border: 3px solid #fff;
    border-radius: 50%;
    top: 50%; /* Vycentrovat vertikálně */
    transform: translate(-50%, -50%); /* Přesné vycentrování */
    cursor: grab;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.6);
    transition: background-color 0.3s ease, left 0.1s ease;
    z-index: 11; /* Nad handle zone */
}

.ratio-handle:active {
    cursor: grabbing;
    box-shadow: 0 0 12px rgba(0, 123, 255, 0.8);
}

/* Camera Modal Styly */
.camera-modal {
    display: none; /* Skryté ve výchozím nastavení */
    position: fixed;
    z-index: 1000; /* Nad vším ostatním */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8); /* Tmavší překrytí */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px); /* Rozmazané pozadí (moderní prohlížeče) */
}

.modal-content {
    background-color: #3a3a3a;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 90%;
    width: 550px; /* Větší šířka */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.8);
    border: 1px solid #555;
    transform: scale(0.95); /* Malá animace při otevření */
    animation: modal-fade-in 0.3s forwards;
}

@keyframes modal-fade-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.camera-stream-container {
    width: 100%;
    height: 350px; /* Větší výška pro video */
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    border-radius: 8px;
    overflow: hidden;
    position: relative; /* Pro cílovou značku */
}

#cameraStream {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Zajistí, že video pokryje kontejner */
    transform: scaleX(-1); /* Zrcadlení pro selfie-like zobrazení */
}

.color-picker-target {
    width: 60px; /* Větší */
    height: 60px;
    border: 3px solid white; /* Výraznější okraj */
    margin: 20px auto;
    border-radius: 50%;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
    transition: background-color 0.3s ease-in-out;
}

.modal-content p {
    font-size: 1.1em;
    margin-bottom: 15px;
    color: #e0e0e0;
}

.modal-content button {
    margin-top: 15px;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

#pickColorBtn {
    background-color: #007bff;
    color: white;
}

#pickColorBtn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

#closeCameraModal {
    background-color: #6c757d;
    color: white;
    margin-left: 15px; /* Větší mezera */
}

#closeCameraModal:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
}

/* Media Queries pro responzivní design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 15px;
        gap: 15px;
    }

    h1 {
        font-size: 1.8em;
    }

    .input-colors {
        flex-direction: column; /* Zpět na sloupec pro malé obrazovky */
        gap: 10px;
    }

    .color-input-panel {
        flex: none; /* Zrušit flex pro jednotlivé panely */
        width: 100%;
        padding: 12px;
        flex-direction: column; /* Slidery pod preview */
        align-items: flex-start;
        gap: 10px;
    }
    .color-preview {
        align-self: center; /* Vycentrovat náhled barvy */
    }

    .color-sliders {
        width: 100%;
    }

    .remove-color-btn {
        width: 25px;
        height: 25px;
        font-size: 0.9em;
        top: 5px;
        right: 5px;
    }
    .pick-from-camera-btn {
        align-self: stretch; /* Rozšířit tlačítko */
        text-align: center;
    }


    .ratio-master-slider {
        padding: 15px;
        padding-top: 25px;
    }

    .ratio-master-slider label {
        font-size: 1em;
        margin-bottom: 10px;
    }

    .ratio-track-container {
        height: 20px;
    }

    .ratio-handle-zone {
        height: 35px;
    }

    .ratio-handle {
        width: 24px;
        height: 24px;
        border-width: 2px;
    }

    .modal-content {
        padding: 20px;
    }
    .camera-stream-container {
        height: 250px;
    }
}