:root {
    --bg-start: #f5f7fa;
    --bg-end: #c3cfe2;
    --surface: #ffffff;
    --surface-soft: #f9f9ff;
    --surface-card: #ffffff;
    --text: #333333;
    --text-soft: #666666;
    --text-contrast: #ffffff;
    --header-start: #e9cde1;
    --header-end: #fc25a2;
    --accent: #fc25a2;
    --accent-soft: #fce4f2;
    --border: #e6e6e6;
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --shadow-main: 0 10px 30px rgba(0, 0, 0, 0.12);
    --shadow-card: 0 6px 20px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
    --bg-start: #0f172a;
    --bg-end: #1e293b;
    --surface: #111827;
    --surface-soft: #1f2937;
    --surface-card: #182334;
    --text: #e5e7eb;
    --text-soft: #c0c7d4;
    --text-contrast: #ffffff;
    --header-start: #3f1d3d;
    --header-end: #93256b;
    --accent: #ff4cb5;
    --accent-soft: #4f1d42;
    --border: #304056;
    --modal-overlay: rgba(5, 8, 14, 0.85);
    --shadow-main: 0 16px 36px rgba(0, 0, 0, 0.45);
    --shadow-card: 0 12px 24px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: 15px;
    box-shadow: var(--shadow-main);
    overflow: hidden;
}

.comparators-container {
    margin-top: 24px;
    padding: 30px;
    text-align: center;
}

.site-header {
    background: linear-gradient(90deg, var(--header-start) 0%, var(--header-end) 100%);
    color: var(--text-contrast);
    padding: 25px;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    text-decoration: none;
    color: inherit;
    width: fit-content;
    margin: 0 auto;
}

.logo img {
    height: 80px;
    width: auto;
}

.logo span {
    font-family: "Great Vibes", cursive;
    font-size: 3rem;
    font-weight: 400;
    letter-spacing: 1px;
}

.tagline {
    font-style: italic;
    margin-top: 8px;
}

.toolbar {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
}

.display-controls,
.admin-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-select {
    border: 1px solid rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-contrast);
    padding: 8px 10px;
    border-radius: 20px;
    outline: none;
    cursor: pointer;
}

.language-select option {
    color: #111827;
}

.admin-btn {
    border: 1px solid rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.18);
    color: var(--text-contrast);
    border-radius: 20px;
    cursor: pointer;
    padding: 8px 14px;
    transition: all 0.25s ease;
}

.admin-btn:hover {
    background: #ffffff;
    color: var(--accent);
}

.admin-status {
    font-size: 0.9rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    padding: 6px 10px;
}

.main-content {
    padding: 30px;
}

#uploadSection h2 {
    margin-bottom: 18px;
}

.upload-options {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.option-card {
    flex: 1;
    min-width: 260px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-card);
    box-shadow: var(--shadow-card);
    padding: 20px;
    text-align: center;
}

.option-card i {
    font-size: 2.6rem;
    color: var(--accent);
    margin-bottom: 10px;
}

.option-card h3 {
    margin-bottom: 12px;
}

.option-card button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    cursor: pointer;
    transition: background 0.2s ease;
}

.option-card button:hover {
    background: #d91d87;
}

.upload-area {
    display: none;
    border: 2px dashed var(--accent);
    border-radius: 12px;
    background: var(--surface-soft);
    padding: 24px;
    text-align: center;
}

.upload-area.active {
    display: block;
}

.upload-area i {
    font-size: 2.5rem;
    color: var(--accent);
}

.url-input {
    width: 100%;
    margin: 14px 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    background: var(--surface);
    color: var(--text);
}

.submit-btn {
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: #ffffff;
    padding: 11px 22px;
    cursor: pointer;
}

.gallery-section h1 {
    font-size: 2.4rem;
    text-align: center;
}

.quantity-row {
    margin: 24px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#cantidadSelector {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    background: var(--surface);
    color: var(--text);
}

.gallery {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    transition: opacity 0.2s ease;
    min-height: 140px;
}

.gallery-wrapper {
    position: relative;
}

.gallery-loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--text);
    font-weight: 600;
}

:root[data-theme="dark"] .gallery-loading {
    background: rgba(10, 16, 30, 0.72);
}

.gallery-dimmed {
    opacity: 0.38;
    pointer-events: none;
}

.loading-spinner {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    animation: spinner-rotate 0.8s linear infinite;
}

.gallery-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    height: 220px;
    cursor: zoom-in;
}

.gallery-item.is-loading {
    background: linear-gradient(110deg, var(--surface-soft) 30%, var(--surface) 45%, var(--surface-soft) 60%);
    background-size: 200% 100%;
    animation: gallery-shimmer 1.2s linear infinite;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transform: scale(1.03);
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.gallery-image.loaded {
    opacity: 1;
    transform: scale(1);
}

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    background: rgba(231, 76, 60, 0.9);
    color: #ffffff;
    cursor: pointer;
    display: none;
}

.gallery-item:hover .delete-btn {
    display: block;
}

.empty-message {
    grid-column: 1 / -1;
    background: var(--surface-soft);
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    color: var(--text-soft);
}

.pagination {
    margin-top: 24px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.pagination-button {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    cursor: pointer;
}

.pagination-button.active {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.pagination-button.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.pagination-ellipsis {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-soft);
}

.pagination-info {
    text-align: center;
    margin-top: 12px;
    color: var(--text-soft);
}

.instructions {
    background: var(--surface-soft);
    border-radius: 10px;
    margin: 16px auto 24px;
    max-width: 620px;
    padding: 14px;
}

.instructions p {
    margin: 8px 0;
}

.icon {
    display: inline-block;
    margin-right: 6px;
}

.section {
    margin-top: 26px;
    background: var(--surface-soft);
    border-radius: 12px;
    padding: 22px;
}

.section-title {
    color: #8d0000;
    margin-bottom: 14px;
}

:root[data-theme="dark"] .section-title {
    color: #ff8585;
}

.section-description {
    margin-bottom: 20px;
}

.comparison-container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    cursor: col-resize;
}

.image-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.image-after,
.image-before img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    display: block;
}

.image-after {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.image-before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 50%;
    overflow: hidden;
    z-index: 2;
}

.image-before img {
    position: absolute;
    inset: 0;
}

.slider-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    width: 4px;
    transform: translateX(0);
    background: #ffffff;
    z-index: 3;
    will-change: transform;
}

.slider-handle {
    position: absolute;
    left: 0;
    top: 50%;
    width: 44px;
    height: 44px;
    transform: translate(0, -50%);
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
    z-index: 4;
    /* Evitar comportamiento táctil por defecto durante el arrastre */
    touch-action: none;
    will-change: transform;
}

/* Transición suave cuando no hay arrastre activo, controlada con clases */
.comparison-container.is-animating .slider-line,
.comparison-container.is-animating .slider-handle {
    transition: transform 200ms ease-out;
}

/* Durante arrastre quitar cualquier transición para máxima respuesta */
.comparison-container.is-dragging .slider-line,
.comparison-container.is-dragging .slider-handle {
    transition: none !important;
}

.image-info {
    margin-top: 14px;
    display: flex;
    justify-content: space-between;
    color: var(--text-soft);
    font-style: italic;
}

.social-section {
    margin: 26px auto 0;
    text-align: center;
}

.social-section h3 {
    color: var(--accent);
    margin-bottom: 10px;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 16px;
}

.social-links a {
    font-size: 28px;
}

.social-links a[aria-label="WhatsApp"] {
    color: #25d366;
}

.social-links a[aria-label="Facebook"] {
    color: #1877f2;
}

.social-links a[aria-label="Instagram"] {
    color: #e4405f;
}

.site-footer {
    margin-top: 24px;
    background: var(--header-start);
    color: var(--text);
    text-align: center;
    padding: 20px 10px;
    font-size: 0.9rem;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--modal-overlay);
}

.modal-content {
    margin: 15vh auto 0;
    width: min(420px, 92vw);
    background: var(--surface);
    color: var(--text);
    border-radius: 10px;
    padding: 24px;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 12px;
    color: var(--accent);
}

.modal-content input,
.modal-content button {
    width: 100%;
    margin-top: 10px;
    padding: 12px;
    border-radius: 6px;
}

.modal-content input {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.modal-content button {
    border: none;
    cursor: pointer;
    background: var(--accent);
    color: #ffffff;
}

.close {
    position: absolute;
    right: 16px;
    top: 8px;
    font-size: 28px;
    color: var(--text-soft);
    cursor: pointer;
}

.message {
    min-height: 22px;
    margin-top: 12px;
    color: #e74c3c;
}

.fs-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.92);
    cursor: pointer;
}

.fs-content {
    max-width: 90%;
    max-height: 90%;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 8px;
}

.fs-close {
    position: absolute;
    right: 28px;
    top: 20px;
    color: #ffffff;
    font-size: 40px;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

@keyframes spinner-rotate {
    to {
        transform: rotate(360deg);
    }
}

@keyframes gallery-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.visually-hidden {
    border: 0;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    width: 1px;
}

@media (max-width: 900px) {
    .logo span {
        font-size: 2.5rem;
    }

    .toolbar {
        justify-content: center;
    }
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .main-content,
    .comparators-container {
        padding: 18px;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }

    .gallery-section h1 {
        font-size: 1.9rem;
    }

    .image-info {
        font-size: 0.9rem;
    }
}
