:root {
    --mv-purple: #8B5CF6;
    --mv-purple-dark: #7C3AED;
    --mv-purple-light: #A78BFA;
    --mv-purple-glow: rgba(139, 92, 246, 0.3);
    --mv-purple-subtle: rgba(139, 92, 246, 0.08);
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #F3F4F6;
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    --border-color: #E5E7EB;
    --success: #10B981;
    --error: #EF4444;
    --warning: #F59E0B;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 20%, var(--mv-purple-glow) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--mv-purple) 0%, var(--mv-purple-dark) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--mv-purple-glow);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0.25rem 0 0 0;
}


.badge {
    display: inline-flex;
    align-items: center;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
}

/* Upload Section */
.upload-section {
    max-width: 600px;
    margin: 0 auto 3rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Banners Section */
.banners-section {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

/* Panel */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.panel-header {
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.panel-body {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

/* Form Group */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    outline: none;
    border-color: var(--mv-purple);
    box-shadow: 0 0 0 3px var(--mv-purple-subtle);
}

textarea.form-input {
    resize: vertical;
    line-height: 1.5;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-primary);
}

.upload-area:hover,
.upload-area.dragging {
    border-color: var(--mv-purple-light);
    background: var(--mv-purple-subtle);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.upload-icon {
    width: 48px;
    height: 48px;
    stroke: var(--mv-purple);
    margin-bottom: 0.5rem;
}

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

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Image Preview */
.image-preview {
    margin-top: 1rem;
    position: relative;
}

.preview-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.image-preview img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
}

.btn-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 36px;
    height: 36px;
    background: var(--error);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background 0.2s;
}

.btn-close:hover {
    background: #dc2626;
}

/* Checkbox Group */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--mv-purple);
}

.checkbox-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Button Group */
.button-group {
    display: flex;
    gap: 1rem;
}

.button-group .btn {
    flex: 1;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--mv-purple) 0%, var(--mv-purple-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px var(--mv-purple-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--mv-purple-glow);
}

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

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

.btn-success:hover {
    background: #059669;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    width: 100%;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    width: 100%;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 0.5rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Logs Section */
.logs-section {
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.logs-box {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    height: 280px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
}

.log-entry {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    last-child: none;
}

.log-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.log-info {
    color: var(--mv-purple);
}

.log-entry.log-success {
    color: var(--success);
}

.log-entry.log-error {
    color: var(--error);
}

.log-entry.log-warning {
    color: var(--warning);
}

/* Results Section */
.results-section {
    margin-top: 2rem;
}

.result-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.result-header h4 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.result-lang-code {
    font-size: 0.875rem;
    font-weight: 700;
    background: var(--mv-purple-subtle);
    color: var(--mv-purple);
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
}

.result-body {
    padding: 1.5rem;
}

.result-row {
    margin-bottom: 1.25rem;
}

.result-row:last-child:not(.result-image) {
    margin-bottom: 0;
}

.result-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.result-value {
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-style: italic;
    margin: 0;
}

.score-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--mv-purple) 0%, var(--mv-purple-dark) 100%);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.95rem;
    min-width: 80px;
    text-align: center;
    line-height: 1.4;
}

.result-image {
    margin: 1.25rem 0;
}

.result-image img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: block;
}

/* Banner Card - Horizontal Layout */
.banner-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.3s, transform 0.3s;
}

.banner-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.banner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--mv-purple-subtle) 0%, rgba(139, 92, 246, 0.05) 100%);
}

.banner-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.lang-badge {
    font-size: 0.75rem;
    font-weight: 800;
    background: var(--mv-purple);
    color: white;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    letter-spacing: 0.5px;
}

.banner-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

.banner-image-wrapper {
    background: var(--bg-primary);
    overflow: hidden;
    position: relative;
    min-height: 280px;
    border-right: 1px solid var(--border-color);
}

.banner-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.banner-info {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.banner-row {
    margin-bottom: 1rem;
}

.banner-row:last-child {
    margin-bottom: 0;
}

.banner-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.banner-text {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
    line-height: 1.4;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 768px) {
    .banner-content {
        grid-template-columns: 1fr;
    }

    .banner-image-wrapper {
        min-height: 160px;
    }
}

/* Edit Section (Step 2) */
.edit-section {
    max-width: 600px;
    margin: 0 auto 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.edit-section-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.edit-section-header h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 0.25rem 0;
}

.edit-section-header p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.edit-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.edit-card-original {
    background: var(--bg-tertiary);
}

.edit-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, var(--mv-purple-subtle) 0%, rgba(139, 92, 246, 0.03) 100%);
}

.edit-card-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.lang-badge-muted {
    background: var(--text-muted);
}

.edit-card-body {
    padding: 1.25rem;
}

.original-text-display {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.translation-textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.translation-textarea::placeholder {
    color: var(--text-muted);
}

.translation-textarea:focus {
    outline: none;
    border-color: var(--mv-purple);
    box-shadow: 0 0 0 3px var(--mv-purple-subtle);
}

/* Size Selection */
.size-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 0.75rem 0;
}

.size-count-badge {
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--mv-purple-subtle);
    color: var(--mv-purple);
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
}

.size-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
}

.size-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: var(--bg-primary);
}

.size-option:hover {
    border-color: var(--mv-purple-light);
    background: var(--mv-purple-subtle);
}

.size-option.selected {
    border-color: var(--mv-purple);
    background: var(--mv-purple-subtle);
}

.size-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.size-checkbox svg {
    width: 12px;
    height: 12px;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.size-option.selected .size-checkbox {
    background: var(--mv-purple);
    border-color: var(--mv-purple);
}

.size-option.selected .size-checkbox svg {
    opacity: 1;
}

.size-label {
    flex: 1;
    min-width: 0;
}

.size-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.size-dimensions {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.size-preview-box {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.size-preview-inner {
    border: 1.5px solid var(--border-color);
    border-radius: 2px;
    background: var(--bg-secondary);
    transition: border-color 0.15s ease;
}

.size-option.selected .size-preview-inner {
    border-color: var(--mv-purple-light);
}

/* Dynamic Results */
.results-dynamic {
    max-width: 1400px;
    margin: 0 auto;
}

.lang-results-group {
    margin-bottom: 2rem;
}

.lang-results-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.lang-results-header h3 {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.size-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.25rem;
}

.size-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.3s, transform 0.3s;
}

.size-result-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.size-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.size-result-header .size-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.size-result-header .size-dimensions {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.size-result-image {
    position: relative;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.size-result-image img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.size-result-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

@media (max-width: 600px) {
    .size-grid {
        grid-template-columns: 1fr;
    }
    .size-results-grid {
        grid-template-columns: 1fr;
    }
}

/* Footer */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer p {
    margin: 0.5rem 0;
}

/* Scrollbar */
.logs-box::-webkit-scrollbar {
    width: 6px;
}

.logs-box::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 3px;
}

.logs-box::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.logs-box::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Error State */
.result-card.error-state {
    background: #FEF2F2;
    border: 1px solid #FECACA;
}

.error-content {
    padding: 2rem 1.5rem;
    text-align: center;
}

.error-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.error-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--error);
    margin-bottom: 0.5rem;
}

.error-message {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.error-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
}

/* Responsive */
@media (max-width: 1024px) {
    .header-inner {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-badges {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .header {
        padding: 1.5rem;
    }

    .header h1 {
        font-size: 1.25rem;
    }

    .header p {
        font-size: 0.8rem;
    }

    .main-content {
        padding: 1rem;
    }

    .content-wrapper {
        gap: 1rem;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .btn {
        width: 100%;
    }

    .logs-box {
        height: 200px;
    }
}