:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --text-main: #0f172a;
    --text-light: #64748b;
    --border: #e2e8f0;
    --dashed-border: #cbd5e1;
    --link: #2563eb;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 25px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    padding: 1.5rem 1rem;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle premium background effects */
.background-effects {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.5;
}

.glow-1 {
    top: -150px;
    left: -150px;
    width: 500px;
    height: 500px;
    background: #dbeafe;
}

.glow-2 {
    bottom: -150px;
    right: -150px;
    width: 600px;
    height: 600px;
    background: #f3e8ff;
}

.container {
    width: 100%;
    max-width: 800px;
    background: var(--bg-surface);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
}

@media (max-width: 640px) {
    .container {
        padding: 1.5rem;
        border-radius: var(--radius-md);
    }
}

/* Header */
.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
    color: #1e293b;
    line-height: 1.2;
}

@media (max-width: 640px) {
    .header h1 {
        font-size: 1.5rem;
    }
}

.header p {
    margin-bottom: 0.75rem;
    color: var(--text-light);
    font-size: 1.05rem;
}

.header a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.2);
    text-underline-offset: 4px;
    transition: var(--transition);
}

.header a:hover {
    text-decoration-color: var(--link);
}

/* Controls */
.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 2rem 0;
    background: #f8fafc;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.language-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1 1 auto;
}

.language-selector label {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
}

.select-wrapper {
    position: relative;
    flex: 1 1 auto;
    min-width: 150px;
}

select {
    width: 100%;
    appearance: none;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

select:hover, select:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.select-wrapper i {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-light);
}

.secondary-btn {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.2rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.secondary-btn:active {
    transform: translateY(1px);
}

.secondary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

@media (max-width: 500px) {
    .controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .secondary-btn {
        justify-content: center;
    }
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--dashed-border);
    border-radius: var(--radius-md);
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: #f8fafc;
    position: relative;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary);
    background: #eff6ff;
}

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

.upload-icon {
    font-size: 2.5rem;
    color: var(--primary);
    opacity: 0.8;
}

.upload-content h3 {
    font-weight: 500;
    font-size: 1.15rem;
    color: var(--text-main);
    max-width: 400px;
    line-height: 1.5;
}

@media (max-width: 640px) {
    .upload-area {
        padding: 2rem 1rem;
        min-height: 180px;
    }
    .upload-content h3 {
        font-size: 1rem;
    }
}

/* Processing UI */
.processing-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    width: 100%;
}

.spinner {
    font-size: 3rem;
    color: var(--primary);
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.progress-info {
    width: 100%;
    max-width: 350px;
}

.progress-info p {
    margin-bottom: 0.75rem;
    font-weight: 500;
    color: var(--primary);
    font-size: 0.95rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    transition: width 0.3s ease;
}

/* Result Area */
.result-area {
    margin-bottom: 2rem;
    animation: fadeIn 0.4s ease;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

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

.document-preview {
    background: #f1f5f9;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    max-height: 600px;
    overflow-y: auto;
}

.document-preview img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.text-output-section {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.result-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1e293b;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
}

.icon-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.icon-btn i {
    font-size: 1.1rem;
}

@media (max-width: 400px) {
    .actions {
        width: 100%;
    }
    .icon-btn {
        flex: 1;
        justify-content: center;
    }
}

textarea {
    width: 100%;
    min-height: 400px;
    flex: 1;
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: 'Inter', inherit;
    font-size: 0.95rem;
    line-height: 1.7;
    resize: vertical;
    background: #f8fafc;
    color: var(--text-main);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
    transition: var(--transition);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Footer */
.footer {
    border-top: 1px solid var(--border);
    padding-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer a {
    color: var(--link);
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.3);
    transition: var(--transition);
}

.footer a:hover {
    text-decoration-color: var(--link);
}

.bottom-links {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}

.bottom-links .date {
    margin-left: auto;
    font-size: 0.85rem;
    color: #94a3b8;
}

@media (max-width: 500px) {
    .bottom-links {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .bottom-links .date {
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

.hidden {
    display: none !important;
}
