/**
 * Magnetky Upload - Frontend Styles
 */

/* ========================
 * Custom Fields (personalization)
 * ======================== */

.magnetky-custom-fields {
    margin-bottom: 1.5em;
}

.magnetky-field {
    margin-bottom: 1em;
    text-align: left;
}

.magnetky-field label {
    display: block;
    margin-bottom: 0.3em;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
}

.magnetky-field input[type="text"],
.magnetky-field input[type="number"],
.magnetky-field input[type="time"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 10px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.magnetky-field input:focus {
    outline: none;
    border-color: var(--theme-palette-color-1, #E07A5F);
    box-shadow: 0 0 0 3px rgba(224, 122, 95, 0.15);
}

.magnetky-upload-wrapper {
    margin: 16px 0;
    padding: 20px;
    /* Glassmorphism base - forcing override */
    background: rgba(255, 255, 255, 0.7) !important;
    background-image: none !important;
    /* Remove theme gradient */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.magnetky-upload-wrapper:hover {
    background: rgba(255, 255, 255, 0.85) !important;
    background-image: none !important;
    border-color: #fff !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.magnetky-upload-wrapper label {
    display: block;
    margin-bottom: 6px;
    font-weight: 700;
    font-size: 16px;
    color: #2c3e50;
    letter-spacing: -0.3px;
}

.magnetky-upload-wrapper .description {
    color: #666;
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.magnetky-required {
    color: #e74c3c;
}

.magnetky-upload-btn {
    display: inline-block;
    padding: 10px 24px;
    background: linear-gradient(135deg, #0073aa 0%, #005a87 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.magnetky-upload-btn:hover {
    background: linear-gradient(135deg, #008cd1 0%, #006da3 100%);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 115, 170, 0.35);
}

.magnetky-upload-btn:disabled {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ========================
 * Multi-photo Grid
 * ======================== */

.magnetky-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 16px 0;
}

@media (max-width: 600px) {
    .magnetky-photos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Photo Card */
.magnetky-photo-card {
    position: relative;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    padding: 8px;
    transition: all 0.3s ease;
}

.magnetky-photo-card:hover {
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.magnetky-photo-card.is-uploading {
    opacity: 0.7;
}

.magnetky-photo-card .magnetky-lightbox-link {
    display: block;
    position: relative;
    cursor: zoom-in;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
}

.magnetky-photo-card .magnetky-lightbox-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.0);
    transition: background 0.3s ease;
}

.magnetky-photo-card .magnetky-lightbox-link:hover::after {
    background: rgba(0, 0, 0, 0.1);
}

.magnetky-photo-card .magnetky-lightbox-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

/* Upload loader overlay */
.magnetky-photo-card__loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: magnetky-spin 0.8s linear infinite;
}

@keyframes magnetky-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Remove button */
.magnetky-photo-card__remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    background: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 2;
    padding: 0;
}

.magnetky-photo-card__remove:hover {
    background: #e74c3c;
    transform: scale(1.1);
}

/* Quantity controls */
.magnetky-photo-card__controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
}

.magnetky-qty-minus,
.magnetky-qty-plus {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: var(--theme-palette-color-1, #E07A5F);
    color: white;
    cursor: pointer;
    font-size: 18px;
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.magnetky-qty-minus:hover,
.magnetky-qty-plus:hover {
    background: var(--theme-palette-color-2, #C65D45);
    transform: scale(1.1);
}

.magnetky-qty-display {
    min-width: 24px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #2c3e50;
    user-select: none;
}

/* Hide WC quantity input and add-to-cart button for upload products */
form.cart:has(.magnetky-upload-wrapper) .quantity,
form.cart:has(.magnetky-upload-wrapper) .single_add_to_cart_button,
form.cart:has(.magnetky-upload-wrapper) .added_to_cart {
    display: none !important;
}

/* Our own add-to-cart button */
.magnetky-submit-btn {
    display: block;
    width: 100%;
    margin-top: 16px;
    padding: 14px 24px;
    background: var(--theme-palette-color-1, #E07A5F);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.magnetky-submit-btn:hover {
    background: var(--theme-palette-color-2, #C65D45);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.magnetky-submit-btn:disabled,
.magnetky-submit-btn.loading {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ========================
 * Legacy single-preview (kept for fallback)
 * ======================== */

.magnetky-photo-preview {
    margin-top: 14px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    display: inline-block;
    position: relative;
    backdrop-filter: blur(5px);
}

.magnetky-photo-preview img {
    max-width: 160px;
    max-height: 160px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
}

.magnetky-remove-btn {
    display: block;
    margin: 15px auto 0;
    padding: 8px 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #e74c3c;
    border: 1px solid #e74c3c;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.magnetky-remove-btn:hover {
    background: #e74c3c;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(231, 76, 60, 0.2);
}

/* ========================
 * Error message
 * ======================== */

.magnetky-upload-error {
    color: #e74c3c;
    margin-top: 20px;
    padding: 12px;
    background: rgba(253, 242, 242, 0.9);
    border-radius: 8px;
    font-size: 14px;
    border: 1px solid rgba(231, 76, 60, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide per-unit price in cart for magnetky items (price depends on tier) */
.magnetky-cart-item .product-price,
.magnetky-cart-item td.product-price {
    display: none;
}

/* Cart photo grid */
.magnetky-cart-photos {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.magnetky-cart-photo-item {
    position: relative;
    display: inline-block;
}

.magnetky-cart-photo-qty {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    line-height: 1.3;
}

/* Cart thumbnail */
.magnetky-cart-thumbnail {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border: 2px solid white;
}

/* Static qty display in cart for magnetky items */
.magnetky-cart-qty {
    font-weight: 700;
    font-size: 16px;
    color: #2c3e50;
}

/* ========================
 * Grouped magnet display (cart)
 * Photos are visually chunked into "Magnetka N" frames.
 * ======================== */

.magnetky-cart-photos--grouped {
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
}

.magnetky-cart-magnet-group {
    border: 1px dashed #cfd8e3;
    border-radius: 8px;
    padding: 6px 8px 8px;
    background: #fafbfc;
}

.magnetky-cart-magnet-group__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7785;
    margin-bottom: 4px;
}

.magnetky-cart-magnet-group__items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ========================
 * Grouped magnet display (product page)
 * ======================== */

.magnetky-grouped-progress {
    margin: 8px 0 12px;
    padding: 8px 12px;
    background: #f4f6f9;
    border-left: 3px solid #4f8edc;
    border-radius: 4px;
    font-size: 14px;
    color: #34495e;
    line-height: 1.4;
}

.magnetky-photo-group {
    border: 1px dashed #cfd8e3;
    border-radius: 8px;
    padding: 8px 10px 10px;
    margin-bottom: 10px;
    background: #fafbfc;
}

.magnetky-photo-group.is-partial {
    border-color: #f0c869;
    background: #fffaef;
}

.magnetky-photo-group__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7785;
    margin-bottom: 6px;
}

.magnetky-photo-group.is-partial .magnetky-photo-group__label::after {
    content: ' — neúplná';
    color: #c98a1a;
}

.magnetky-photo-group__items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

/* ========================
 * Lightbox Modal
 * ======================== */

.magnetky-lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    z-index: 99999;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.magnetky-lightbox-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.magnetky-lightbox-content {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.magnetky-lightbox-modal.is-open .magnetky-lightbox-content {
    transform: scale(1);
}

.magnetky-lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
    font-weight: 300;
    line-height: 1;
    transition: transform 0.2s ease;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.magnetky-lightbox-close:hover {
    transform: rotate(90deg) scale(1.1);
}

/* ========================
 * Instagram Consent
 * ======================== */

.magnetky-instagram-consent {
    margin-top: 14px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    text-align: left;
    transition: all 0.3s ease;
}

.magnetky-instagram-consent:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(228, 64, 95, 0.3);
    box-shadow: 0 4px 16px rgba(228, 64, 95, 0.1);
}

.magnetky-instagram-consent label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #2c3e50;
    cursor: pointer;
    margin-bottom: 0;
}

.magnetky-instagram-consent input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #E4405F;
    cursor: pointer;
    flex-shrink: 0;
}

.magnetky-instagram-consent .magnetky-ig-icon {
    font-size: 20px;
}

.magnetky-instagram-consent .description {
    margin: 4px 0 0 28px;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.magnetky-instagram-consent input[type="checkbox"]:checked + .magnetky-ig-icon {
    animation: igPop 0.3s ease;
}

@keyframes igPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}
