/* Shared panels */
.config-panel {
    flex: 0 0 380px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(238, 244, 255, 0.9));
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.preview-panel {
    flex: 1;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(234, 241, 255, 0.9));
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

/* Upload section */
.upload-section {
    text-align: center;
}

#fileInput {
    display: none;
}

.upload-btn {
    display: inline-block;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
    text-align: center;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.upload-btn:hover {
    filter: brightness(0.95);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* Crop matrix */
.matrix-section {
    background-color: var(--surface-2);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.matrix-section h3,
.export-section h3 {
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.preset-btn {
    padding: 0.75rem 1.5rem;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.preset-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.preset-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.custom-matrix {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.custom-matrix input {
    width: 60px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 0.875rem;
    transition: var(--transition);
    background-color: var(--card-bg);
}

.custom-matrix input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.custom-matrix button,
#applyMatrixBtn,
#calculateBtn {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.custom-matrix button:hover,
#applyMatrixBtn:hover,
#calculateBtn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Preview area */
.preview-section {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: var(--surface-2);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 2px dashed rgba(15, 23, 42, 0.12);
}

#previewCanvas {
    max-width: 100%;
    max-height: 560px;
    border-radius: var(--border-radius);
    cursor: crosshair;
    background-color: var(--card-bg);
    box-shadow: var(--shadow-md);
}

/* Export section */
.export-section {
    background-color: var(--surface-2);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.export-options {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.export-options > div {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.export-options label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
    min-width: 80px;
}

.export-options select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    flex: 1;
    font-size: 0.875rem;
    background-color: var(--card-bg);
    transition: var(--transition);
    min-width: 150px;
}

.export-options select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.size-calc {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

#calculateBtn {
    background-color: var(--accent-color);
    flex: 1;
}

#calculateBtn:hover {
    background-color: var(--primary-hover);
}

#sizeResult {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    width: 100%;
    text-align: center;
    margin-top: 0.5rem;
}

.export-btn {
    display: block;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.export-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Sticker tool */
.preview-area {
    width: 35%;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.module {
    background-color: var(--card-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.module h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.module-content {
    display: flex;
    flex-direction: column;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}

.image-item {
    position: relative;
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.image-item:hover {
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.image-item.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-checkbox {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    padding: 2px;
}

.image-checkbox input[type="checkbox"] {
    accent-color: var(--primary-color);
    cursor: pointer;
}

.canvas-preview {
    margin: 1rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.sticker-processor .canvas-preview {
    display: none;
}

#stickerCanvas,
#iconCanvas {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.select-btn {
    padding: 0.5rem 1rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    margin-top: 0.5rem;
}

.select-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.select-btn.active {
    background-color: var(--success-color);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.selection-controls {
    margin-top: 0.5rem;
}

.canvas-actions {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.canvas-action-btn {
    padding: 0.5rem 1rem;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    font-size: 0.875rem;
}

.canvas-action-btn:hover {
    background-color: #475569;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.canvas-action-btn:active {
    transform: translateY(0);
}

.module.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.banner-canvas-container {
    overflow-x: auto;
    justify-content: flex-start;
}

#bannerCanvas {
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: grab;
}

#bannerCanvas:active {
    cursor: grabbing;
}

.bg-presets {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
    flex-wrap: wrap;
}

.bg-preset {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: var(--transition);
}

.bg-preset:hover {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.bg-preset.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.module-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.module-actions button {
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.module-actions button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.export-all {
    margin-top: 1rem;
    text-align: center;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

#exportAllBtn {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.125rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

#exportAllBtn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* GIF compress shared styles */
.gif-compress-container .preview-section {
    flex: 1;
    background-color: var(--card-bg);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    min-height: 300px;
}

.gif-compress-container .preview-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.preview-box {
    width: 100%;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    border: 2px dashed var(--border-color);
    overflow: hidden;
}

.preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.preview-box .placeholder {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.image-info {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
}

.image-info p {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.image-info .success {
    color: var(--success-color);
    font-weight: 600;
}

.image-info .warning {
    color: var(--warning-color);
    font-weight: 600;
}

.file-info {
    margin-top: 1rem;
    padding: 1rem;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    text-align: left;
}

.file-info p {
    margin: 0.5rem 0;
    color: var(--text-secondary);
}

.file-info strong {
    color: var(--text-primary);
}

.compress-settings {
    background-color: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.compress-settings h3 {
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.setting-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.setting-item label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.setting-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.target-size {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1rem;
}

.status-text {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-primary,
.btn-secondary {
    padding: 1rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    font-size: 1rem;
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    filter: brightness(0.95);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-secondary {
    background-color: var(--accent-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.progress-section {
    background-color: var(--bg-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.progress-section h3 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.125rem;
    font-weight: 600;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Component-level responsive tweaks */
@media (max-width: 1200px) {
    .config-panel {
        flex: 0 0 350px;
        padding: 1.5rem;
    }

    .preview-panel {
        padding: 1.5rem;
    }

    .preview-area {
        width: 40%;
    }
}

@media (max-width: 1024px) {
    .config-panel {
        flex: 1;
        max-width: 100%;
    }

    .preview-panel {
        min-height: 500px;
    }

    .presets {
        grid-template-columns: repeat(3, 1fr);
    }

    .preview-area {
        width: 100%;
        order: -1;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    .config-panel,
    .preview-panel {
        padding: 1.25rem;
    }

    .presets {
        grid-template-columns: repeat(2, 1fr);
    }

    .export-options > div {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .export-options label {
        min-width: auto;
    }

    .size-calc {
        flex-direction: column;
        align-items: stretch;
    }

    .module {
        padding: 1.25rem;
    }

    .module-actions {
        flex-direction: column;
    }

    .module-actions button {
        width: 100%;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .setting-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .preview-box {
        height: 250px;
    }
}
