:root {
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.app-header {
    text-align: center;
    margin-bottom: 8px;
}

.app-header .logo {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.app-header .logo span {
    font-size: 1rem;
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 6px;
    vertical-align: middle;
}

.app-header .subtitle {
    color: var(--text-muted);
    margin-top: 4px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05);
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: 100%;
}

.card h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.source-buttons {
    display: flex;
    gap: 10px;
}

.source-buttons .btn.active {
    background: var(--primary-color);
    color: white;
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: calc(var(--radius) - 4px);
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fafafa;
    min-height: 280px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.upload-icon {
    width: 48px;
    height: 48px;
    fill: var(--text-muted);
    margin-bottom: 12px;
}

.drop-zone p {
    font-weight: 600;
    margin-bottom: 4px;
}

.drop-zone p span {
    color: var(--primary-color);
}

.drop-zone small {
    color: var(--text-muted);
}

.camera-view, .preview-container {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #ffffff;
    top: 0;
    left: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.pdf-icon {
    font-size: 1.2rem;
    font-weight: bold;
    color: #dc2626;
    background: #fee2e2;
    padding: 12px 24px;
    border-radius: 8px;
    border: 1px solid #fca5a5;
}

.btn {
    padding: 12px 24px;
    border-radius: var(--radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-primary:disabled {
    background: var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 8px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.textarea-container {
    position: relative;
    flex-grow: 1;
    min-height: 300px;
}

textarea {
    width: 100%;
    height: 100%;
    min-height: 320px;
    border: 1px solid var(--border-color);
    border-radius: calc(var(--radius) - 4px);
    padding: 16px;
    resize: none;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-main);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.hidden {
    display: none !important;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    border-radius: calc(var(--radius) - 4px);
    z-index: 10;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}