:root {
    --primary: #18181b;
    --primary-hover: #27272a;
    --mid-grey: #71717a;
    --border: #e4e4e7;
    --border-radius: 8px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --transition: all 0.2s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #ffffff;
    min-height: 100vh;
    padding: 0;
    line-height: 1.6;
}

.container {
    background: #ffffff;
}

.header {
    background: var(--primary);
    color: white;
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: white;
}

.header-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

.header-brand img {
    width: 32px;
    height: 32px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    direction: ltr;
}

.help-button,
.lang-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.85rem;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-button:hover,
.lang-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.35);
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.popup-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 15px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: popupSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

.popup-header {
    background: var(--primary);
    color: white;
    padding: 20px 30px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.popup-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.popup-body {
    padding: 30px;
    line-height: 1.6;
}

.guide-section {
    margin-bottom: 25px;
}

.guide-section h3 {
    color: #2d3748;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.guide-section p, .guide-section li {
    color: #4a5568;
    margin-bottom: 8px;
}

.guide-section ul {
    padding-left: 20px;
}

.language-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.language-tab {
    padding: 8px 16px;
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.language-tab.active {
    background: var(--primary);
    color: white;
}

.language-content {
    display: none;
}

.language-content.active {
    display: block;
}

.feature-highlight {
    background: #f5f5f5;
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary);
    margin: 15px 0;
}

.contact-info {
    background: #f5f5f5;
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: 20px;
}

.contact-info a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.contact-info a:hover {
    text-decoration: underline;
}

.contact-byline {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 8px;
}

#contactInfoHe {
    display: none;
}

/* RTL Support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .guide-section ul {
    padding-right: 20px;
    padding-left: 0;
}

.main-content {
    padding: 32px 32px;
}

.upload-section {
    border: 2px dashed #d4d4d8;
    border-radius: var(--border-radius);
    padding: 40px 32px;
    text-align: center;
    margin-bottom: 40px;
    transition: var(--transition);
    cursor: pointer;
    background: #fafafa;
    position: relative;
}

.upload-section:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.upload-section.dragover {
    border-color: var(--primary);
    background: #f0f0f0;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 5rem;
    margin-bottom: 25px;
}

.upload-text {
    font-size: 1.3rem;
    color: #4a5568;
    margin-bottom: 25px;
    font-weight: 500;
}

.file-input {
    display: none;
}

.upload-btn {
    background: var(--primary);
    color: white;
    padding: 15px 35px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
}

.upload-btn:hover {
    background: var(--primary-hover);
}

/* Turnstile */
#turnstileContainer {
    display: none;
    margin-top: 20px;
    text-align: center;
}

.security-verification-text {
    margin-bottom: 15px;
    color: #4a5568;
    font-size: 0.9rem;
}

#turnstileFallback {
    display: none;
    margin-top: 15px;
    padding: 16px;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    background: #fef2f2;
}

.turnstile-error-title {
    color: #7f1d1d;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.turnstile-error-desc {
    color: #991b1b;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.turnstile-reload-btn {
    background: #18181b;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.file-info {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 25px;
    margin: 30px 0;
    display: none;
    box-shadow: var(--shadow);
}

.file-info h3 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.file-info p {
    margin: 8px 0;
    color: #4a5568;
}

.progress-container {
    background: #e2e8f0;
    border-radius: 20px;
    padding: 4px;
    margin: 30px 0;
    display: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    background: var(--primary);
    height: 12px;
    border-radius: 20px;
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.options-section {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 24px 32px;
    margin: 40px 0;
    display: none;
    box-shadow: var(--shadow);
}

.options-title {
    font-size: 1.6rem;
    color: #2d3748;
    margin-bottom: 30px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.option-group {
    margin-bottom: 30px;
}

.option-label {
    display: block;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

.option-select, .option-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

.option-select:focus, .option-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.08);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 15px 0;
    padding: 12px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.checkbox-group:hover {
    background: rgba(0, 0, 0, 0.03);
}

.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.checkbox-group label {
    font-weight: 500;
    cursor: pointer;
}

/* Custom range input — hidden until "Custom Range" is selected */
#customRange {
    display: none;
    margin-top: 15px;
}

.download-section {
    display: flex;
    gap: 25px;
    justify-content: center;
    margin-top: 40px;
    flex-wrap: wrap;
}

.download-btn {
    background: var(--primary);
    color: white;
    padding: 18px 35px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 600;
    min-width: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.download-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

.download-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.preview-section {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 24px 32px;
    margin: 40px 0;
    display: none;
    box-shadow: var(--shadow);
}

/* Preview scroll wrapper */
.preview-scroll {
    overflow-x: auto;
    max-height: 400px;
    overflow-y: auto;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.preview-table th,
.preview-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    word-wrap: break-word;
    max-width: 200px;
}

.preview-table td.rtl {
    direction: rtl;
    text-align: right;
}

.preview-table th {
    background: var(--primary);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}

.preview-table tr:hover {
    background: #f7fafc;
}

.status-message {
    padding: 20px;
    border-radius: var(--border-radius);
    margin: 30px 0;
    font-weight: 600;
    display: none;
    box-shadow: var(--shadow);
}

.status-success {
    background: #f5f5f5;
    color: #18181b;
    border: 2px solid #a1a1aa;
}

.status-error {
    background: #fef2f2;
    color: #7f1d1d;
    border: 2px solid #fca5a5;
}

.status-info {
    background: #fafafa;
    color: #18181b;
    border: 2px solid #d4d4d8;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

.feature-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

.feature-tags span {
    font-size: 0.75rem;
    color: var(--mid-grey);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 3px 10px;
}

.footer {
    background: var(--primary);
    color: white;
    padding: 32px 24px;
    text-align: center;
    margin-top: 40px;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
}

.footer-branding {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.footer-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.footer-text {
    font-size: 1.1rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.footer-link {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    padding: 8px 16px;
    border-radius: 6px;
}

.footer-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.footer-privacy {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.6;
    margin-bottom: 20px;
}

.footer-copyright {
    font-size: 0.85rem;
    opacity: 0.7;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

/* Share Section */
.share-section {
    background: white;
    border-top: 1px solid var(--border);
    padding: 32px 24px;
}

.share-container {
    max-width: 900px;
    margin: 0 auto;
}

.share-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.share-text h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 4px 0;
}

.share-text p {
    font-size: 0.9rem;
    color: var(--mid-grey);
    margin: 0;
}

.share-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}

.share-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f4f4f5;
    color: #52525b;
}

.share-btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.share-btn:nth-child(1):hover { background: #1877f2; color: white; }
.share-btn:nth-child(2):hover { background: #000000; color: white; }
.share-btn:nth-child(3):hover { background: #0077b5; color: white; }
.share-btn:nth-child(4):hover { background: #25d366; color: white; }
.share-btn:nth-child(5):hover { background: #0088cc; color: white; }
.share-btn:nth-child(6):hover { background: #e1306c; color: white; }

@media (max-width: 640px) {
    .share-content { flex-direction: column; text-align: center; gap: 16px; }
}

.project-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 15px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: block;
}

@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: var(--border-radius);
    }

    .main-content {
        padding: 20px 16px;
    }

    .header {
        padding: 0 16px;
    }

    .upload-section {
        padding: 32px 16px;
    }

    .options-section, .preview-section {
        padding: 20px 16px;
    }

    .download-section {
        flex-direction: column;
        align-items: center;
    }

    .download-btn {
        width: 100%;
        max-width: 300px;
    }

    .footer {
        padding: 24px 16px;
    }

    .footer-branding {
        flex-direction: column;
        gap: 10px;
    }

    .footer-links {
        flex-direction: column;
        gap: 15px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
