/* Image Editor Layout */
.editor-app-container {
    max-height: none;
    height: auto;
    min-height: 100vh;
}

.editor-workspace {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
    width: 100%;
    max-width: 100%;
}

/* Tool Sidebar */
.editor-tools {
    min-height: 0;
    padding: 1.25rem;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
}

.tool-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 1.25rem;
}

.tool-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 10px;
    padding: 8px 4px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    transition: var(--transition-smooth);
    min-height: 48px;
    justify-content: center;
}

.tool-tab i {
    width: 18px;
    height: 18px;
}

.tool-tab:hover {
    background: #ffffff;
    color: var(--text-main);
}

.tool-tab.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.tool-panels {
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.tool-panel {
    display: none;
    flex-direction: column;
    gap: 10px;
}

.tool-panel.active {
    display: flex;
}

.tool-panel h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 1rem;
}

.tool-panel h4:first-child {
    margin-top: 0;
}

.panel-hint {
    font-size: 0.75rem;
    color: var(--text-dark);
    line-height: 1.4;
    margin-top: -4px;
}

.input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.input-row label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.input-row input[type="number"] {
    width: 110px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.85rem;
}

.input-row input[type="color"] {
    width: 40px;
    height: 32px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
}

.checkbox-row input {
    accent-color: var(--primary);
    cursor: pointer;
}

.slider-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.slider-row label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.slider-row input[type="range"] {
    width: 100%;
    accent-color: var(--primary);
}

.btn-row {
    display: flex;
    gap: 8px;
}

.btn-row.wrap {
    flex-wrap: wrap;
}

.btn-row .btn-secondary,
.btn-row .btn-primary {
    flex: 1;
    padding: 8px 10px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.btn-row input[type="color"] {
    flex: 0 0 auto;
}

.full-width {
    width: 100%;
    justify-content: center;
}

.btn-icon-lg {
    flex: 1;
    height: 38px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-icon-lg:hover {
    background: #ffffff;
    color: var(--text-main);
}

.btn-icon-lg.danger:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-icon-lg i {
    width: 16px;
    height: 16px;
}

button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.object-properties {
    margin-top: 1rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Sidebar Download Actions */
.sidebar-download-card {
    margin-top: 1.25rem;
    padding: 12px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.18);
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-download-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Canvas Stage */
.editor-stage {
    min-height: 0;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    padding: 1.25rem;
    position: relative;
    background-color: var(--panel-bg);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
}

.stage-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    min-width: 0;
}

.stage-topbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.stage-topbar-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    flex-shrink: 0;
}

.download-btn-highlight {
    background: var(--primary-gradient) !important;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3) !important;
    font-weight: 700 !important;
    padding: 8px 14px !important;
}

.dimensions-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
}

.dimensions-badge i {
    width: 14px;
    height: 14px;
    color: var(--primary);
}

#current-size-text {
    color: var(--text-main);
    font-family: 'JetBrains Mono', monospace;
}

.canvas-stage-area {
    flex: 1;
    min-height: 460px;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(45deg, rgba(0,0,0,0.03) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(0,0,0,0.03) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.03) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.03) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
    padding: 1.5rem;
}

.canvas-empty-state {
    text-align: center;
    color: var(--text-dark);
    padding: 2.5rem 1rem;
}

.canvas-empty-state i {
    width: 44px;
    height: 44px;
    margin-bottom: 0.85rem;
    stroke-width: 1.5;
    color: var(--text-muted);
}

.canvas-empty-state h3 {
    color: var(--text-main);
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.canvas-empty-state p {
    font-size: 0.78rem;
    margin-bottom: 1.25rem;
    max-width: 300px;
}

.canvas-wrapper {
    padding: 10px;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: auto;
}

.canvas-wrapper .canvas-container {
    box-shadow: 0 12px 35px -5px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.08);
    border-radius: 8px;
}

.canvas-wrapper canvas {
    box-shadow: none;
    border-radius: 6px;
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    border-radius: 20px;
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary);
    animation: spinner 0.8s infinite linear;
}

.loading-overlay p {
    font-size: 0.85rem;
    color: #ffffff;
    max-width: 280px;
    text-align: center;
}

/* Responsive Media Queries */
@media (max-width: 960px) {
    .editor-workspace {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .editor-tools {
        order: 2;
        height: auto;
        padding: 1.25rem 1rem;
    }

    .editor-stage {
        order: 1;
        padding: 1.25rem 1rem;
    }

    .tool-panels {
        max-height: 300px;
    }

    .canvas-stage-area {
        min-height: 320px;
    }
}

@media (max-width: 640px) {
    .tool-tabs {
        grid-template-columns: repeat(4, 1fr);
        gap: 4px;
    }

    .tool-tab {
        padding: 6px 2px;
        font-size: 0.68rem;
    }

    .tool-tab span {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        max-width: 100%;
    }

    .stage-topbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .stage-topbar-left,
    .stage-topbar-right {
        justify-content: space-between;
        width: 100%;
    }

    .canvas-stage-area {
        min-height: 260px;
    }
}

