/* ==========================================================
   TFG Natalia · Segmentación automática de tumores cerebrales
   ========================================================== */

:root {
    --color-principal: #8fd3e8;
    --color-principal-hover: #6cc4df;
    --color-secundario: #dff7f4;
    --color-fondo: #eefaf8;
    --color-blanco: #ffffff;
    --color-texto: #23404d;
    --color-borde: #b8dfe7;
    --sombra: 0px 6px 18px rgba(0, 0, 0, 0.08);
    --radio: 18px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--color-fondo);
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--color-texto);
    min-height: 100vh;
    position: relative;
}

/* ---------- Marca de agua de fondo ---------- */
.bg-watermark {
    position: fixed;
    inset: 0;
    background: url("../img/ejemplo_fondo.png") center 60% no-repeat;
    background-size: 450px;
    opacity: 0.1;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 0;
}

.bg-watermark.hidden {
    opacity: 0;
}

/* ---------- Cabecera ---------- */
header {
    width: 100%;
    background: var(--color-principal);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 30px;
    box-shadow: var(--sombra);
    position: sticky;
    top: 0;
    z-index: 1000;
}

header h1 {
    font-size: 30px;
    font-weight: 700;
    color: white;
}

.back-link {
    color: white;
    text-decoration: none;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.25);
    padding: 10px 18px;
    border-radius: 10px;
}

.back-link:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* ---------- Botón hamburguesa ---------- */
.menu-btn {
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    transition: 0.25s;
}

.menu-btn:hover {
    transform: scale(1.08);
}

.menu-btn span {
    display: block;
    width: 24px;
    height: 3px;
    margin: 5px auto;
    background: var(--color-principal);
}

/* ---------- Menú lateral ---------- */
.side-menu {
    position: fixed;
    right: -240px;
    top: 90px;
    width: 220px;
    background: white;
    border-radius: 18px 0 0 18px;
    box-shadow: var(--sombra);
    transition: right 0.35s ease;
    overflow: hidden;
    z-index: 999;
    display: flex;
    flex-direction: column;
}

.side-menu.open {
    right: 0;
}

.menu-item {
    width: 100%;
    padding: 18px;
    background: white;
    border: none;
    border-bottom: 1px solid var(--color-secundario);
    cursor: pointer;
    font-size: 16px;
    color: var(--color-texto);
    transition: 0.25s;
    text-align: left;
}

.menu-item:last-child {
    border-bottom: none;
}

.menu-item:hover {
    background: var(--color-secundario);
}

.menu-item.disabled {
    color: #aaa;
    cursor: not-allowed;
}

.menu-item.disabled:hover {
    background: white;
}

/* ---------- Contenido principal (index) ---------- */
.content {
    position: relative;
    z-index: 1;
    width: 92%;
    max-width: 1400px;
    margin: 40px auto;
    display: flex;
    gap: 40px;
    justify-content: center;
    align-items: flex-start;
    flex-wrap: wrap;
}

.panel {
    flex: 1;
    min-width: 380px;
    max-width: 460px;
    text-align: center;
}

.panel h2 {
    margin-bottom: 20px;
    font-size: 24px;
}

.box {
    background: white;
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    min-height: 360px;
    padding: 25px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-text {
    color: #889;
    text-align: center;
    font-size: 16px;
    padding: 0 20px;
}

/* ---------- Miniaturas de entrada (4 secuencias) ---------- */
.thumb-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.thumb img {
    width: 140px;
    height: 140px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid #ddd;
    background: #000;
}

.thumb span {
    margin-top: 8px;
    font-weight: bold;
    font-size: 14px;
}

.case-label {
    margin-top: 18px;
    font-weight: bold;
    color: var(--color-texto);
    font-size: 15px;
}

/* ---------- Salida: máscara predicha ---------- */
.pred-mask {
    width: 100%;
    max-width: 300px;
    display: block;
    margin: auto;
    border-radius: 15px;
    border: 3px solid #ddd;
    background: black;
}

.real-mask-corner {
    position: absolute;
    right: 18px;
    bottom: 18px;
    width: 100px;
    text-align: center;
}

.real-mask-corner img {
    width: 100%;
    border-radius: 10px;
    border: 2px solid #ddd;
    background: black;
}

.real-mask-corner span {
    display: block;
    margin-top: 5px;
    font-size: 12px;
}

/* ---------- Botón generar predicción ---------- */
.actions {
    position: relative;
    z-index: 1;
    text-align: center;
    margin: 10px 0 50px;
}

.btn-generate {
    background: var(--color-principal);
    color: white;
    border: none;
    border-radius: 14px;
    padding: 16px 38px;
    font-size: 18px;
    cursor: pointer;
    transition: 0.25s;
    box-shadow: var(--sombra);
    font-family: inherit;
}

.btn-generate:hover {
    background: var(--color-principal-hover);
    transform: translateY(-2px);
}

.btn-generate:disabled {
    background: #b9d9e2;
    cursor: not-allowed;
    transform: none;
}

.dice-result {
    margin-top: 18px;
    font-size: 20px;
    font-weight: bold;
}

/* ---------- Galería ---------- */
.gallery-title {
    text-align: center;
    margin: 30px 0 0;
    font-size: 24px;
}

.gallery {
    width: 92%;
    max-width: 1400px;
    margin: 30px auto 60px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 26px;
}

.gallery-card {
    background: white;
    border-radius: var(--radio);
    padding: 18px;
    cursor: pointer;
    box-shadow: var(--sombra);
    transition: 0.25s;
    text-align: center;
}

.gallery-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.gallery-card p {
    margin-top: 12px;
    font-weight: bold;
    font-size: 15px;
}

.gallery-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 12px;
    background: #000;
    display: block;
}

/* ---------- Vista previa ---------- */
.preview-container {
    width: 92%;
    max-width: 1300px;
    margin: 40px auto;
}

.preview-container h2 {
    text-align: center;
    margin-bottom: 10px;
    font-size: 26px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 26px;
    margin-top: 30px;
}

.preview-grid > div {
    background: white;
    border-radius: var(--radio);
    padding: 16px;
    text-align: center;
    box-shadow: var(--sombra);
}

.preview-grid img {
    width: 100%;
    border-radius: 12px;
    background: black;
    aspect-ratio: 1;
    object-fit: cover;
}

.btn-use {
    display: block;
    margin: 40px auto;
    padding: 16px 34px;
    background: var(--color-principal);
    color: white;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: 0.25s;
    font-size: 17px;
    font-family: inherit;
}

.btn-use:hover {
    background: var(--color-principal-hover);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .content {
        flex-direction: column;
        align-items: center;
    }

    .panel {
        min-width: 100%;
        max-width: 100%;
    }

    .thumb img {
        width: 110px;
        height: 110px;
    }

    header h1 {
        font-size: 22px;
    }
}

/* ---------- Subida de imágenes ---------- */
.upload-container {
    width: 92%;
    max-width: 1100px;
    margin: 40px auto 60px;
    text-align: center;
}

.upload-container h2 {
    font-size: 26px;
    margin-bottom: 10px;
}

.upload-info {
    color: #567;
    max-width: 700px;
    margin: 0 auto 30px;
    line-height: 1.5;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 10px;
}

.upload-slot {
    background: white;
    border-radius: var(--radio);
    padding: 18px;
    box-shadow: var(--sombra);
    border: 3px solid transparent;
    transition: border-color 0.2s ease;
}

.upload-slot.valid {
    border-color: #6fcf97;
}

.upload-slot.invalid {
    border-color: #eb5757;
}

.upload-slot-title {
    display: block;
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 16px;
}

.upload-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    border: 2px dashed var(--color-borde);
    border-radius: 12px;
    cursor: pointer;
    background: var(--color-secundario);
    overflow: hidden;
    transition: 0.2s;
}

.upload-box:hover {
    background: #cdeff0;
}

.upload-placeholder {
    color: #789;
    font-size: 13px;
    padding: 10px;
    text-align: center;
}

.upload-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.upload-error {
    color: #c0392b;
    font-size: 13px;
    margin-top: 8px;
    min-height: 16px;
}

#upload-result-panel {
    max-width: 320px;
    margin: 30px auto 0;
}