/* General Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    padding-top: 100px; /* 为固定按钮留出空间 */
    color: #333;
    line-height: 1.6;
    position: relative;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1em;
    opacity: 0.9;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 320px 1fr; /* Sidebar fixed width, content flexible */
    gap: 0;
    min-height: 600px;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1024px) {
    body {
        padding-top: 90px; /* 移动端为固定按钮留出空间 */
    }
    
    .main-content {
        grid-template-columns: 1fr; /* Stack sidebar and content */
    }
    .sidebar {
        border-right: none;
        border-bottom: 2px solid #e1e8ed;
        max-height: unset; /* Allow sidebar to expand */
        position: static; /* Remove sticky position on smaller screens */
    }
    .content-area {
        padding: 20px; /* Reduce padding */
    }
}

@media (max-width: 768px) {
    .preview-container {
        grid-template-columns: 1fr; /* Stack preview boxes */
    }
    header h1 {
        font-size: 2em;
    }
    header p {
        font-size: 1em;
    }
    .container {
        border-radius: 0; /* No border-radius on very small screens */
        box-shadow: none;
    }
    body {
        padding: 0; /* No padding on body */
    }
}

/* Sidebar */
.sidebar {
    background: #f7f9fc;
    border-right: 2px solid #e1e8ed;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 180px); /* Adjust based on header height, for sticky behavior */
    position: sticky;
    top: 0;
    align-self: start; /* Ensures sticky behavior starts from the top of its grid area */
}

/* Content Area */
.content-area {
    padding: 30px;
}

/* Upload Zone */
.upload-zone {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    background: #f7f9fc;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 250px;
}

.upload-zone:hover {
    background: #eef2ff;
    border-color: #764ba2;
}

.upload-zone.dragover {
    background: #e0e7ff;
    border-color: #4c1d95;
}

.upload-icon {
    font-size: 4em;
    margin-bottom: 15px;
    color: #667eea;
}

.upload-zone h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.5em;
}

.upload-zone p {
    color: #666;
    font-size: 1.1em;
}

.hidden {
    display: none !important;
}

/* Preview Container */
.preview-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.preview-box {
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    padding: 20px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
}

.preview-box h3 {
    color: #333;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.3em;
}

.preview-box .size-badge {
    font-size: 0.85em;
    padding: 5px 12px;
    background: #667eea;
    color: white;
    border-radius: 20px;
    font-weight: 600;
}

.preview-box .size-badge.optimized {
    background: #10b981;
}

.svg-preview {
    width: 100%;
    min-height: 250px;
    height: 100%; /* Ensure it fills parent height */
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* Prevent SVG content from overflowing this box */
    margin-bottom: 15px;
    flex-grow: 1; /* Allow preview to grow */
}

/* For image-based SVG preview */
.svg-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Ensures the entire image is visible within the container */
}

/* Statistics Section */
.stats {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 2px solid #e1e8ed;
}

.stats h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.4em;
    border-bottom: 1px solid #e1e8ed;
    padding-bottom: 10px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 1.1em;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    color: #666;
}

.stat-value {
    color: #333;
    font-weight: 600;
}

.stat-value.positive {
    color: #10b981;
}

/* Options Sidebar Sections */
.options-section {
    margin-bottom: 25px;
    border-bottom: 1px dashed #e1e8ed;
    padding-bottom: 20px;
}

.options-section:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.options-section h3 {
    color: #333;
    margin-bottom: 12px;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
}

.option-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    background: white;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #f0f0f0;
}

.option-item:hover {
    background: #eef2ff;
    border-color: #c9d7ff;
}

.option-item label {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex: 1;
    font-size: 0.95em;
    color: #333;
}

.option-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
    transition: background-color 0.2s, border-color 0.2s;
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

.option-item input[type="checkbox"]:checked {
    background-color: #667eea;
    border-color: #667eea;
}

.option-item input[type="checkbox"]:checked::before {
    content: '✓';
    display: block;
    color: white;
    font-size: 14px;
    line-height: 16px;
    text-align: center;
}

.option-item input[type="number"] {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid #e1e8ed;
    border-radius: 6px;
    font-size: 0.9em;
    text-align: center;
    transition: border-color 0.2s;
}

.option-item input[type="number"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.precision-option {
    background: #f0f4ff;
    border-color: #c9d7ff;
    font-weight: 500;
}
.precision-option label {
    color: #444;
}

/* Action Buttons */
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    margin-right: 10px;
    margin-top: 10px;
}

.action-btn:last-child {
    margin-right: 0;
}

.primary-btn {
    background: #667eea;
    color: white;
}

.primary-btn:hover {
    background: #5a6edb;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.secondary-btn {
    background: #e1e8ed;
    color: #333;
}

.secondary-btn:hover {
    background: #d4dde5;
    box-shadow: 0 4px 15px rgba(170, 180, 190, 0.3);
}

.reset-btn {
    background: #fca5a5;
    color: #7f1d1d;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: block;
    width: 100%;
    margin-top: 20px;
}

.reset-btn:hover {
    background: #ef4444;
    color: white;
}

.action-buttons {
    margin-top: 30px;
    text-align: center;
}

/* Notification Pop-up */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease, bottom 0.3s ease;
    z-index: 1000;
    font-size: 0.95em;
    pointer-events: none; /* Allow clicks to pass through */
}

.notification.show {
    opacity: 1;
    bottom: 30px;
}

/* Code Editor Styles */
.code-editor-container {
    margin-top: 20px;
    background: #282c34;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid #e1e8ed;
}

.code-tabs {
    display: flex;
    border-bottom: 1px solid #444;
}

.code-tab {
    background: #3c4048;
    color: #ccc;
    padding: 10px 20px;
    border: none;
    border-right: 1px solid #444;
    cursor: pointer;
    font-size: 0.95em;
    transition: background-color 0.2s, color 0.2s;
    flex-grow: 1; /* Distribute tabs evenly */
    text-align: center;
}

.code-tab:last-child {
    border-right: none;
}

.code-tab.active {
    background: #282c34;
    color: #fff;
    font-weight: 600;
}

.code-editor-wrapper {
    position: relative;
    height: 400px; /* Fixed height for code editors */
}

.code-editor {
    width: 100%;
    height: 100%;
    border: none;
    background: #282c34;
    color: #f8f8f2;
    padding: 20px;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    font-size: 0.9em;
    line-height: 1.5;
    resize: none;
    overflow: auto;
    white-space: pre;
    box-sizing: border-box;
    position: absolute; /* Stack textareas */
    top: 0;
    left: 0;
}