/* =====================================================
   Image Resizer - Gemini Inspired Design
   Ethereal, Intelligent, and Clean Light Theme
   ===================================================== */

/* CSS Variables */
:root {
    /* Color Palette - Gemini Inspired */
    --bg-base: #FFFFFF;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(240, 244, 255, 0.6);

    /* Text Colors */
    --text-primary: #1F1F1F;
    --text-secondary: #444746;
    --text-muted: #747775;

    /* Gemini Gradients & Accents */
    /* Deep Blue to Violet/Blue shift */
    --gemini-gradient: linear-gradient(135deg, #4285F4 0%, #9013FE 100%);
    --gemini-mesh: radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);

    --accent-blue: #1b6ef3;
    /* Google Blue tone */
    --accent-glow: rgba(27, 110, 243, 0.15);

    --border-subtle: #E1E3E1;
    --border-accent: rgba(27, 110, 243, 0.3);

    /* Functional Colors */
    --input-bg: #EFF4F9;
    --focus-ring: rgba(66, 133, 244, 0.4);

    /* Spacing & Layout */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Border Radius - Softer, more organic */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 24px;
    --radius-xl: 32px;
    --radius-full: 9999px;

    /* Elevation & Depth */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.04);
    --shadow-float: 0 12px 32px rgba(66, 133, 244, 0.15);

    /* Animation */
    --ease-gemini: cubic-bezier(0.2, 0.0, 0, 1.0);
    --duration-normal: 0.3s;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Google Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #F0F2F5;
    /* Very subtle grey-blue base */
    background-image:
        radial-gradient(circle at 10% 10%, rgba(219, 22afe, 0.4) 0%, transparent 60%),
        radial-gradient(circle at 90% 90%, rgba(224, 204, 250, 0.4) 0%, transparent 60%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1600px;
    margin: 0 auto;
}

/* Header */
.app-header {
    padding: 8px var(--space-lg);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 4px;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(90deg, #4285F4, #9B72CB);
    /* Gemini text gradient */
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.app-title:hover {
    opacity: 0.8;
}

.logo-icon {
    width: 24px;
    height: 24px;
    stroke: #4285F4;
}

.app-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--space-md);
    padding: 0 var(--space-lg) var(--space-sm);
    width: 100%;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Preview Panel (Left) */
.preview-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    position: relative;
    overflow: hidden;
    transition: all var(--duration-normal) var(--ease-gemini);
}

/* Upload Zone */
/* Upload Zone - Squoosh inspired organic style */
.upload-zone {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-gemini);
}

.upload-bg-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.upload-bg-blobs div {
    position: absolute;
    border-radius: 50%;
    filter: blur(40px);
    opacity: 0.15;
    animation: float-blob 20s infinite alternate ease-in-out;
}

.blob-1 {
    width: 200px;
    height: 200px;
    background: #4285F4;
    top: -50px;
    left: -50px;
}

.blob-2 {
    width: 250px;
    height: 250px;
    background: #9013FE;
    bottom: -80px;
    right: -50px;
    animation-delay: -5s !important;
}

.blob-3 {
    width: 150px;
    height: 150px;
    background: #0ea5e9;
    top: 50%;
    left: 10%;
    animation-delay: -10s !important;
}

@keyframes float-blob {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 40px) scale(1.1);
    }
}

.upload-blob-container {
    position: relative;
    z-index: 2;
    padding: 40px;
}

.upload-blob {
    width: 240px;
    height: 240px;
    background: var(--gemini-gradient);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    box-shadow: 0 20px 50px rgba(66, 133, 244, 0.3);
    animation: organic-blob 8s infinite ease-in-out;
    transition: transform 0.3s var(--ease-gemini);
}

@keyframes organic-blob {

    0%,
    100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }

    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }

    50% {
        border-radius: 50% 30% 50% 50% / 40% 70% 60% 30%;
    }

    75% {
        border-radius: 40% 60% 40% 60% / 60% 40% 70% 40%;
    }
}

.upload-zone:hover .upload-blob {
    transform: scale(1.05);
    box-shadow: 0 30px 60px rgba(66, 133, 244, 0.4);
}

.upload-icon {
    width: 48px;
    height: 48px;
    stroke: white;
    stroke-width: 2;
    margin-bottom: 12px;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.upload-hint {
    position: absolute;
    bottom: 30px;
    color: var(--text-muted);
    font-size: 0.85rem;
    z-index: 2;
    transition: opacity 0.3s;
}

.upload-zone:hover .upload-hint {
    opacity: 0.7;
}

/* Image Preview Area */
.image-preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
    position: relative;
    /* Transparent checkerboard */
    background-image:
        linear-gradient(45deg, #E5E7EB 25%, transparent 25%),
        linear-gradient(-45deg, #E5E7EB 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #E5E7EB 75%),
        linear-gradient(-45deg, transparent 75%, #E5E7EB 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: white;
}

#previewCanvas {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    /* Soft shadow for image */
    border-radius: 4px;
}

.reset-btn {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.reset-btn:hover {
    transform: scale(1.1);
    color: var(--accent-blue);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

/* Controls Panel (Right) */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    overflow-y: auto;
    padding: var(--space-xs);
    /* For focus rings */
    transition: opacity 0.3s var(--ease-gemini), filter 0.3s var(--ease-gemini);
}

.controls-panel.disabled {
    opacity: 0.5;
    filter: saturate(0.5);
    user-select: none;
}

.controls-panel.disabled button,
.controls-panel.disabled input,
.controls-panel.disabled select {
    pointer-events: none;
}

/* Sections */
.control-section {
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s var(--ease-gemini);
}

.control-section:hover {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);
}

.section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-title svg {
    width: 18px;
    height: 18px;
    stroke: var(--accent-blue);
    stroke-width: 1.8;
}

/* Info Grid */
.info-grid {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.info-item {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding-bottom: 2px;
    border-bottom: 1px dashed var(--border-subtle);
}

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

.info-label {
    color: var(--text-muted);
}

.info-value {
    font-weight: 500;
    color: var(--text-primary);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inputs & Form Elements */
.input-with-unit {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border-radius: var(--radius-md);
    padding: 4px;
    transition: box-shadow 0.2s ease;
    border: 1px solid transparent;
}

.input-with-unit:focus-within {
    background: white;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.input-with-unit input,
.input-with-unit select {
    background: transparent;
    border: none;
    padding: 4px 8px;
    font-size: 0.9rem;
    color: var(--text-primary);
    font-family: inherit;
    width: 100%;
    outline: none;
}

.input-with-unit .unit {
    padding: 0 12px;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
}

.size-inputs {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    margin-bottom: 12px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 500;
}

.percentage-input label,
.resolution-input label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
    font-weight: 500;
}

.percentage-input,
.resolution-input {
    margin-bottom: 8px;
}

/* Link/Chain Button */
.link-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #F1F3F4;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    pointer-events: auto;
}

.link-btn:hover {
    background: #E8EAED;
}

.link-btn.linked {
    background: #E8F0FE;
    /* Blue background for ON */
    color: var(--accent-blue);
    /* Blue color for ON */
}

.link-btn.linked:hover {
    background: #D2E3FC;
}

.link-btn svg {
    width: 20px;
    height: 20px;
}

.link-btn svg.unlinked {
    display: none;
}

.link-btn.linked svg.unlinked {
    display: none;
}

.link-btn.linked svg.linked {
    display: block;
}

.link-btn:not(.linked) svg.linked {
    display: none;
}

.link-btn:not(.linked) svg.unlinked {
    display: block;
}

/* Range Sliders (Gemini Style) */
input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, #AECBFA, #E8F0FE);
    border-radius: 4px;
    outline: none;
    margin: 8px 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--accent-blue);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    transition: transform 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.quality-header,
.sharpness-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.quality-value,
.sharpness-value {
    color: var(--accent-blue);
    font-weight: 600;
}

.sharpness-labels,
.quality-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0;
}



/* Format Selector */
.format-selector {
    margin-bottom: 16px;
}

.format-selector label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.format-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.format-btn {
    padding: 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: white;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-gemini);
}

.format-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: #F8FAFD;
}

.format-btn.active {
    background: linear-gradient(135deg, #4285F4, #5D80E5);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3);
}

/* Quality Slider */
.quality-slider {
    margin-bottom: 12px;
}

/* Export Info Box */
.export-info {
    background: #F8FAFD;
    border-radius: var(--radius-md);
    padding: 8px 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(66, 133, 244, 0.05);
}

.export-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.5;
}

.export-info-item .info-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.export-info-item .info-value {
    font-size: 0.95rem;
    color: var(--text-primary);
    font-weight: 500;
    letter-spacing: 0.01em;
}

/* Download Button (Hero) */
.download-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(100deg, #1A73E8, #8E24AA);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s var(--ease-gemini);
    box-shadow: var(--shadow-float);
    position: relative;
    overflow: hidden;
}

.download-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(100deg, #174EA6, #4A148C);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 1;
}

.download-btn span,
.download-btn svg {
    z-index: 2;
}

.download-btn svg {
    width: 20px;
    height: 20px;
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(66, 133, 244, 0.25);
}

.download-btn:hover::before {
    opacity: 1;
}

/* Footer */
.app-footer {
    text-align: center;
    padding: var(--space-md);
    color: var(--text-muted);
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Animations */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.98) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.control-section:not([hidden]) {
    animation: fadeInScale 0.6s var(--ease-gemini) forwards;
}

/* Utility */
[hidden] {
    display: none !important;
}