/* ===== متغيرات الألوان - ألوان التداول ===== */
:root {
    --color-primary: #1a73e8;
    --color-primary-dark: #0d47a1;
    --color-primary-light: #4fc3f7;
    --color-success: #00c853;
    --color-gold: #ffb300;
    --color-gold-dark: #ff8f00;
    --color-red: #d32f2f;

    --bg-primary: #0a1929;
    --bg-secondary: #102a43;
    --bg-card: #142d4a;
    --bg-elevated: #1a3a5c;
    --bg-hover: #1e4470;
    --text-primary: #ffffff;
    --text-secondary: #b0bec5;
    --text-tertiary: #78909c;
    --border-color: #1e3a5c;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --navbar-bg: rgba(10, 25, 41, 0.85);
    --install-btn-bg: #1a73e8;
    --install-btn-hover: #1557b0;
    --age-rating-bg: #d32f2f;
    --skeleton-base: #1a3a5c;
    --skeleton-shine: #2a5a8c;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f5f7fa;
    --bg-hover: #e3eaf0;
    --text-primary: #0a1929;
    --text-secondary: #455a64;
    --text-tertiary: #78909c;
    --border-color: #e8edf2;
    --shadow-color: rgba(0, 0, 0, 0.06);
    --navbar-bg: rgba(255, 255, 255, 0.9);
    --install-btn-bg: #1a73e8;
    --install-btn-hover: #1557b0;
    --age-rating-bg: #d32f2f;
    --skeleton-base: #e0e7ee;
    --skeleton-shine: #f0f4f8;
}

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

/* ضمان أن hidden يخفي العنصر حتى مع display:flex في CSS */
[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s ease, color 0.3s ease;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

html[dir="ltr"] body {
    font-family: 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

/* ===== زر اللغة العائم ===== */
.lang-toggle-floating {
    position: fixed;
    top: 16px;
    inset-inline-end: 16px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #455a64;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: none;
}

.lang-toggle-floating:hover {
    background: #f0f4f8;
}

.lang-toggle-floating .lang-current {
    display: none;
}

/* ===== صفحة Google Play ===== */
.play-store-page {
    padding: 24px 0 40px;
}

/* المطور */
.ps-developer {
    margin-bottom: 8px;
}

.ps-developer span {
    color: var(--color-primary);
    font-size: 1.1rem;
    font-weight: 700;
}

/* اسم التطبيق */
.ps-app-title {
    margin-bottom: 24px;
}

.ps-app-name {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    margin-bottom: 2px;
}

.ps-app-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== صف معلومات التطبيق ===== */
.ps-info-row {
    display: flex;
    align-items: center;
    gap: clamp(16px, 4vw, 28px);
    padding: 12px 0;
    margin-bottom: 12px;
    flex-wrap: nowrap;
    overflow: visible;
}

/* أيقونة التطبيق */
.ps-app-icon-wrapper {
    flex-shrink: 0;
    position: relative;
    width: clamp(72px, 22vw, 92px);
    height: clamp(72px, 22vw, 92px);
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ps-app-icon {
    width: clamp(56px, 18vw, 72px);
    height: clamp(56px, 18vw, 72px);
    border-radius: 16px;
    object-fit: cover;
    transition: border-radius 0.3s ease, transform 0.3s ease;
}

/* حالة التثبيت: الأيقونة تصبح دائرية */
.ps-app-icon-wrapper.installing .ps-app-icon,
.ps-app-icon-wrapper.installing .ps-app-icon-placeholder,
.ps-app-icon-wrapper.completed .ps-app-icon,
.ps-app-icon-wrapper.completed .ps-app-icon-placeholder {
    border-radius: 50%;
}

/* حلقة التقدم حول الأيقونة — متناسقة مع حجم الصورة */
.progress-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    overflow: visible;
}

.ps-app-icon-wrapper.installing .progress-ring,
.ps-app-icon-wrapper.completed .progress-ring {
    opacity: 1;
}

.progress-ring-bg {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 3;
}

.progress-ring-fill {
    fill: none;
    stroke: #1a73e8;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 201.06;
    stroke-dashoffset: 201.06;
    transition: stroke-dashoffset 0.2s ease-out;
}

.ps-app-icon-wrapper.completed .progress-ring-fill {
    stroke: #1a73e8;
}

/* خلفية سوداء للأيقونة في الوضع الفاتح */
[data-theme="light"] .ps-app-icon,
[data-theme="light"] .footer-logo {
    background: #000000;
}

.ps-app-icon-placeholder {
    width: clamp(56px, 18vw, 72px);
    height: clamp(56px, 18vw, 72px);
    border-radius: 16px;
    background: linear-gradient(135deg, #1967D2, #ffb300);
    color: white;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* معلومات التطبيق الافتراضية */
.ps-info-stats {
    display: flex;
    align-items: center;
    gap: 28px;
    flex: 1;
    justify-content: flex-start;
    align-self: center;
    transition: opacity 0.25s ease;
}

.ps-info-stats[hidden] {
    display: none;
}

/* عمود إحصائية */
.ps-info-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ps-stat-number {
    font-size: 1.05rem;
    font-weight: 600;
    color: #202124;
    line-height: 1.3;
}

.ps-stat-label {
    font-size: 0.75rem;
    color: #5f6368;
    text-align: center;
    white-space: nowrap;
}

/* فاصل عمودي */
.ps-info-divider {
    width: 1px;
    height: 36px;
    background: #dadce0;
    flex-shrink: 0;
}

/* نجمة التقييم */
.star-icon {
    color: #1967D2;
    font-size: 1.1rem;
}

.ps-rating-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ps-rating-number {
    font-size: 1.05rem;
    font-weight: 600;
    color: #202124;
}

/* أيقونة توجيه الوالدين */
.ps-parental-icon {
    width: 21px;
    height: 21px;
    background: #f9ab00;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* ===== حالة التثبيت ===== */
.ps-install-status {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(4px, 1.5vw, 6px);
    flex: 1;
    align-self: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ps-install-status:not([hidden]) {
    opacity: 1;
}

/* سطر النسبة والحجم — أفقي */
.install-status-line {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.install-status-percent {
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 600;
    color: #000000;
    font-variant-numeric: tabular-nums;
}

.install-status-of {
    font-size: clamp(0.9rem, 3vw, 1.1rem);
    color: #5f6368;
}

.install-status-total {
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 600;
    color: #000000;
}

.play-protect-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.play-protect-icon {
    color: #01875f;
    flex-shrink: 0;
}

.play-protect-text {
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    color: #5f6368;
}

/* ===== زر التثبيت ===== */
.ps-install-section {
    margin-bottom: 20px;
}

/* زر التثبيت الافتراضي - Capsule/Pill */
.ps-install-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 480px;
    background: #1967D2;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    min-height: 36px;
}

.ps-install-btn:not([hidden]) {
    display: flex;
}

.ps-install-btn:hover {
    background: #1557b0;
}

.ps-install-btn:active {
    transform: scale(0.99);
}

/* أزرار التثبيت: إلغاء + فتح */
.ps-install-actions {
    display: none;
    gap: 12px;
    width: 100%;
    max-width: 480px;
}

.ps-install-actions:not([hidden]) {
    display: flex;
}

.ps-action-btn {
    flex: 1;
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    min-height: 36px;
}

/* زر الإلغاء: أبيض + border رمادي + نص أزرق */
.ps-action-btn--cancel {
    background: #ffffff;
    color: #1967D2;
    border: 1px solid #dadce0;
}

.ps-action-btn--cancel:hover {
    background: #f8f9fa;
    border-color: #bdc1c6;
}

.ps-action-btn--cancel:active {
    transform: scale(0.99);
}

/* زر الفتح: معطل (رمادي فاتح) */
.ps-action-btn--open {
    background: #e6e6e6;
    color: #9aa0a6;
    border: none;
    cursor: not-allowed;
}

/* زر الفتح: مفعّل (أزرق) */
.ps-action-btn--open.enabled {
    background: #1967D2;
    color: white;
    cursor: pointer;
}

.ps-action-btn--open.enabled:hover {
    background: #1557b0;
}

.ps-action-btn--open.enabled:active {
    transform: scale(0.99);
}

.ps-install-note {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #5f6368;
}

/* ===== كاروسيل لقطات الشاشة ===== */
.ps-screenshots {
    margin-bottom: 32px;
}

.ps-screenshots-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 4px 0 16px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ps-screenshots-scroll::-webkit-scrollbar {
    display: none;
}

.ps-screenshot-item {
    flex-shrink: 0;
    width: 220px;
    height: 440px;
    border-radius: 16px;
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    scroll-snap-align: start;
    box-shadow: 0 4px 12px var(--shadow-color);
}

.ps-screenshot-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ps-screenshot-item:hover img {
    transform: scale(1.03);
}

/* ===== قسم "حول التطبيق" ===== */
.ps-about-section {
    margin-bottom: 24px;
}

.ps-about-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ps-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ps-about-arrow {
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

html[dir="rtl"] .ps-about-arrow svg {
    transform: scaleX(-1);
}

.ps-about-arrow:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.ps-about-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

/* ===== بطاقة الترتيب ===== */
.ps-ranking-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.ps-ranking-number {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-primary-light);
    line-height: 1;
    flex-shrink: 0;
}

.ps-ranking-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

/* ===== بطاقة معلومات إضافية ===== */
.ps-info-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.ps-info-card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.ps-info-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ps-info-row-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ps-info-key {
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

.ps-info-val {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ===== بطاقة التواصل ===== */
.ps-contact-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
}

.ps-contact-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.ps-contact-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ps-contact-link {
    color: var(--color-primary-light);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.ps-contact-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* ===== زر التثبيت العائم ===== */
.floating-install {
    position: fixed;
    bottom: 16px;
    inset-inline-start: 0;
    inset-inline-end: 0;
    z-index: 900;
    opacity: 0;
    transform: translateY(100px);
    transition: all 0.3s ease;
    pointer-events: none;
    background: var(--navbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-color);
    padding: 12px 20px;
}

.floating-install.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.btn-install-floating {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    background: #1967D2;
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease;
    min-height: 52px;
}

.btn-install-floating:hover {
    background: #1557b0;
}

.btn-install-floating--open {
    background: #1967D2;
}

.btn-install-floating--open:disabled {
    background: #e6e6e6;
    color: #9aa0a6;
    cursor: not-allowed;
}

/* ===== التذييل ===== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 32px 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.footer-logo {
    width: 24px;
    height: 24px;
    border-radius: 5px;
    box-shadow: none;
    filter: none;
}

.footer-text {
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

/* ===== الحركات ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ===== التجاوب ===== */
@media (max-width: 768px) {
    .container { padding: 0 16px; }
    .play-store-page { padding: 64px 0 32px; }
    .ps-app-name { font-size: 1.5rem; }
    .ps-app-subtitle { font-size: 0.9rem; }

    .ps-info-row {
        gap: 16px;
        padding: 12px 0;
    }

    .ps-app-icon-wrapper { width: clamp(64px, 20vw, 80px); height: clamp(64px, 20vw, 80px); }
    .ps-app-icon, .ps-app-icon-placeholder { width: clamp(48px, 15vw, 60px); height: clamp(48px, 15vw, 60px); }
    .ps-stat-number { font-size: 1rem; }
    .ps-stat-label { font-size: 0.7rem; }
    .ps-info-divider { height: 32px; }

    .ps-install-btn { padding: 6px 16px; font-size: 0.9rem; }

    .ps-screenshot-item { width: 200px; height: 400px; }

    .ps-section-title { font-size: 1.05rem; }
    .ps-ranking-number { font-size: 2rem; }
    .ps-ranking-text { font-size: 0.85rem; }
}

@media (max-width: 480px) {
    .ps-app-name { font-size: 1.3rem; }
    .ps-info-row { gap: 12px; }
    .ps-app-icon-wrapper { width: clamp(56px, 18vw, 68px); height: clamp(56px, 18vw, 68px); }
    .ps-app-icon, .ps-app-icon-placeholder { width: clamp(42px, 14vw, 52px); height: clamp(42px, 14vw, 52px); border-radius: 12px; }
    .ps-stat-number { font-size: 0.9rem; }
    .ps-stat-label { font-size: 0.65rem; }
    .ps-info-divider { height: 28px; }
    .ps-screenshot-item { width: 180px; height: 360px; }
    .ps-screenshots-scroll { gap: 8px; }
    .ps-ranking-card { padding: 16px 20px; }
    .ps-info-card, .ps-contact-card { padding: 16px 20px; }
}

/* شريط التمرير العام */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary);
}

/* إمكانية الوصول */
:focus-visible {
    outline: 2px solid var(--color-primary-light);
    outline-offset: 2px;
}

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

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
}
