/* Utility Class */
.hidden {
    display: none !important;
}

/* Main Layout Container (Stacked vertically for tool + clean ad slots) */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    padding: 1.35rem 1rem 2.25rem;
    gap: 1rem;
}

.hero-section {
    text-align: center;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

.hero-section h1 {
    font-size: 2.05rem;
    margin-bottom: 0.45rem;
    color: var(--text-color);
}

.hero-section > p {
    color: var(--muted-text);
    font-size: 0.98rem;
    margin-bottom: 1.5rem;
}

/* Home Stage: Left Side Ad + Upload Box + Right Side Ad (Desktop) */
.home-ad-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
}

.home-ad-stage .upload-box {
    flex: 1 1 560px;
    max-width: 640px;
    min-width: 0;
}

/* AdSense Slots: Hidden by default until an ad fills them */
.ad-slot-wrapper {
    display: none;
    text-align: center;
}

.ad-slot-wrapper:has(.adsbygoogle[data-ad-status="filled"]),
.ad-slot-wrapper:has(iframe) {
    display: block;
}

.ad-slot-wrapper.ad-banner {
    width: 100%;
    max-width: 920px;
    margin: 0.25rem auto;
}

.ad-slot-wrapper.ad-banner .ad-slot-box {
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.ad-slot-wrapper.ad-side {
    width: 180px;
    flex-shrink: 0;
}

.ad-slot-wrapper.ad-side .ad-slot-box {
    min-height: 320px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

/* Upload Box Styling */
.upload-box {
    background-color: var(--card-bg);
    border: 2px dashed #a5b4fc;
    border-radius: 16px;
    padding: 3rem 2rem;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.upload-box:hover,
.upload-box.drag-over {
    background-color: #f8faff;
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 14px 28px -8px rgba(79, 70, 229, 0.16), 0 4px 10px -4px rgba(15, 23, 42, 0.05);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.upload-content svg {
    stroke: var(--primary-color);
}

.upload-content p {
    margin: 0;
    font-size: 1.08rem;
    color: var(--text-color);
}

.sub-text {
    font-size: 0.85rem;
    color: #94a3b8;
}

/* Editor Section Styling */
.editor-section {
    width: 100%;
    max-width: 1040px;
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 1.8rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.editor-container {
    display: grid;
    grid-template-columns: minmax(300px, 1.05fr) minmax(280px, 0.95fr);
    gap: 2rem;
    align-items: start;
}

.controls-box,
.preview-box {
    min-width: 0;
    width: 100%;
}

.preview-box {
    text-align: center;
    background: #f8fafc;
    padding: 1.35rem;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    position: sticky;
    top: 5.25rem;
}

.preview-box img {
    max-width: 100%;
    max-height: 340px;
    border-radius: 10px;
    margin: 0.5rem 0 0.75rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

/* Reference-style clean info layout below preview image */
.ezi-preview-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-top: 0.35rem;
}

.ezi-meta-filename {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-color);
    word-break: break-word;
}

.ezi-meta-dims-row {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 2px;
}

.ezi-dim-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: #e2e8f0;
    color: #1e293b;
}

.ezi-dim-badge.new-dim {
    background: #dcfce7;
    color: #166534;
}

.ezi-dim-arrow {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--muted-text);
}

.ezi-meta-size {
    font-size: 0.82rem;
    color: var(--muted-text);
    margin-top: 2px;
}

.controls-box h3,
.preview-box h3 {
    margin-bottom: 0.95rem;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-color);
}

/* Dynamic Tabs */
#resizeTabsBar {
    display: flex;
    gap: 6px;
    padding: 4px;
    border-radius: 10px;
    background: #f1f5f9;
    border: 1px solid var(--border-color);
    margin: 0 0 1.05rem;
}

#resizeTabsBar button {
    flex: 1;
    padding: 8px 10px;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.15s ease;
}

/* Inputs & Selects */
.input-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.range-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.range-label-row #qualityVal {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-color);
    background: var(--primary-soft);
    padding: 2px 8px;
    border-radius: 999px;
}

.input-group label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-color);
}

.input-group input[type="number"],
.controls-box input[type="number"],
.controls-box select {
    width: 100%;
    padding: 0.62rem 0.78rem;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    font-size: 0.95rem;
    background: var(--card-bg);
    color: var(--text-color);
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group input[type="range"] {
    width: 100%;
    accent-color: var(--primary-color);
    cursor: pointer;
    height: 6px;
}

.input-group input[type="number"]:focus,
.controls-box input[type="number"]:focus,
.controls-box select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}

/* Preview Stage & Floating Action Icons */
#eziPreviewStage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

#eziPhotoActionBar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
    position: relative;
}

.ezi-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border-strong);
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.15s ease;
    touch-action: manipulation;
}

.ezi-icon-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Action Buttons */
#eziActionRow {
    display: flex;
    flex-direction: column;
    gap: 9px;
    margin-top: 1.05rem;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 0.82rem 1rem;
    border: none;
    border-radius: 9px;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 0;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.22);
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(67, 56, 202, 0.28);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-color);
    border: 1px solid var(--border-strong);
}

.btn-secondary:hover:not(:disabled) {
    background-color: #e2e8f0;
}

.btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Tablet & Mobile Responsive */
@media (max-width: 900px) {
    .home-ad-stage {
        flex-direction: column;
        gap: 12px;
    }

    .home-ad-stage .upload-box {
        width: 100%;
        max-width: 600px;
    }

    .ad-slot-wrapper.ad-side {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .main-container {
        padding: 0.75rem 0.75rem 1.25rem;
        gap: 0.65rem;
    }

    .hero-section {
        display: block;
    }

    .hero-section h1 {
        font-size: 1.55rem;
    }

    .hero-section > p {
        margin-bottom: 0.9rem;
        font-size: 0.92rem;
    }

    .home-ad-stage {
        display: block;
        width: 100%;
    }

    /* Strict 1:1 Square Upload Box on Mobile (Preserving User's Custom Dimensions) */
    .home-ad-stage .upload-box,
    .upload-box {
        flex: none !important;
        width: min(125vw, 390px) !important;
        height: min(82vw, 390px) !important;
        max-width: 390px !important;
        max-height: 390px !important;
        min-height: 0 !important;
        aspect-ratio: 1 / 1;
        padding: 1rem !important;
        border-radius: 12px;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 auto !important;
    }

    .upload-content {
        gap: 8px;
        text-align: center;
    }

    .upload-content svg {
        width: 34px;
        height: 34px;
    }

    .upload-content p {
        font-size: 0.95rem;
        line-height: 1.3;
    }

    .sub-text {
        font-size: 0.78rem;
    }

    .ad-slot-wrapper.ad-banner .ad-slot-box {
        min-height: 60px;
    }

    .editor-section {
        padding: 1.1rem;
        border-radius: 12px;
    }

    .editor-container {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .preview-box {
        order: -1;
        position: static;
        padding: 1rem;
    }

    .preview-box img {
        max-height: 260px;
    }

    .ezi-icon-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }

    #resizeTabsBar button {
        padding: 8px 6px;
        font-size: 0.8rem;
    }

    .input-group input[type="number"],
    .controls-box input[type="number"],
    .controls-box select {
        font-size: 16px;
        min-height: 42px;
    }

    .btn-primary,
    .btn-secondary {
        min-height: 44px;
    }
}
