:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #059669;
    --secondary-light: #d1fae5;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f8fafc;
    --white: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
    --font: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    direction: rtl;
}

body.en {
    direction: ltr;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: var(--white);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 12px 0;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo svg {
    width: 32px;
    height: 32px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color var(--transition);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.nav a:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.lang-toggle {
    background: none;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    transition: all var(--transition);
}

.lang-toggle:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text);
    padding: 4px;
}

/* Hero */
.hero {
    text-align: center;
    padding: 50px 0 30px;
}

.hero h1 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 12px;
}

.hero p {
    font-size: 1.05rem;
    color: var(--text-light);
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.8;
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px 0 50px;
}

.tool-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 24px;
    text-decoration: none;
    color: var(--text);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.tool-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.tool-card .icon {
    width: 50px;
    height: 50px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 1.4rem;
}

.tool-card .icon.blue { background: var(--primary-light); color: var(--primary); }
.tool-card .icon.green { background: var(--secondary-light); color: var(--secondary); }
.tool-card .icon.orange { background: #fef3c7; color: #d97706; }
.tool-card .icon.purple { background: #ede9fe; color: #7c3aed; }

.tool-card h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.tool-card p {
    font-size: 0.88rem;
    color: var(--text-light);
    line-height: 1.6;
}

/* Tool Page Layout */
.tool-page {
    padding: 30px 0 50px;
}

.tool-header {
    text-align: center;
    margin-bottom: 30px;
}

.tool-header h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.tool-header p {
    color: var(--text-light);
    font-size: 0.95rem;
}

/* Upload Area */
.upload-area {
    background: var(--white);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    margin-bottom: 20px;
    max-width: 650px;
    margin-left: auto;
    margin-right: auto;
}

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

.upload-area .upload-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--primary);
}

.upload-area h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-light);
    font-size: 0.88rem;
    margin-bottom: 12px;
}

.upload-area .browse-btn {
    display: inline-block;
    padding: 10px 28px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    cursor: pointer;
    transition: background var(--transition);
}

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

.upload-area input[type="file"] {
    display: none;
}

/* File List */
.file-list {
    max-width: 650px;
    margin: 0 auto 16px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 8px;
}

.file-item .file-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.file-item .file-info {
    flex: 1;
    min-width: 0;
}

.file-item .file-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item .file-size {
    font-size: 0.8rem;
    color: var(--text-light);
}

.file-item .file-remove {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    flex-shrink: 0;
}

/* Options */
.options-bar {
    max-width: 650px;
    margin: 0 auto 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.options-bar label {
    font-size: 0.9rem;
    font-weight: 600;
}

.options-bar select,
.options-bar input[type="range"] {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    background: var(--white);
}

.options-bar .quality-value {
    font-weight: 700;
    color: var(--primary);
    min-width: 30px;
}

/* Convert Button */
.btn-convert {
    display: block;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    padding: 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
}

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

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

/* Progress Bar */
.progress-wrapper {
    max-width: 650px;
    margin: 16px auto;
    display: none;
}

.progress-wrapper.active {
    display: block;
}

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

.progress-bar .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    width: 0;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 8px;
}

/* Result */
.result-box {
    max-width: 650px;
    margin: 20px auto;
    background: var(--secondary-light);
    border: 1px solid var(--secondary);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    display: none;
}

.result-box.active {
    display: block;
}

.result-box .result-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.result-box h3 {
    color: var(--secondary);
    margin-bottom: 8px;
}

.result-box p {
    color: var(--text);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.result-box .savings {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--secondary);
}

.btn-download {
    display: inline-block;
    padding: 12px 36px;
    background: var(--secondary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    margin-top: 16px;
    transition: background var(--transition);
}

.btn-download:hover {
    background: #047857;
}

.btn-reset {
    display: inline-block;
    padding: 10px 28px;
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    cursor: pointer;
    margin-top: 12px;
    margin-right: 8px;
    text-decoration: none;
    transition: all var(--transition);
}

.btn-reset:hover {
    border-color: var(--text);
}

/* Error */
.error-box {
    max-width: 650px;
    margin: 20px auto;
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    color: #dc2626;
    display: none;
}

.error-box.active {
    display: block;
}

/* Content Section (below tool) */
.content-section {
    max-width: 850px;
    margin: 50px auto;
    padding: 0 20px;
}

.content-section h2 {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text);
}

.content-section h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 12px;
    margin-top: 24px;
}

.content-section p, .content-section li {
    color: var(--text);
    font-size: 0.95rem;
    line-height: 1.9;
    margin-bottom: 12px;
}

.content-section ul, .content-section ol {
    padding-right: 24px;
    margin-bottom: 16px;
}

body.en .content-section ul, body.en .content-section ol {
    padding-right: 0;
    padding-left: 24px;
}

.content-section .faq-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    overflow: hidden;
}

.content-section .faq-question {
    padding: 14px 18px;
    background: var(--white);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-section .faq-question:hover {
    background: var(--bg);
}

.content-section .faq-answer {
    padding: 0 18px 14px;
    font-size: 0.9rem;
    color: var(--text-light);
    display: none;
}

.content-section .faq-answer.open {
    display: block;
}

/* Ad Placeholders */
.ad-container {
    max-width: 850px;
    margin: 30px auto;
    text-align: center;
    min-height: 90px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    font-size: 0.85rem;
}

.ad-container.top-ad {
    margin-top: 0;
    margin-bottom: 20px;
}

/* Footer */
.footer {
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 40px 0;
    margin-top: 60px;
}

.footer .container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    justify-content: space-between;
}

.footer-col h4 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.footer-col a {
    display: block;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.88rem;
    margin-bottom: 8px;
    transition: color var(--transition);
}

.footer-col a:hover {
    color: var(--primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 24px;
    margin-top: 24px;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-light);
    width: 100%;
}

/* Page Content (About, Privacy, etc.) */
.page-content {
    max-width: 850px;
    margin: 40px auto;
    padding: 0 20px;
}

.page-content h1 {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 20px;
}

.page-content h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-top: 30px;
    margin-bottom: 12px;
}

.page-content p, .page-content li {
    font-size: 0.95rem;
    line-height: 1.9;
    margin-bottom: 14px;
    color: var(--text);
}

.page-content ul, .page-content ol {
    padding-right: 24px;
    margin-bottom: 16px;
}

body.en .page-content ul, body.en .page-content ol {
    padding-right: 0;
    padding-left: 24px;
}

/* Contact Form */
.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.contact-form label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 6px;
}

.contact-form input,
.contact-form textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.95rem;
    margin-bottom: 16px;
    transition: border-color var(--transition);
}

.contact-form input:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.contact-form textarea {
    min-height: 150px;
    resize: vertical;
}

.contact-form button {
    padding: 12px 36px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--transition);
}

.contact-form button:hover {
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .header .container {
        flex-wrap: wrap;
    }

    .nav {
        display: none;
        width: 100%;
        flex-direction: column;
        padding-top: 12px;
        gap: 8px;
    }

    .nav.open {
        display: flex;
    }

    .mobile-menu-btn {
        display: block;
    }

    .hero h1 {
        font-size: 1.4rem;
    }

    .hero p {
        font-size: 0.9rem;
    }

    .tools-grid {
        grid-template-columns: 1fr;
    }

    .upload-area {
        padding: 30px 20px;
    }

    .upload-area .upload-icon {
        font-size: 2.2rem;
    }

    .options-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .footer .container {
        flex-direction: column;
        gap: 20px;
    }
}

/* LTR specific adjustments */
body.en .upload-area,
body.en .file-item,
body.en .options-bar,
body.en .result-box,
body.en .error-box {
    text-align: left;
}

body.en .result-box {
    text-align: center;
}

/* Utility */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
