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

svg {
    fill: none !important;
    width: auto;
    height: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #fff;
    color: #333;
    overflow-x: hidden;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.loading-screen.active {
    opacity: 1;
    pointer-events: all;
}

.loading-bar-container {
    width: 300px;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.loading-bar {
    position: absolute;
    height: 100%;
    background: #ff6154;
    border-radius: 2px;
    width: 40%;
    will-change: transform;
    animation: loading 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes loading {
    0% {
        transform: translateX(-100%);
    }
    50% {
        transform: translateX(200%);
    }
    100% {
        transform: translateX(500%);
    }
}

.loading-text {
    font-size: 15px;
    color: #666;
    font-weight: 500;
}

.container {
    max-width: 1100px;
    height: calc(100vh - 81px);
    align-content: center;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Step Content */
.step-content {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.step-panel {
    display: none;
    width: 100%;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.step-panel.active {
    display: block;
}

.step-panel.show {
    opacity: 1;
    transform: translateY(0);
}

.step-title {
    font-size: 18px;
    font-weight: bold;
    margin-top: 10px;
}

.step-description {
    font-size: 12.5px;
    color: #999;
    margin-bottom: 40px !important;
}

/* Step 1: Import */
.upload-area {
    max-width: 400px;
    margin: 40px auto;
}

.file-input-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 16px 48px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    background: #e5554a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 97, 84, 0.4);
}

.upload-content {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.upload-icon {
    position: absolute;
    width: 24px;
    height: 24px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin: 0;
    transition: opacity 0.3s ease;
}

.file-input-label:hover .upload-icon {
    opacity: 1;
}

.file-input-label:hover .upload-text {
    opacity: 0;
    visibility: hidden;
}

.file-input {
    display: none;
}

/* Step 2: Selection Panel - Grid Layout */
.selection-panel {
    max-width: 900px;
    margin: 0 auto;
    text-align: left;
}

.selection-content {
    display: grid;
    grid-template-columns: 450px 1fr;
    gap: 40px;
    align-items: start;
}

/* Left side - File Preview */
.files-preview-section {
    /* Left column */
}

.file-preview-large {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    transition: all 0.3s ease;
}

.file-preview-large:hover {
    border-color: #ff6154;
    box-shadow: 0 8px 24px rgba(255, 97, 84, 0.12);
}

.file-preview-thumbnail {
    width: 100%;
    max-width: 200px;
    background: #f8f9fa;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.file-preview-thumbnail canvas {
    max-width: 100%;
    max-height: 260px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
}

.file-preview-details {
    width: 100%;
}

.file-preview-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
    word-break: break-word;
    line-height: 1.4;
    margin-bottom: 4px;
}

.file-preview-size {
    font-size: 0.95rem;
    color: #6b7280;
    font-weight: 500;
}

.file-change-btn {
    background: transparent;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.file-change-btn:hover {
    border-color: #ff6154;
    color: #ff6154;
    background: #fff5f4;
}

/* Right side - Controls Panel */
.controls-panel {
    background: white;
    border: none;
    border-radius: 16px;
    padding: 32px;
    box-shadow: none;
    align-self: center;
}

.control-section {
    margin-bottom: 28px;
}

.control-section:last-child {
    margin-bottom: 0;
}

.control-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 16px;
}

.controls-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 28px 0;
}

/* Custom Dropdown Styles */
.custom-dropdown {
    position: relative;
    width: 100%;
}

.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-dropdown-trigger:hover {
    border-color: #ffc9c3;
    background: #fff5f4;
}

.custom-dropdown.open .custom-dropdown-trigger {
    border-color: #ff6154;
    background: #fff5f4;
}

.dropdown-selected {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-selected-text {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
}

.dropdown-arrow {
    width: 20px;
    height: 20px;
    stroke: #6b7280;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 100;
    display: none;
    max-height: 280px;
    overflow: hidden;
}

.custom-dropdown.open .custom-dropdown-menu {
    display: block;
    overflow-y: auto;
}

.dropdown-option {
    padding: 14px 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

.dropdown-option:last-child {
    border-bottom: none;
}

.dropdown-option:hover {
    background: #fff5f4;
}

.dropdown-option.selected {
    background: #fff5f4;
}

.dropdown-option.selected .dropdown-option-name {
    color: #ff6154;
    font-weight: 600;
}

.dropdown-option-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dropdown-option-name {
    font-size: 0.95rem;
    font-weight: 500;
    color: #1f2937;
}

/* Custom Dropdown Scrollbar */
.custom-dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.custom-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
    border: 2px solid white;
}

.custom-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* OCR Button */
.extract-actions-vertical {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-extract {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 20px 24px;
    background: #ff6154;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
}

.btn-extract:hover {
    background: #e5554a;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 97, 84, 0.3);
}

/* Spinner - hidden by default, shown on loading */
.btn-spinner {
    width: 0;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.2s ease, width 0.2s ease, margin 0.2s ease;
    margin-right: -16px;
}

.btn-extract.btn-loading .btn-spinner {
    width: 24px;
    opacity: 1;
    margin-right: 0;
    animation: spinner 0.6s linear infinite;
}

/* Arrow icon on the right */
.btn-arrow {
    width: 24px;
    height: 24px;
    stroke: white;
    flex-shrink: 0;
    margin-left: auto;
    transition: transform 0.2s ease;
}

.btn-extract:hover .btn-arrow {
    transform: translateX(4px);
}

.btn-extract.btn-loading .btn-arrow {
    display: none;
}

.btn-extract-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.btn-extract-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}

.btn-extract-desc {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.8);
}

.btn-extract.btn-loading {
    pointer-events: none;
    opacity: 0.8;
}

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

/* Step 3: Download */
.download-container {
    max-width: 480px;
    margin: 0 auto;
}

/* File Result Card */
.file-result-card {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.file-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #fff5f491 0%, #ffe5e273 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-icon svg {
    width: 32px;
    height: 32px;
    stroke: #ff6154;
}

.file-details {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.file-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    font-size: 14px;
    color: #6b7280;
}

.status-badge {
    background: #10b981;
    color: white;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.status-badge svg {
    width: 18px;
    height: 18px;
    stroke: white;
}

/* Download Actions */
.download-btn-group {
    margin-bottom: 16px;
}

.btn-download-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    background: #ff6154;
    color: white;
    border: none;
    border-radius: 14px;
    padding: 18px 32px;
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    box-shadow: 0 4px 16px rgba(255, 97, 84, 0.25);
}

.btn-download-primary:hover {
    background: #e5554a;
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 97, 84, 0.35);
}

.btn-download-primary svg {
    width: 22px;
    height: 22px;
    stroke: white;
}

/* Secondary Actions */
.secondary-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
    margin-bottom: 14px;
}

.secondary-action-btn {
    flex: 1;
    background: #f9fafb;
    border: none;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #6b7280;
}

.secondary-action-btn:hover {
    background: #fff5f4;
    border-color: #ff6154;
    color: #ff6154;
}

.secondary-action-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

/* OCR Another Button */
.btn-ocr-another {
    background: transparent;
    color: #ff6154;
    border: 2px solid #ff6154;
    border-radius: 12px;
    padding: 16px 32px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-ocr-another:hover {
    background: #fff5f4;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 97, 84, 0.1);
}

.btn-ocr-another .arrow-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    opacity: 0;
    transform: translateX(-8px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-ocr-another:hover .arrow-icon {
    opacity: 1;
    transform: translateX(0);
}

.btn-ocr-another:hover span {
    transform: translateX(-4px);
}

.btn-ocr-another span {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.error-message {
    color: #d93025;
    background: #fce8e6;
    border-radius: 12px;
    padding: 16px;
    margin: 20px auto;
    display: none;
    max-width: 400px;
}

/* Responsive */
@media (max-width: 768px) {
    .selection-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .file-preview-large {
        padding: 24px;
    }

    .controls-panel {
        padding: 24px;
    }

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