/* Variables & Themes */
:root {
    color-scheme: dark light;
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --card-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    --border-radius: 16px;
    --transition: all 0.3s ease;
    
    font-family: 'Cairo', sans-serif;
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

[dir="ltr"] {
    font-family: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: var(--transition);
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Loader */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--glass-border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Install App Banner */
.install-banner {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    z-index: 9500;
    transition: transform 0.35s ease, opacity 0.35s ease;
}
.install-banner.hidden {
    display: flex;
    transform: translateY(120%);
    opacity: 0;
    pointer-events: none;
}
.install-banner-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    flex-shrink: 0;
}
.install-banner-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}
.install-banner-text strong {
    font-size: 0.95rem;
    color: var(--text-color);
}
.install-banner-text span {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.install-banner-btn {
    flex-shrink: 0;
    padding: 0.5rem 1.1rem !important;
    font-size: 0.85rem;
    width: auto !important;
}
.install-banner-close {
    position: absolute;
    top: -0.5rem;
    inset-inline-end: -0.5rem;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: var(--bg-color);
    color: var(--text-muted);
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* File Loader */
.file-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.4s ease;
}
.file-loader-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.file-loader-content {
    background: var(--bg-color);
    padding: 2.5rem 2rem;
    text-align: center;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.2rem;
    max-width: 90%;
    width: 380px;
    border: 1px solid var(--glass-border);
}
.file-spinner {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.animated-files {
    position: relative;
    width: 100%;
    height: 100%;
}
.animated-files i {
    position: absolute;
    font-size: 2.5rem;
}
.doc-icon {
    color: var(--primary-color);
    left: 0;
    bottom: 0;
    animation: bounce 2s infinite;
}
.lang-icon {
    color: var(--secondary-color);
    right: 0;
    top: 0;
    font-size: 2.8rem !important;
    animation: bounce 2s infinite 1s;
}
.magic-icon {
    color: #fbbf24;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem !important;
    animation: pulse-magic 1.5s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}
@keyframes pulse-magic {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(128,128,128,0.2);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-top: 0.5rem;
}
.progress-fill {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
    width: 40%;
    animation: progress-slide 1.5s infinite ease-in-out;
}
@keyframes progress-slide {
    0% { left: -40%; }
    100% { left: 100%; }
}

/* Translated Image Preview */
.translated-image-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    margin: 0.75rem 0;
}
.translated-image-wrap img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

/* Glassmorphism Classes */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--card-shadow);
    border-radius: var(--border-radius);
}

/* Header */
header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    flex-wrap: nowrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    flex-shrink: 0;
}
.logo h1 {
    font-size: inherit;
    margin: 0;
}

nav ul {
    display: none; /* Hidden on mobile */
}

@media (min-width: 768px) {
    nav ul {
        display: flex;
        gap: 2rem;
    }
    nav a {
        font-weight: 600;
        transition: var(--transition);
    }
    nav a:hover, nav a.active {
        color: var(--primary-color);
    }
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

/* Mobile Adjustments for Header */
@media (max-width: 767px) {
    header .container {
        padding: 0.8rem 0.5rem;
        gap: 0.3rem;
        flex-wrap: wrap;
    }
    .logo {
        font-size: 1.1rem;
        gap: 0.3rem;
        /* allow logo to shrink on very small screens to avoid overflow */
        flex-shrink: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .header-actions {
        gap: 0.3rem;
    }
    .header-actions .lang-select {
        font-size: 0.85rem;
        padding: 0.2rem 0.4rem !important;
        margin-left: 0.2rem !important;
    }
    .header-actions .icon-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    .header-actions .btn-primary {
        padding: 0.4rem 0.6rem;
        border-radius: 50px;
    }
    .header-actions .btn-primary span {
        display: none;
    }
}

/* Buttons */
button {
    cursor: pointer;
    font-family: inherit;
    border: none;
    outline: none;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 600;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--glass-bg);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    padding: 0.5rem 1.5rem;
    border-radius: 20px;
    font-weight: 600;
}

.icon-btn {
    background: transparent;
    color: var(--text-color);
    font-size: 1.2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.icon-btn:hover {
    background: rgba(128, 128, 128, 0.1);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 1rem;
    background: radial-gradient(circle at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}

.hero h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 800;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Animations */
.animate-up {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeUp 0.8s forwards;
}

.delay-1 { animation-delay: 0.2s; }

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Translator Section */
.translator-section {
    padding: 2rem 0;
}

.translator-container {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
}

@media (min-width: 768px) {
    .translator-container {
        flex-direction: row;
        align-items: stretch;
    }
}

.lang-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(128, 128, 128, 0.05);
    border-radius: var(--border-radius);
    padding: 1rem;
}

.lang-header {
    margin-bottom: 1rem;
}

.lang-select {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    font-family: inherit;
    font-weight: 600;
}

textarea {
    flex: 1;
    min-height: 150px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 1.2rem;
    resize: none;
    outline: none;
}

textarea::placeholder {
    color: var(--text-muted);
}

.controls {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.mic-btn.recording, .target-mic-btn.recording {
    color: var(--secondary-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(236, 72, 153, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); }
}

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

.btn-translate {
    background: var(--primary-color);
    color: white;
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    width: 100%;
}

@media (min-width: 768px) {
    .btn-translate {
        writing-mode: vertical-rl;
        padding: 1.5rem 0.8rem;
        height: auto;
    }
}

/* Skeleton Loading */
.skeleton-text {
    width: 100%;
    height: 150px;
    background: linear-gradient(90deg, var(--bg-color) 25%, rgba(128,128,128,0.2) 50%, var(--bg-color) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

.hidden { display: none !important; }

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Ads */
.ad-banner {
    background: rgba(128, 128, 128, 0.1);
    border: 1px dashed var(--text-muted);
    text-align: center;
    padding: 1rem;
    color: var(--text-muted);
    border-radius: 8px;
    margin: 1rem auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.ad-leaderboard {
    width: 100%;
    max-width: 728px;
    min-height: 90px;
}

.ad-medium-rectangle {
    width: 100%;
    max-width: 300px;
    min-height: 250px;
}

.ad-large-rectangle {
    width: 100%;
    max-width: 336px;
    min-height: 280px;
}

.ad-skyscraper {
    width: 100%;
    max-width: 160px;
    min-height: 600px;
}

.ad-responsive {
    width: 100%;
    min-height: 100px;
}

.mt-3 { margin-top: 1rem; }
.my-4 { margin: 2rem 0; }
.text-center { text-align: center; }

/* Likes */
.likes-section {
    padding: 2rem 0;
}
.like-btn {
    background: var(--glass-bg);
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.8rem 2rem;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
}
.like-btn:hover, .like-btn.liked {
    background: var(--primary-color);
    color: white;
}

/* Comments */
.comments-section {
    padding: 3rem 0;
}
.section-title {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
}

.comments-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .comments-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1024px) {
    .comments-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.comment-card {
    padding: 1.5rem;
}
.comment-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
}
.comment-author {
    font-weight: bold;
}
.comment-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Footer */
footer {
    background: var(--glass-bg);
    border-top: 1px solid var(--glass-border);
    padding: 3rem 0 0;
    margin-top: 4rem;
}
.footer-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}
@media (min-width: 768px) {
    .footer-content {
        grid-template-columns: repeat(3, 1fr);
    }
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 1.5rem;
}
.social-links a:hover {
    color: var(--primary-color);
}

.footer-links ul li {
    margin-bottom: 0.5rem;
}
.footer-links a:hover {
    color: var(--primary-color);
}

.footer-contact input, .footer-contact textarea {
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 1rem;
    background: var(--bg-color);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    border-radius: 8px;
    font-family: inherit;
}
.footer-bottom {
    text-align: center;
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.2);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    color: var(--text-color);
    animation: slideInRight 0.3s forwards;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.error { border-left-color: #ef4444; }
.toast.success { border-left-color: #22c55e; }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.3s ease;
}
.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
.modal-content {
    background: var(--bg-color);
    width: 90%;
    max-width: 400px;
    padding: 2.5rem 2rem;
    position: relative;
    border-radius: var(--border-radius);
    text-align: center;
    transform: scale(1);
    transition: transform 0.3s ease;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-overlay.hidden .modal-content {
    transform: scale(0.9);
}
.close-modal-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.2rem;
}
[dir="ltr"] .close-modal-btn {
    right: auto;
    left: 15px;
}
.close-modal-btn:hover {
    color: var(--primary-color);
}
.modal-content h3 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}
.modal-content p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
}

/* Conversation Mode: hands-free two-party dialogue view */
.modal-content.conversation-panel {
    max-width: 560px;
    width: 94%;
    text-align: center;
    display: flex;
    flex-direction: column;
    max-height: 88vh;
}

.conversation-parties {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.conversation-parties .party {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
}

.conversation-parties .party-a { color: var(--primary-color); }
.conversation-parties .party-b { color: var(--secondary-color); }

.conversation-chat {
    flex: 1;
    overflow-y: auto;
    min-height: 220px;
    max-height: 48vh;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.5rem 0.25rem;
    margin-bottom: 1rem;
    text-align: start;
}

.conversation-chat:empty::before {
    content: "لا توجد رسائل بعد";
    display: block;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 2rem;
}

.conv-msg {
    max-width: 82%;
    padding: 0.6rem 0.9rem;
    border-radius: 14px;
    animation: convMsgIn 0.25s ease;
}

@keyframes convMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.conv-msg .conv-original {
    font-size: 0.78rem;
    opacity: 0.75;
    margin-bottom: 0.2rem;
}

.conv-msg .conv-translated {
    font-size: 1rem;
    font-weight: 600;
}

.conv-msg.speaker-a {
    align-self: flex-start;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--glass-border);
}

.conv-msg.speaker-b {
    align-self: flex-end;
    background: rgba(236, 72, 153, 0.15);
    border: 1px solid var(--glass-border);
}

.conv-msg.system {
    align-self: center;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-align: center;
    max-width: 100%;
}

.conversation-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-align: center;
    min-height: 1.4rem;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.conv-mic-indicator {
    display: none;
}

.conversation-status.listening {
    color: var(--primary-color);
}

.conversation-status.listening .conv-mic-indicator {
    display: inline-block;
    color: var(--secondary-color);
    animation: pulse 1.5s infinite;
}

.conversation-controls {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
}

.btn-social {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--glass-border);
    transition: var(--transition);
    cursor: pointer;
}
.google-btn {
    background: #fff;
    color: #333;
}
.google-btn:hover {
    background: #f1f1f1;
    transform: translateY(-2px);
}
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    margin: 1.5rem 0;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--glass-border);
}
.divider span {
    padding: 0 15px;
    font-size: 0.9rem;
}
.input-group {
    position: relative;
    margin-bottom: 1rem;
}
.input-group i {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    right: 15px;
    color: var(--text-muted);
}
[dir="ltr"] .input-group i {
    right: auto;
    left: 15px;
}
.input-group input {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 2.5rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-color);
    font-family: inherit;
    transition: border-color 0.3s;
}
.input-group input:focus {
    border-color: var(--primary-color);
    outline: none;
}
[dir="ltr"] .input-group input {
    padding: 0.8rem 2.5rem 0.8rem 1rem;
}
