@keyframes iridescentAurora {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
@keyframes goldenPulse {
    0% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4), 0 0 20px rgba(245, 158, 11, 0.2); }
    50% { box-shadow: 0 0 30px rgba(245, 158, 11, 0.85), 0 0 45px rgba(245, 158, 11, 0.5); }
    100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4), 0 0 20px rgba(245, 158, 11, 0.2); }
}
.ai-avatar-core { animation: goldenPulse 3s ease-in-out infinite; }

/* ========== BASE STYLES ========== */
body {
    font-family: 'Cairo', 'Amiri', sans-serif;
    background: linear-gradient(135deg, #070114, #2c021d, #041235, #002d1d, #44001a, #0b0114, #120126, #031424, #02242a, #2a0217, #01151a);
    background-size: 500% 500%;
    animation: iridescentAurora 25s ease infinite;
    color: #f3f4f6;
    overflow-x: hidden;
    padding-bottom: 120px;
    transition: all 0.5s ease;
    min-height: 100vh;
}

/* ========== ARABIC THEME (عالمي ودافئ) ========== */
body.lang-ar {
    font-family: 'Cairo', 'Amiri', sans-serif;
    /* تدرج دافئ من العنابي إلى الذهبي مع لمسات عربية */
    background: linear-gradient(145deg, #1a0a1c 0%, #3d1020 20%, #6b2a1a 40%, #a65c1e 60%, #d4a23a 80%, #1a0a1c 100%);
    background-size: 400% 400%;
    animation: iridescentAurora 20s ease-in-out infinite;
}
body.lang-ar .lang-border-decor { border-right: 4px solid #d4a23a; }
body.lang-ar .gold-text {
    background: linear-gradient(135deg, #f6e27a 0%, #d4a23a 50%, #b8860b 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
body.lang-ar .gold-btn {
    background: linear-gradient(135deg, #d4a23a 0%, #f6e27a 50%, #b8860b 100%);
    color: #1a0a1c;
}
body.lang-ar .gold-btn:hover { box-shadow: 0 8px 30px rgba(212, 162, 58, 0.7); }
body.lang-ar .glass-card {
    background: rgba(26, 10, 28, 0.8);
    border: 1px solid rgba(212, 162, 58, 0.35);
}
body.lang-ar .glass-card:hover {
    box-shadow: 0 20px 50px rgba(212, 162, 58, 0.25);
}

/* ========== ENGLISH THEME (أنيق وعالمي بلمسات فضية) ========== */
body.lang-en {
    font-family: 'Inter', 'Montserrat', sans-serif;
    background: linear-gradient(145deg, #0b0c10 0%, #1f2833 35%, #232b36 65%, #0b0c10 100%);
    background-size: 300% 300%;
    animation: iridescentAurora 18s ease-in-out infinite;
    color: #e8edf2;
}
body.lang-en .lang-border-decor { border-left: 4px solid #c0cbd6; }
body.lang-en .gold-text {
    background: linear-gradient(135deg, #d0d9e2 0%, #ffffff 50%, #9aa8b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
body.lang-en .gold-btn {
    background: linear-gradient(135deg, #d0d9e2 0%, #ffffff 50%, #b0bec5 100%);
    color: #0b0c10;
    font-weight: 700;
}
body.lang-en .gold-btn:hover { box-shadow: 0 8px 30px rgba(255, 255, 255, 0.3); }
body.lang-en .glass-card {
    background: rgba(15, 20, 30, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.12);
}
body.lang-en .glass-card:hover {
    box-shadow: 0 20px 50px rgba(255, 255, 255, 0.08);
}
body.lang-en .nav-item.active {
    color: #b0bec5;
    text-shadow: 0 0 12px rgba(192, 203, 214, 0.5);
}

/* ========== RUSSIAN THEME (أزرق ملكي وتقني) ========== */
body.lang-ru {
    font-family: 'Roboto', 'Inter', sans-serif;
    background: linear-gradient(145deg, #020b1a 0%, #0a2442 30%, #1a3a5c 60%, #020b1a 100%);
    background-size: 350% 350%;
    animation: iridescentAurora 22s ease-in-out infinite;
    color: #d6e6f5;
}
body.lang-ru .lang-border-decor { border-left: 4px solid #4a90d9; }
body.lang-ru .gold-text {
    background: linear-gradient(135deg, #4a90d9 0%, #9ac8f0 50%, #1e5a9e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
body.lang-ru .gold-btn {
    background: linear-gradient(135deg, #4a90d9 0%, #9ac8f0 50%, #1e5a9e 100%);
    color: #ffffff;
    font-weight: 700;
}
body.lang-ru .gold-btn:hover { box-shadow: 0 8px 30px rgba(74, 144, 217, 0.6); }
body.lang-ru .glass-card {
    background: rgba(2, 11, 26, 0.8);
    border: 1px solid rgba(74, 144, 217, 0.25);
}
body.lang-ru .glass-card:hover {
    box-shadow: 0 20px 50px rgba(74, 144, 217, 0.2);
}
body.lang-ru .nav-item.active {
    color: #9ac8f0;
    text-shadow: 0 0 12px rgba(74, 144, 217, 0.4);
}

/* ========== SHARED GLOBAL ELEMENTS ========== */
.gold-border {
    border: 2px solid transparent;
    border-image: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c) 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 0 10px rgba(212, 175, 55, 0.15);
}
.gold-text {
    background: linear-gradient(135deg, #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.gold-btn {
    background: linear-gradient(135deg, #bf953f 0%, #fcf6ba 50%, #b38728 100%);
    color: #000;
    font-weight: 900;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(179, 135, 40, 0.4);
    border: none;
}
.gold-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(252, 246, 186, 0.6);
}
.glass-card {
    background: rgba(8, 4, 20, 0.75);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(197, 160, 60, 0.25);
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.6);
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 50px rgba(197, 160, 60, 0.3);
}
.royal-logo-premium {
    filter: brightness(0.95) contrast(0.91) saturate(0.98);
    border: 2px solid #bf953f;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
    background-color: #ffffff;
    transition: all 0.3s ease;
}
.royal-logo-premium:hover {
    filter: brightness(1) contrast(1) saturate(1);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.6);
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: rgba(7, 3, 18, 0.96);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-top: 2px solid rgba(197, 160, 60, 0.45);
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    padding: 10px 4px;
    z-index: 1000;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-item {
    text-align: center;
    color: #9ca3af;
    cursor: pointer;
    flex: 0 0 auto;
    min-width: 70px;
    font-size: 0.65rem;
    transition: all 0.3s ease;
    padding: 2px 4px;
}
.nav-item i {
    font-size: 1.2rem;
    display: block;
    margin-bottom: 2px;
    transition: transform 0.3s ease;
}
.nav-item.active {
    color: #f59e0b;
    font-weight: bold;
    transform: translateY(-2px);
    text-shadow: 0 0 10px rgba(197, 160, 60, 0.3);
}
.nav-item.active i { transform: scale(1.15); color: #fbbf24; }
.app-screen {
    display: none;
    animation: screenFadeIn 0.5s ease;
}
.app-screen.active { display: block; }
@keyframes screenFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========== HAIR CATALOG ========== */
.hair-catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 10px;
}
.hair-swatch-3d {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.25);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: inset 0 3px 6px rgba(255,255,255,0.4), inset 0 -4px 8px rgba(0,0,0,0.7), 0 6px 12px rgba(0,0,0,0.6);
}
.hair-swatch-3d:hover {
    transform: scale(1.18) translateY(-3px);
    border-color: #f59e0b;
    box-shadow: inset 0 3px 6px rgba(255,255,255,0.6), inset 0 -4px 8px rgba(0,0,0,0.8), 0 10px 22px rgba(245,158,11,0.5);
    z-index: 10;
}
.hair-swatch-3d span {
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    color: white;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 5px;
    border-radius: 6px;
    pointer-events: none;
    border: 1px solid rgba(255,255,255,0.15);
}
.hair-swatch-3d.selected {
    border: 3px solid #fbbf24;
    box-shadow: inset 0 3px 6px rgba(255,255,255,0.8), inset 0 -4px 8px rgba(0,0,0,0.9), 0 0 20px rgba(251,191,36,0.8);
    transform: scale(1.12);
    z-index: 5;
}

/* ========== MAKEUP TOOLBAR ========== */
.makeup-toolbar {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 16px;
    backdrop-filter: blur(12px);
    scrollbar-width: none;
}
.makeup-toolbar::-webkit-scrollbar { display: none; }
.makeup-tool-btn {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #d1d5db;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.makeup-tool-btn:hover {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #fef08a;
}
.makeup-tool-btn.active {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #000;
    font-weight: 900;
    border-color: #fef08a;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* ========== FLOATING TOPUP ========== */
#floatingTopupBtn {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 998;
    background: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728);
    color: #000;
    font-weight: 900;
    padding: 12px 10px;
    border-top-left-radius: 16px;
    border-bottom-left-radius: 16px;
    box-shadow: -4px 0 20px rgba(179, 135, 40, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-right: none;
}
#floatingTopupBtn:hover {
    padding-right: 16px;
    box-shadow: -6px 0 25px rgba(252, 246, 186, 0.8);
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }
::-webkit-scrollbar-thumb { background: rgba(212, 175, 55, 0.4); border-radius: 10px; }

/* ========== CHAT ========== */
@keyframes bubbleFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.chat-bubble { animation: bubbleFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards; }
.safe-wrap {
    word-wrap: break-word !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    white-space: pre-wrap !important;
    max-width: 100%;
}
#avatarMessages, #expertChatBox { scroll-behavior: smooth; }

/* ========== MODAL ========== */
.custom-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
}
.custom-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}
.custom-modal-box {
    background: #0a0716;
    border: 2px solid #bf953f;
    border-radius: 24px;
    padding: 30px;
    max-width: 450px;
    width: 100%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    transform: translateY(-20px);
    transition: all 0.3s ease;
}
.custom-modal-overlay.active .custom-modal-box { transform: translateY(0); }

/* ========== CAMERA ========== */
.camera-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border: 2px solid rgba(245, 158, 11, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 20;
    display: none;
}
.camera-crosshair::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 4px;
    height: 4px;
    background: #fbbf24;
    border-radius: 50%;
}

/* ========== AVATAR CHAT ========== */
#avatarChatWindow {
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
    transform: translateY(120%) scale(0.95);
    opacity: 0;
    pointer-events: none;
    display: flex;
}
#avatarChatWindow.active-chat {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* ========== DYNAMIC BG ========== */
#dynamic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #070114;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    z-index: -2;
    transition: background-image 1s ease-in-out;
}
#dynamic-bg-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, rgba(7, 1, 20, 0.5) 0%, rgba(20, 2, 10, 0.4) 50%, rgba(2, 10, 20, 0.5) 100%);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: -1;
}

/* ========== SKIN ANALYSIS ========== */
.skin-analysis-result {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 16px;
    padding: 16px;
    margin-top: 12px;
    transition: all 0.3s ease;
}
.skin-analysis-result .color-swatch {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.15);
    margin: 0 4px;
    vertical-align: middle;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.skin-analysis-result .recommendation-tag {
    display: inline-block;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.25);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 700;
    margin: 4px 4px 4px 0;
    color: #fef08a;
}