/* إخفاء شريط التمرير */
::-webkit-scrollbar { display: none; }
html { -ms-overflow-style: none; scrollbar-width: none; }

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

body {
    font-family: 'AAGalaxy', sans-serif;
    background: radial-gradient(circle at top center, #1e3a8a 0%, #0f172a 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: -1;
}

/* تحديث تنسيق الخزنة لاستخدام الصور */
.treasure-chest {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
    position: relative;
    /* إزالة الخلفية المتدرجة والحدود */
    background: transparent; 
    border: none;
    box-shadow: none;
    padding: 0;
    overflow: hidden; /* لضمان عدم خروج الصورة */
    height: 100%; /* يجب تحديد ارتفاع للتحكم في أبعاد الصورة */
    aspect-ratio: 1 / 1; /* جعلها مربع */
}

/* إخفاء العناصر الزخرفية السابقة غير المستخدمة */
.treasure-chest::before,
.treasure-chest::after {
    content: none !important;
}

.treasure-chest:hover {
    transform: translateY(-8px) scale(1.08) rotateX(5deg);
    box-shadow: 0 15px 30px rgba(0,0,0,0.4), 0 0 20px rgba(255,215,0,0.3);
}

.treasure-chest-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.4s;
}

.treasure-chest.opened .treasure-chest-image {
    /* لجعل الصورة تبدو "مفتوحة" أو "غير نشطة"، سنقلل التعتيم */
    opacity: 0.5;
    filter: grayscale(80%);
}

/* نحتاج لتعديل أبعاد شبكة الخزائن لضمان ظهور الصور بشكل صحيح */
#treasureGrid {
    display: grid;
    grid-template-columns: repeat(10, 1fr); 
    gap: 0.5rem;
    padding-bottom: 2rem;
}

/* تحسين التجاوب مع الشاشات المختلفة */
@media (max-width: 1024px) {
    #treasureGrid {
        grid-template-columns: repeat(8, 1fr); 
    }
}

@media (max-width: 768px) {
    #treasureGrid {
        grid-template-columns: repeat(6, 1fr); 
        gap: 0.4rem;
    }
    .treasure-chest:hover {
        transform: none; /* إلغاء التأثيرات القوية على اللمس */
    }
}

@media (max-width: 550px) {
    #treasureGrid {
        grid-template-columns: repeat(5, 1fr); 
        gap: 0.3rem;
    }
}

@media (max-width: 400px) {
    #treasureGrid {
        grid-template-columns: repeat(4, 1fr); 
    }
}

@media (max-width: 340px) {
    #treasureGrid {
        grid-template-columns: repeat(3, 1fr); 
    }
}

/* بقية التنسيقات (wave-animation, ship-container, etc.) تبقى كما هي */
.wave-animation {
    animation: wave 3s ease-in-out infinite;
}

@keyframes wave {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

.ship-container {
    position: relative;
    background: linear-gradient(135deg, rgba(30, 58, 138, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 1px solid rgba(56, 189, 248, 0.3);
    box-shadow: 
        0 20px 40px rgba(0,0,0,0.4),
        inset 0 1px 0 rgba(255,255,255,0.1);
    backdrop-filter: blur(12px);
}

/* إخفاء القارب القديم */
.ship-container::before {
    content: none; 
}

.points-animation {
    animation: pointsFloat 2.5s ease-out forwards;
}

@keyframes pointsFloat {
    0% { 
        transform: translateY(0) scale(1) rotate(0deg); 
        opacity: 1; 
    }
    50% { 
        transform: translateY(-30px) scale(1.1) rotate(5deg); 
        opacity: 0.8; 
    }
    100% { 
        transform: translateY(-60px) scale(1.3) rotate(10deg); 
        opacity: 0; 
    }
}

.slide-in {
    animation: slideIn 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

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

.pulse-glow {
    animation: pulseGlow 2.5s infinite;
}

@keyframes pulseGlow {
    0%, 100% { 
        box-shadow: 
            0 0 20px rgba(6,182,212,0.5),
            0 0 40px rgba(14,165,233,0.3); 
    }
    50% { 
        box-shadow: 
            0 0 30px rgba(6,182,212,0.8),
            0 0 60px rgba(14,165,233,0.5); 
    }
}

.ocean-waves {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 300px;
    background: radial-gradient(ellipse at bottom center, rgba(6,182,212,0.15) 0%, transparent 70%);
    z-index: -1;
    animation: none;
    pointer-events: none;
}

@keyframes oceanWave {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* تنسيق قائمة الإعدادات والنوافذ المنبثقة */
.settings-container, .modal-container {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-card, .modal-card {
    max-width: 400px;
    width: 90%;
    padding: 24px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1e40af 0%, #0ea5e9 100%);
    border: 2px solid #0284c7;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.settings-container.active .settings-card, .modal-container.active .modal-card {
    transform: scale(1);
    opacity: 1;
}

/* تنسيق زر الإلغاء الجديد في شاشة الخزنة */
.close-button {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(255, 0, 0, 0.6);
    color: white;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}
.close-button:hover {
    background: rgba(255, 0, 0, 0.8);
}

/* Ensure SweetAlert is always on top */
.swal2-container {
    z-index: 10000 !important;
}

/* --- New UI Styles --- */

/* Mission Card Style */
.mission-card {
    background: rgba(15, 23, 42, 0.4);
    border: 2px solid rgba(251, 191, 36, 0.5);
    border-radius: 12px;
    padding: 20px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.mission-card::before {
    content: '';
    position: absolute;
    top: -5px; left: -5px; right: -5px; bottom: -5px;
    border: 1px dashed #fbbf24;
    border-radius: 16px;
    pointer-events: none;
    opacity: 0.5;
}

/* Team Selection Grid */
.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}
.team-card-select {
    background: rgba(30, 41, 59, 0.8);
    border: 2px solid #475569;
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}
.team-card-select:hover {
    transform: translateY(-3px);
    border-color: #94a3b8;
}
.team-card-select.selected {
    border-color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    box-shadow: 0 0 15px rgba(251, 191, 36, 0.3);
}
.team-card-select.selected::after {
    content: '✓';
    position: absolute;
    top: 5px;
    right: 5px;
    background: #fbbf24;
    color: #000;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
}
.team-card-select img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin-bottom: 8px;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}
.team-card-select span {
    font-size: 10px;
    font-weight: bold;
    color: #e2e8f0;
    text-align: center;
}

/* Smart Stepper */
.stepper-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(15, 23, 42, 0.6);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid #334155;
    max-width: 280px;
    margin: 0 auto;
}
.stepper-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, filter 0.2s;
    box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.stepper-btn:active {
    transform: scale(0.95);
}
.stepper-btn.minus {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}
.stepper-btn.plus {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.stepper-display {
    flex: 1;
    text-align: center;
    font-size: 28px;
    font-weight: 800;
    color: white;
    background: transparent;
    border: none;
    font-family: 'Courier New', monospace;
    width: 80px;
}

/* 3D Action Buttons */
.btn-3d {
    transition: all 0.1s;
    position: relative;
    top: 0;
    box-shadow: 0 5px 0 rgba(0,0,0,0.2);
}
.btn-3d:active {
    top: 3px;
    box-shadow: 0 2px 0 rgba(0,0,0,0.2);
}

/* تحسينات عامة للتجاوب في شاشات الجوال */
@media (max-width: 640px) {
    .ship-container {
        padding: 0.75rem; /* تقليل الحواف */
    }
    
    /* تصغير أيقونة الخزنة الكبيرة */
    #treasureIcon {
        font-size: 4rem !important; 
        margin-bottom: 0.5rem !important;
    }
    
    /* تصغير العناوين */
    #treasureTitle {
        font-size: 1.5rem !important;
    }
    
    /* جعل الأزرار تأخذ العرض الكامل */
    .btn-3d {
        width: 100%;
        margin-bottom: 0.5rem;
        padding: 1rem !important;
    }
    
    /* تحسين عرض بطاقة المهمة */
    .mission-card {
        padding: 15px !important;
    }
    
    #treasureContent {
        font-size: 1rem !important;
    }
    
    /* تحسين عرض العداد */
    .stepper-container {
        width: 100%;
        max-width: 100%;
    }
    
    /* إخفاء بعض الزخارف الثقيلة */
    .ocean-waves {
        height: 150px;
    }
}

@font-face {
    font-family: 'AAGalaxy';
    src: url('../../fonts/AA-GALAXY.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* --- 3D Interactive Card Preview --- */
.preview-card-3d-scene {
    perspective: 1000px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.preview-card-3d-wrapper {
    position: relative;
    width: 200px;
    height: 290px;
    cursor: pointer;
    perspective: 1000px;
}

.preview-card-3d {
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.8) 0%, rgba(15, 23, 42, 0.95) 100%);
    border: 2px solid rgba(251, 191, 36, 0.25);
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.5),
        0 0 15px rgba(251, 191, 36, 0.05);
    padding: 16px;
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out, box-shadow 0.3s ease, border-color 0.3s ease;
    overflow: hidden;
}

/* طبقة اللمعان الجذابة */
.preview-card-3d .card-glare {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    background: radial-gradient(
        circle 120px at var(--glare-x, 50%) var(--glare-y, 50%),
        rgba(255, 255, 255, 0.18) 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%
    );
    mix-blend-mode: overlay;
    transition: opacity 0.3s ease;
}

/* تأثير التفاعل وحركة الطفو */
.preview-card-3d:hover {
    box-shadow: 
        0 20px 40px rgba(0, 0, 0, 0.7),
        0 0 25px rgba(251, 191, 36, 0.25);
    border-color: rgba(251, 191, 36, 0.6);
}

.preview-card-3d:hover .card-glare {
    opacity: 1;
}

/* تأثير preserve-3d على العناصر الفرعية */
.preview-card-3d .card-tag {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 8px;
    font-weight: bold;
    border: 1px solid rgba(251, 191, 36, 0.3);
    transform: translateZ(20px);
}

.preview-card-3d .card-safe-number {
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    font-family: monospace;
    font-weight: bold;
    transform: translateZ(20px);
}

.preview-card-3d .card-icon-container {
    transform: translateZ(35px);
    transition: transform 0.2s ease;
}

.preview-card-3d h4 {
    transform: translateZ(25px);
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.6);
}

.preview-card-3d p {
    transform: translateZ(20px);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.preview-card-3d #previewEffect {
    transform: translateZ(30px);
}

/* حركة بطيئة وخفيفة للأيقونة */
.animate-bounce-slow {
    animation: bounceSlow 3s ease-in-out infinite;
}

@keyframes bounceSlow {
    0%, 100% {
        transform: translateY(0) translateZ(35px);
    }
    50% {
        transform: translateY(-6px) translateZ(35px);
    }
}

/* --- Premium Custom Editor Inputs --- */
.glass-input {
    background: rgba(15, 23, 42, 0.7) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 12px !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    color: #fff !important;
    outline: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.glass-input:focus {
    border-color: #fbbf24 !important;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.1),
        0 0 15px rgba(251, 191, 36, 0.2) !important;
    background: rgba(15, 23, 42, 0.85) !important;
}

.editor-card-section {
    background: rgba(30, 41, 59, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(8px);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.editor-card-section:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.glass-btn-quick {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
}

.glass-btn-quick:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-1px);
}

.glass-btn-quick:active {
    transform: translateY(1px);
}

/* تنسيق مخصص للتصنيفات الأربعة مع التوهج */
.category-card {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.category-card:hover {
    background: rgba(15, 23, 42, 0.6);
    transform: translateY(-2px);
    border-color: rgba(255, 255, 255, 0.15);
}

/* المؤشرات النشطة المتوهجة للمجموعات الأربعة */
input[name="contentType"][value="bonus"]:checked + .category-card {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.08);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15), inset 0 0 8px rgba(16, 185, 129, 0.1);
}

input[name="contentType"][value="penalty"]:checked + .category-card {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.15), inset 0 0 8px rgba(239, 68, 68, 0.1);
}

input[name="contentType"][value="gift"]:checked + .category-card {
    border-color: #0ea5e9;
    background: rgba(14, 165, 233, 0.08);
    box-shadow: 0 0 15px rgba(14, 165, 233, 0.15), inset 0 0 8px rgba(14, 165, 233, 0.1);
}

input[name="contentType"][value="other"]:checked + .category-card {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.08);
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.15), inset 0 0 8px rgba(168, 85, 247, 0.1);
}

/* منصة عرض المعاينة ثلاثية الأبعاد */
.preview-stand-base {
    background: radial-gradient(circle at bottom center, rgba(251, 191, 36, 0.08) 0%, transparent 70%);
    position: relative;
    border-radius: 24px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.3);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Control Panel Modal Tabs --- */
.control-tab-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.control-tab-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
}

.control-tab-btn.active {
    color: #fbbf24; /* amber-400 (Gold) */
    background: rgba(251, 191, 36, 0.1) !important;
    border: 1px solid rgba(251, 191, 36, 0.25) !important;
    box-shadow: inset 0 1px 0 rgba(251, 191, 36, 0.15);
}

.control-tab-content.hidden {
    display: none !important;
}
