/* ==========================================================
   VANTIX IMAGE OPTIMIZER CSS
   Chassis: Duplicated from Photo Shield (proven stable)
   Product skin: Image Optimizer specific controls
   ========================================================== */

/* LAYOUT */
.ps-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 0;
}
.ps-sidebar {
    flex: 0 0 300px;
    position: sticky;
    top: 6rem;
    height: max-content;
}

/* UTILITIES */
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.pt-4 { padding-top: 1rem; }

/* RESPONSIVE: VANISH SIDEBAR ON MOBILE */
@media (max-width: 991px) {
    .ps-sidebar {
        display: none;
    }
    .ps-layout {
        padding: 0;
    }
    .device-frame {
        border: none;
        border-radius: 0;
        min-height: 100vh;
    }
}

/* =========================================
   IPHONE 17 PRO CHASSIS (Duplicated stable)
   ========================================= */
.iphone-17-chassis {
    width: 100%;
    max-width: 430px;
    height: calc(100vh - 10rem);
    max-height: 932px;
    min-height: 650px;
    margin-bottom: 6rem;
    background-color: #000;
    border-radius: 56px;
    border: 8px solid #1a1a1a;
    box-shadow: 0 0 50px rgba(0,0,0,0.5), inset 0 0 0 2px rgba(255,255,255,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    position: relative;
    --color-primary: #d4af37;
    --color-accent: #2dd4bf;
    --color-surface: #0c1324;
    --color-on-surface: #dce1fb;
    --color-on-surface-variant: #d0c5af;
    --color-success: #10B981;
    --color-absolute-black: #000000;
    --font-display: 'Inter', sans-serif;
    color: var(--color-on-surface);
    font-family: var(--font-display);
}

.iphone-17-chassis * {
    box-sizing: border-box;
}

.iphone-dynamic-island {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 35px;
    background: #000;
    border-radius: 999px;
    z-index: 100;
    display: flex;
    align-items: center;
    padding: 0 12px;
    box-shadow: 0 0 1px 1px rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.05);
    pointer-events: none;
}
.iphone-dynamic-island-cam {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: radial-gradient(circle, #1a2a44 40%, #000 60%);
    border: 1px solid rgba(255,255,255,0.08);
}

.iphone-top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 50;
    padding: 10px 12px;
    padding-top: 52px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: transparent;
    flex-shrink: 0;
}
.iphone-top-bar button {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    transition: opacity 0.3s, transform 0.1s;
    padding: 8px;
}
.iphone-top-bar button:active {
    transform: scale(0.95);
}

.iphone-main-content {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: 0;
    background-color: var(--color-surface);
    min-height: 0;
}

/* Ambient glow background */
.iphone-ambient-bg {
    position: absolute;
    top: -10%; left: -10%; right: -10%; bottom: -10%;
    background-size: cover;
    background-position: center;
    filter: blur(60px) saturate(180%);
    opacity: 0;
    transition: opacity 0.8s ease;
    z-index: 0;
    pointer-events: none;
}
.iphone-ambient-bg.active {
    opacity: 0.5;
}

.iphone-canvas-area {
    height: 60%;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
    z-index: 1;
    flex-shrink: 0;
}
.iphone-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 0;
    overflow: hidden;
    border: none;
    box-shadow: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #050505;
    transition: all 0.5s;
    cursor: pointer;
}
.iphone-image-container:hover {
    box-shadow: 0 0 30px rgba(45,212,191,0.1);
}
.iphone-image-container img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: none;
}
.iphone-image-container img.active {
    display: block;
}

/* VANILLA CROP OVERLAY */
#crop-overlay {
    position: absolute;
    /* Dimensions and position will be set via JS to perfectly match the rendered img */
    z-index: 10;
    pointer-events: auto;
    touch-action: none;
}
#crop-overlay.hidden {
    display: none !important;
}
#crop-box {
    position: absolute;
    border: 2px solid var(--color-accent);
    background: rgba(45, 212, 191, 0.1);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    cursor: move;
    touch-action: none;
    /* Default size, JS will adjust */
    top: 10%; left: 10%; width: 80%; height: 80%;
}
.crop-handle {
    position: absolute;
    width: 16px; height: 16px;
    background: #fff;
    border: 2px solid var(--color-accent);
    border-radius: 50%;
}
.crop-handle.nw { top: -8px; left: -8px; cursor: nwse-resize; }
.crop-handle.ne { top: -8px; right: -8px; cursor: nesw-resize; }
.crop-handle.sw { bottom: -8px; left: -8px; cursor: nesw-resize; }
.crop-handle.se { bottom: -8px; right: -8px; cursor: nwse-resize; }
.iphone-upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: rgba(45,212,191,0.8);
    position: absolute;
    top: 25%;
    transform: translateY(-50%);
}
.iphone-upload-prompt.hidden {
    display: none;
}
.iphone-upload-prompt span.material-symbols-outlined {
    font-size: 30px;
}
.iphone-upload-prompt span.text {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
}

.iphone-protected-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    background: rgba(16, 185, 129, 0.3);
    border: 1px solid rgba(16, 185, 129, 0.3);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 12px;
    padding: 8px 16px;
    z-index: 15;
}
.iphone-protected-badge.active {
    display: flex;
}
.iphone-protected-badge span.material-symbols-outlined {
    font-size: 16px;
    color: var(--color-success);
}
.iphone-protected-badge span.text {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: var(--color-success);
}

/* SCANNING STATE */
@keyframes pulse {
    0% { transform: scale(0.5); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* CONTROL AREA: Glass Panel */
.iphone-control-area {
    position: relative;
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(12, 19, 36, 0.45);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    border-top: 1px solid rgba(255,255,255,0.15);
    border-radius: 32px 32px 0 0;
    z-index: 10;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.5);
    min-height: 0;
}

.iphone-tab-bar {
    width: 100%;
    overflow-x: auto;
    padding: 24px 16px 16px 16px;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-start;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.iphone-tab-bar::-webkit-scrollbar {
    display: none;
}
.iphone-tab-button {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--color-primary);
    background: var(--color-primary);
    color: #000;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    opacity: 0.5;
}
.iphone-tab-button:hover {
    opacity: 0.8;
}
.iphone-tab-button:active {
    transform: scale(0.92);
}
.iphone-tab-button.active {
    opacity: 1;
    box-shadow: 0 0 15px rgba(212,175,55,0.4);
}

.iphone-tab-contents {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 16px 32px 16px;
    overflow-y: auto;
    width: 100%;
    min-height: 0;
}

.iphone-tab-content {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: 8px;
    animation: fadeInTab 0.3s ease-in-out;
}
.iphone-tab-content.active {
    display: flex;
}

@keyframes fadeInTab {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.iphone-glass-element {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 8px 12px;
}
.iphone-input {
    width: 100%;
    padding: 10px 12px;
    color: var(--color-on-surface);
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 12px;
}
.iphone-input::placeholder {
    color: rgba(208, 197, 175, 0.4);
}
.iphone-input:focus {
    border-color: rgba(45,212,191,0.5);
    box-shadow: 0 0 10px rgba(45,212,191,0.1);
}

/* Slider */
.iphone-slider-container {
    width: 100%;
    padding: 0 4px;
}
.iphone-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 12px;
}
.iphone-slider-title {
    font-size: 14px;
    color: var(--color-on-surface);
    opacity: 0.9;
    font-weight: 500;
}
.iphone-slider-value {
    font-family: monospace;
    font-size: 12px;
    color: var(--color-accent);
    opacity: 0.8;
}
.iphone-slider-wrap {
    position: relative;
    height: 16px;
    display: flex;
    align-items: center;
}
.iphone-slider {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 10;
}
.iphone-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--color-accent);
    cursor: pointer;
    margin-top: -7px;
    box-shadow: 0 0 10px rgba(45,212,191,0.6);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.iphone-slider:hover::-webkit-slider-thumb {
    box-shadow: 0 0 15px rgba(45,212,191,0.8);
    transform: scale(1.1);
}
.iphone-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 1px;
}

/* Primary button */
.iphone-btn-primary {
    width: 100%;
    background: var(--color-primary);
    color: #000;
    font-size: 14px;
    font-weight: 700;
    padding: 12px;
    border-radius: 999px;
    border: none;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 0 15px rgba(212,175,55,0.3);
    cursor: pointer;
}
.iphone-btn-primary:hover {
    opacity: 0.9;
    box-shadow: 0 0 20px rgba(212,175,55,0.5);
}
.iphone-btn-primary:active {
    transform: scale(0.92);
}

/* Info Rows */
.iphone-info-row {
    display: flex;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 12px;
}
.iphone-info-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
.iphone-info-label {
    color: var(--color-on-surface-variant);
    font-size: 12px;
}
.iphone-info-value {
    color: var(--color-on-surface);
    font-size: 14px;
}

/* Pro Teaser / Cross-promo */
.iphone-pro-teaser {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(212,175,55,0.2);
    cursor: pointer;
    transition: background 0.3s;
}
.iphone-pro-teaser:hover {
    background: rgba(255,255,255,0.05);
}
.iphone-pro-teaser .left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.iphone-pro-teaser .icon-box {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(212,175,55,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}
.iphone-pro-teaser .icon-box span {
    font-size: 16px;
    color: var(--color-primary);
}
.iphone-pro-teaser .text {
    font-size: 12px;
    color: var(--color-on-surface-variant);
}
.iphone-pro-teaser .lock {
    font-size: 16px;
    color: rgba(212,175,55,0.6);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: 0.3s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
}
input:checked + .slider {
    background-color: var(--color-primary);
}
input:checked + .slider:before {
    transform: translateX(20px);
}
.slider.round {
    border-radius: 24px;
}
.slider.round:before {
    border-radius: 50%;
}

/* =========================================
   IMAGE OPTIMIZER SPECIFIC STYLES
   ========================================= */

/* Preset Grid */
.io-preset-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.io-preset-btn {
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: var(--color-on-surface);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.io-preset-btn:hover {
    background: rgba(45,212,191,0.1);
    border-color: rgba(45,212,191,0.3);
}
.io-preset-btn.active {
    background: rgba(45,212,191,0.15);
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 0 8px rgba(45,212,191,0.2);
}

/* Custom Dimensions */
.io-custom-dims {
    margin-top: 8px;
}
.io-link-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(45,212,191,0.1);
    border: 1px solid rgba(45,212,191,0.2);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.io-link-icon span {
    font-size: 16px;
    color: var(--color-accent);
    transition: all 0.2s;
}
.io-link-icon.unlocked {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.1);
}
.io-link-icon.unlocked span {
    color: rgba(255,255,255,0.3);
}

/* Compression Mode Selector */
.io-mode-selector {
    display: flex;
    gap: 4px;
    background: rgba(255,255,255,0.03);
    border-radius: 10px;
    padding: 3px;
    border: 1px solid rgba(255,255,255,0.05);
}
.io-mode-btn {
    flex: 1;
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--color-on-surface-variant);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.io-mode-btn.active {
    background: rgba(45,212,191,0.15);
    color: var(--color-accent);
    box-shadow: 0 0 8px rgba(45,212,191,0.15);
}
.io-mode-btn:hover:not(.active) {
    color: var(--color-on-surface);
}

/* Target Size Buttons */
.io-target-btn {
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: var(--color-on-surface);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.io-target-btn:hover {
    background: rgba(45,212,191,0.1);
    border-color: rgba(45,212,191,0.3);
}
.io-target-btn.active {
    background: rgba(45,212,191,0.15);
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 0 8px rgba(45,212,191,0.2);
}

/* Size Badge */
.io-size-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 10px;
    margin-top: 8px;
}
.io-size-label {
    font-size: 12px;
    color: var(--color-on-surface-variant);
}
.io-size-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-accent);
    font-family: monospace;
}

/* Format Buttons */
.io-format-btn {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: var(--color-on-surface);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.02em;
}
.io-format-btn:hover {
    background: rgba(45,212,191,0.1);
    border-color: rgba(45,212,191,0.3);
}
.io-format-btn.active {
    background: rgba(45,212,191,0.15);
    border-color: var(--color-accent);
    color: var(--color-accent);
    box-shadow: 0 0 8px rgba(45,212,191,0.2);
}

/* Warning */
.io-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.15);
    border-radius: 10px;
    margin-top: 8px;
}
.io-warning.hidden {
    display: none;
}

/* Savings highlight */
.io-savings {
    color: var(--color-success) !important;
    font-weight: 700 !important;
}

/* Success badge teal */
.io-success-badge span.material-symbols-outlined {
    color: var(--color-accent) !important;
}
.io-success-badge span.text {
    color: var(--color-accent) !important;
}
.io-success-badge {
    background: rgba(45,212,191,0.15) !important;
    border-color: rgba(45,212,191,0.2) !important;
}

/* =========================================
   CROPPER.JS THEME OVERRIDES
   ========================================= */
.cropper-view-box, .cropper-face {
    border-radius: 0;
}
.cropper-view-box {
    outline: 2px solid var(--color-primary);
    outline-color: var(--color-primary);
}
.cropper-line {
    background-color: var(--color-primary);
}
.cropper-point {
    background-color: var(--color-primary);
    width: 10px;
    height: 10px;
    opacity: 1;
}
.cropper-point.point-se {
    width: 15px;
    height: 15px;
}
.cropper-center {
    display: none;
}
.cropper-modal {
    background-color: rgba(0, 0, 0, 0.85);
}
.cropper-bg {
    background-image: none;
    background-color: transparent;
}

/* =========================================
   MOBILE: NATIVE APP MODE
   ========================================= */
@media (max-width: 1023px) {
    .product-hero-sticky,
    header,
    nav,
    footer,
    .site-footer {
        display: none !important;
    }

    .product-page-shell {
        padding: 0 !important;
        min-height: 100dvh !important;
    }
    .product-page-shell .container {
        padding: 0 !important;
        max-width: 100% !important;
    }
    .product-grid-layout {
        gap: 0 !important;
    }
    .product-app-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    .iphone-17-chassis {
        border-radius: 0 !important;
        border: none !important;
        height: 100dvh !important;
        max-height: none !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
    
    .marketing-content {
        padding: 24px !important;
        margin-top: 4rem !important;
    }
}
