/* ============================================================================
   SharpWebP ImageEditor Styles
   All classes prefixed with ie- to avoid conflicts with existing app CSS.
   ============================================================================ */

/* --- Layout --- */
.ie-editor {
    max-width: 1200px;
    margin: 0 auto;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #333;
}

.ie-hidden {
    display: none !important;
}

/* --- Upload Zone --- */
.ie-upload-zone {
    border: 2px dashed #ccc;
    border-radius: 16px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    margin: 20px 0;
}

.ie-upload-zone:hover,
.ie-upload-zone.ie-dragover {
    border-color: #00D68F;
    background: rgba(0, 214, 143, 0.04);
}

.ie-upload-icon {
    color: #999;
    margin-bottom: 16px;
    transition: color 0.3s ease;
}

.ie-upload-zone:hover .ie-upload-icon,
.ie-upload-zone.ie-dragover .ie-upload-icon {
    color: #00D68F;
}

.ie-upload-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    margin: 0 0 8px;
}

.ie-upload-hint {
    font-size: 0.875rem;
    color: #888;
    margin: 0;
}

.ie-file-input {
    display: none;
}

/* --- Workspace --- */
.ie-workspace {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin: 20px 0;
}

/* --- Sidebar (Tool Panels) --- */
.ie-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ie-panel {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    overflow: hidden;
}

.ie-panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.ie-panel-header:hover {
    background: #f5f5f5;
}

.ie-panel-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.ie-panel-label {
    flex: 1;
}

.ie-panel-toggle {
    color: #999;
    font-size: 0.8rem;
}

.ie-panel-body {
    padding: 12px 16px 16px;
    border-top: 1px solid #f0f0f0;
}

/* --- Preview Area --- */
.ie-preview {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.ie-canvas {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    background: repeating-conic-gradient(#f0f0f0 0% 25%, #fff 0% 50%) 50% / 20px 20px;
}

.ie-info-bar {
    font-size: 0.8rem;
    color: #888;
    text-align: center;
}

/* --- Form Elements --- */
.ie-field-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ie-field-row label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    color: #555;
}

.ie-input {
    width: 80px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    text-align: center;
    transition: border-color 0.2s;
}

.ie-input:focus {
    outline: none;
    border-color: #00D68F;
    box-shadow: 0 0 0 2px rgba(0, 214, 143, 0.15);
}

/* --- Buttons --- */
.ie-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.ie-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.ie-btn-primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 10px;
}

.ie-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.ie-btn-secondary {
    background: transparent;
    color: #666;
    border-color: #ddd;
}

.ie-btn-secondary:hover {
    background: #f5f5f5;
}

.ie-btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.ie-btn-sm:hover,
.ie-btn-sm.active {
    background: #00D68F;
    color: #fff;
    border-color: #00D68F;
}

.ie-btn-icon {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

.ie-btn-icon.active {
    background: rgba(0, 214, 143, 0.1);
    border-color: #00D68F;
}

/* --- Presets --- */
.ie-presets {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.ie-presets-label {
    font-size: 0.8rem;
    color: #888;
    font-weight: 500;
}

/* --- Resize Info --- */
.ie-resize-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.8rem;
    color: #666;
    padding: 8px 0;
}

/* --- Crop Fields --- */
.ie-crop-fields {
    gap: 6px;
}

.ie-crop-fields .ie-input {
    width: 60px;
}

/* --- Rotate Buttons --- */
.ie-rotate-buttons {
    gap: 6px;
}

.ie-rotate-buttons .ie-btn {
    flex: 1;
    text-align: center;
    font-size: 0.8rem;
    padding: 6px 8px;
}

.ie-rotate-buttons .ie-btn.active {
    background: rgba(0, 214, 143, 0.1);
    border-color: #00D68F;
    color: #00D68F;
}

/* --- Scale Slider --- */
.ie-resize-scale {
    width: 120px;
    accent-color: #00D68F;
}

.ie-resize-scale-label {
    font-size: 0.8rem;
    color: #666;
    min-width: 36px;
}

/* --- Rotate Slider --- */
.ie-rotate-slider {
    width: 140px;
    accent-color: #00D68F;
}

.ie-rotate-angle {
    font-size: 0.85rem;
    color: #666;
    min-width: 30px;
}

/* --- DPI Info --- */
.ie-dpi-info {
    font-size: 0.8rem;
    color: #666;
    padding: 6px 0;
}

/* --- Format Selector --- */
.ie-action-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
}

.ie-formats {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.ie-formats-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #555;
}

.ie-format-option {
    cursor: pointer;
}

.ie-format-option input[type="radio"] {
    display: none;
}

.ie-format-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    border: 2px solid #e8e8e8;
    border-radius: 10px;
    transition: all 0.2s;
    gap: 2px;
}

.ie-format-card strong {
    font-size: 0.95rem;
}

.ie-format-card small {
    font-size: 0.75rem;
    color: #888;
}

.ie-format-option input[type="radio"]:checked + .ie-format-card {
    border-color: #00D68F;
    background: rgba(0, 214, 143, 0.05);
    box-shadow: 0 0 0 2px rgba(0, 214, 143, 0.2);
}

/* --- Action Bar --- */
.ie-action-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: center;
}

.ie-convert-btn {
    min-width: 200px;
}

/* --- Progress --- */
.ie-progress {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ie-progress-bar {
    width: 200px;
    height: 6px;
    background: #e8e8e8;
    border-radius: 3px;
    overflow: hidden;
}

.ie-progress-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00D68F, #667eea);
    border-radius: 3px;
    animation: ie-progress-anim 2s ease-in-out infinite;
}

@keyframes ie-progress-anim {
    0% { width: 0%; }
    50% { width: 80%; }
    100% { width: 100%; }
}

.ie-progress-text {
    font-size: 0.85rem;
    color: #666;
}

/* --- Result Card --- */
.ie-result {
    margin: 20px 0;
}

.ie-result-card {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 16px;
    padding: 32px;
    text-align: center;
}

.ie-result-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.ie-result-header h3 {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

.ie-result-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 24px;
}

.ie-metric {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    background: #f8f8f8;
    border-radius: 8px;
    min-width: 100px;
}

.ie-metric strong {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ie-metric span {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
}

.ie-result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.ie-download-btn {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* --- Error Toast --- */
.ie-error-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4444;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    animation: ie-toast-in 0.3s ease;
}

@keyframes ie-toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.ie-error-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* --- Navigation --- */
.ie-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.ie-logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: #333;
    text-decoration: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ie-breadcrumb {
    font-size: 0.85rem;
    color: #888;
    flex: 1;
}

.ie-breadcrumb a {
    color: #667eea;
    text-decoration: none;
}

.ie-breadcrumb a:hover {
    text-decoration: underline;
}

/* --- How-To Section --- */
.ie-howto {
    margin: 48px 0;
}

.ie-howto h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 32px;
    color: #333;
}

.ie-steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.ie-step {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.ie-step-num {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.ie-step h3 {
    font-size: 1.1rem;
    margin: 0 0 8px;
    color: #333;
}

.ie-step p {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* --- FAQ Section --- */
.ie-faq {
    margin: 48px 0;
}

.ie-faq h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: #333;
}

.ie-faq-item {
    border: 1px solid #e8e8e8;
    border-radius: 10px;
    margin-bottom: 8px;
    overflow: hidden;
}

.ie-faq-item summary {
    padding: 16px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ie-faq-item summary::after {
    content: '+';
    font-size: 1.2rem;
    color: #999;
    transition: transform 0.2s;
}

.ie-faq-item[open] summary::after {
    content: '\2212';
}

.ie-faq-item summary::-webkit-details-marker {
    display: none;
}

.ie-faq-item p {
    padding: 0 20px 16px;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.6;
    margin: 0;
}

/* --- Related Tools --- */
.ie-related {
    margin: 48px 0;
}

.ie-related h2 {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 24px;
    color: #333;
}

.ie-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.ie-related-card {
    display: block;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    padding: 20px;
    text-decoration: none;
    transition: all 0.2s;
}

.ie-related-card:hover {
    border-color: #00D68F;
    box-shadow: 0 4px 15px rgba(0, 214, 143, 0.1);
    transform: translateY(-2px);
}

.ie-related-card strong {
    display: block;
    font-size: 1rem;
    color: #333;
    margin-bottom: 4px;
}

.ie-related-card p {
    font-size: 0.85rem;
    color: #888;
    margin: 0;
}

/* --- Footer --- */
.ie-footer {
    padding: 24px 0;
    border-top: 1px solid #e8e8e8;
    margin-top: 48px;
}

.ie-footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.ie-footer p {
    font-size: 0.85rem;
    color: #888;
    margin: 0;
}

.ie-footer nav {
    display: flex;
    gap: 16px;
}

.ie-footer nav a {
    font-size: 0.85rem;
    color: #888;
    text-decoration: none;
}

.ie-footer nav a:hover {
    color: #667eea;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .ie-workspace {
        flex-direction: column;
    }

    .ie-sidebar {
        width: 100%;
    }

    .ie-preview {
        min-width: auto;
    }

    .ie-upload-zone {
        padding: 40px 16px;
    }

    .ie-result-card {
        padding: 20px;
    }

    .ie-nav {
        padding: 12px 16px;
    }

    .ie-steps {
        grid-template-columns: 1fr;
    }

    .ie-related-grid {
        grid-template-columns: 1fr 1fr;
    }

    .ie-formats {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .ie-related-grid {
        grid-template-columns: 1fr;
    }

    .ie-field-row {
        flex-direction: column;
        align-items: stretch;
    }

    .ie-rotate-buttons {
        flex-direction: row;
    }
}
