@font-face {
  font-family: 'Inter';
  font-style:  normal;
  font-weight: 100 900; /* Rango de grosores de la fuente variable */
  font-display: swap; /* Evita que el texto esté invisible mientras carga */
  src: url("fonts/Inter-VariableFont_opsz,wght.ttf") format("truetype");
}

@font-face {
  font-family: 'Inter';
  font-style:  italic;
  font-weight: 100 900; /* Rango de grosores de la fuente variable */
  font-display: swap;
  src: url("fonts/Inter-Italic-VariableFont_opsz,wght.ttf") format("truetype");
}

:root {
    --primary-bg: #0a0a0a;
    --secondary-bg: rgba(18, 18, 18, 0.75);
    --primary-text: #f0f0f0;
    --secondary-text: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.08);
    --accent-gradient: linear-gradient(45deg, #F000FF 0%, #00C2FF 100%);
    --success-color: #008F7A;
    --error-color: #E63946;
    --disabled-color: #333;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--primary-bg);
    color: var(--primary-text);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem 1rem;
}

body::before, body::after {
    content: '';
    position: fixed;
    width: 60vw;
    height: 60vw;
    filter: blur(120px);
    z-index: -1;
}
body::before {
    top: -20%;
    left: -20%;
    background: radial-gradient(circle, rgba(240, 0, 255, 0.3), transparent 70%);
    animation: move-aurora-1 20s infinite alternate;
}
body::after {
    bottom: -20%;
    right: -20%;
    background: radial-gradient(circle, rgba(0, 194, 255, 0.3), transparent 70%);
    animation: move-aurora-2 25s infinite alternate;
}
@keyframes move-aurora-1 { to { transform: translate(10vw, 20vh) rotate(15deg); } }
@keyframes move-aurora-2 { to { transform: translate(-20vw, -15vh) rotate(-15deg); } }

header {
    text-align: center;
    margin-bottom: 2rem;
    max-width: 900px;
}
header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
header p {
    color: var(--secondary-text);
    line-height: 1.5;
    font-size: 1.1rem;
    max-width: 70ch;
    margin: 0 auto;
}

.app-container {
    width: 100%;
    max-width: 900px;
    background-color: var(--secondary-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.controls-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    margin-bottom: 1.5rem;
    gap: 2rem;
}
.control-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.control-group label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--secondary-text);
}
.control-group select {
    padding: 0.75rem;
    background-color: rgba(13, 17, 23, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--primary-text);
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    cursor: pointer;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    transition: background-color 0.3s, border-color 0.3s;
}
.drop-zone.dragover {
    background-color: rgba(30, 41, 59, 0.7);
    border-color: #00C2FF;
}
.drop-zone.drop-zone--table-visible {
    border-style: solid;
    border-color: transparent;
}

#drop-zone-prompt {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    min-height: 200px;
    padding: 1rem;
    color: var(--secondary-text);
    gap: 1rem;
}
#drop-zone-prompt span {
    font-size: 0.9rem;
}

#table-view:not(.hidden) {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.action-btn, .download-btn, .preview-btn {
    padding: 0.7rem 1.4rem;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.action-btn:hover, .download-btn:hover, .preview-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}
.action-btn:disabled, .download-btn:disabled, .preview-btn:disabled {
    background-color: var(--disabled-color);
    background-image: none;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: none;
}
.action-btn { background: var(--accent-gradient); }
.download-btn { background-color: var(--success-color); }
.preview-btn { background-color: #4A4A5C; }

#global-actions-container {
    display: flex;
    gap: 1rem;
    align-self: flex-end;
}
.download-all-btn { background-color: var(--success-color); }
.clear-queue-btn { background-color: var(--error-color); }

.table-container {
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 12px;
}
.results-table {
    width: 100%;
    border-collapse: collapse;
}
.results-table th, .results-table td {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}
.results-table tbody tr:last-child td { border-bottom: none; }
.results-table th {
    font-size: 0.8rem;
    color: var(--secondary-text);
    text-transform: uppercase;
    position: sticky;
    top: 0;
    background-color: var(--secondary-bg);
}
.results-table td { font-size: 0.95rem; }
.results-table th:first-child, .results-table td:first-child {
    text-align: left;
    padding-left: 1.5rem;
}
.results-table th:last-child, .results-table td:last-child {
    text-align: right;
    padding-right: 1.5rem;
}
.results-table td.cell-filename {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.results-table tbody tr:hover { background-color: rgba(255, 255, 255, 0.05); }

.cell-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}
.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
}
.savings.positive {
    color: var(--success-color);
    font-weight: 600;
}
.savings.negative {
    color: #f9a825;
    font-weight: 600;
}

.progress-bar-container {
    width: 100%;
    max-width: 100px;
    margin: 0 auto;
    height: 8px;
    background-color: rgba(13, 17, 23, 0.8);
    border-radius: 4px;
    overflow: hidden;
}
.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.3s ease-in-out;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 1rem;
}
.modal-content {
    background-color: #161b22;
    padding: 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.modal-close-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(10, 10, 10, 0.5);
    border: 1px solid var(--border-color);
    color: var(--primary-text);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    z-index: 10;
}
.image-comparator {
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    width: 100%;
    height: 100%;
}
.image-comparator > * {
    grid-area: 1 / 1 / 2 / 2;
}
.image-comparator figure {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    margin: 0;
}
.image-comparator img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.comparator-item.optimized {
    clip-path: inset(0 0 0 50%);
}
.comparator-divider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 3px;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.85);
    transform: translateX(-50%);
    pointer-events: none;
    box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.5);
}
.comparator-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.5);
}
.comparator-handle::before, .comparator-handle::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}
.comparator-handle::before {
    border-width: 6px 8px 6px 0;
    border-color: transparent #0a0a0a transparent transparent;
    left: 10px;
}
.comparator-handle::after {
    border-width: 6px 0 6px 8px;
    border-color: transparent transparent transparent #0a0a0a;
    right: 10px;
}
.image-label {
    position: absolute;
    top: 1rem;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    color: white;
    background-color: rgba(0, 0, 0, 0.7);
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}
.image-label.original { right: calc(100% + 1rem); }
.image-label.optimized { left: calc(100% + 1rem); }

.comparator-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: ew-resize;
    -webkit-appearance: none;
    appearance: none;
    background-color: transparent;
    margin: 0;
}
.comparator-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 4px;
    height: 100%;
    opacity: 0;
}

#quality-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 275px;
    height: 12px;
    border-radius: 6px;
    outline: none;
    cursor: pointer;
    border: none;
    --slider-progress: 50%;
    background-color: rgba(13, 17, 23, 0.9);
    background-image: var(--accent-gradient);
    background-size: var(--slider-progress) 100%;
    background-repeat: no-repeat;
}

#quality-slider::-webkit-slider-thumb, #quality-slider::-moz-range-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-text);
    border-radius: 50%;
    border: 3px solid var(--primary-bg);
    transition: background 0.2s;
}
#quality-slider:hover::-webkit-slider-thumb, #quality-slider:hover::-moz-range-thumb {
    background: #00C2FF;
}

.settings-display {
    text-align: right;
    margin-bottom: 1.2rem;
    color: var(--secondary-text);
    font-size: 0.95rem;
}
.settings-display strong {
    color: var(--primary-text);
    font-weight: 600;
}
.step-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--secondary-text);
    padding: 0 2px;
    margin-top: 0.5rem;
    width: 275px;
}
#quality-display-text {
    display: inline-block;
    min-width: 145px;
    text-align: left;
}
.hidden { display: none !important; }

.content-section {
    width: 100%;
    max-width: 900px; /* Misma anchura que el contenedor principal */
    margin: 3rem auto 0 auto; /* Espacio superior para separarlo de la app */
    padding: 1.5rem;
    color: var(--secondary-text);
}

.content-section h2, .content-section h3 {
    color: var(--primary-text);
    margin-bottom: 1rem;
}

.content-section h2 {
    font-size: 1.8rem;
    text-align: center;
    margin-bottom: 2rem;
}

.content-section h3 {
    font-size: 1.4rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-top: 2.5rem;
}

.content-section p {
    line-height: 1.7;
    font-size: 1.1rem;
}

/* Estilos para la lista de Preguntas Frecuentes (FAQ) */
.content-section dl {
    margin-top: 1.5rem;
}

.content-section dt {
    font-weight: 600;
    color: var(--primary-text);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.content-section dd {
    margin-left: 0; /* Reseteamos la sangría por defecto */
    margin-bottom: 2rem;
    padding-left: 1.2rem;
    border-left: 2px solid var(--border-color);
    line-height: 1.6;
}


@media (max-width: 680px) {
    body {
        padding: 1rem 0.5rem;
    }

    header h1 {
        font-size: 2rem;
    }

    header p {
        font-size: 1rem;
    }

    .app-container {
        padding: 1rem;
        border-radius: 16px;
    }

    .controls-main {
        flex-direction: column;
        align-items: center;
        gap: 2rem;
    }

    .settings-display {
        text-align: center;
    }

    .control-group select {
        width: 275px;
    }

    #quality-display-text {
        display: inline-block;
        min-width: 145px;
        text-align: center;
    }

    #table-view:not(.hidden) {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    #global-actions-container {
        order: -1;
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }

    #global-actions-container .action-btn {
        width: 100%;
        justify-content: center;
        padding: 0.8rem;
        font-size: 1rem;
    }

    .table-container {
        max-height: 60vh;
        border: none;
    }

    .results-table thead {
        display: none;
    }

    .results-table tr {
        display: block;
        border-radius: 12px;
        border: 1px solid var(--border-color);
        background-color: rgba(18, 18, 18, 0.5);
        margin-bottom: 1rem;
        overflow: hidden;
    }

    .results-table tr:last-child {
        margin-bottom: 0;
    }

    .results-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        border-bottom: 1px solid var(--border-color);
        text-align: right;
    }

    .results-table tr td:last-child {
        border-bottom: none;
    }

    .results-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--secondary-text);
        text-align: left;
        margin-right: 1rem;
    }

    .results-table td.cell-filename {
        background-color: rgba(255, 255, 255, 0.05);
        font-weight: 600;
        justify-content: center;
        text-align: center;
        padding: 0.75rem;
        font-size: 1rem;
    }



    .results-table td.cell-filename::before {
        content: none;
    }

    .results-table td.cell-actions {
        justify-content: center;
        padding: 0.5rem;
    }

    .results-table td.cell-actions::before {
        content: none;
    }

    .cell-actions {
        flex-grow: 1;
        justify-content: space-around;
    }

    .cell-actions .action-btn,
    .cell-actions .download-btn,
    .cell-actions .preview-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
    }
}