:root {
    --gold-primary: #d4af37;
    --gold-light: #fcf6ba;
    --gold-dark: #aa771c;
    --brown-text: #4a2c0f;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --danger: #ef4444;
    --success: #10b981;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Cairo', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    min-height: 100vh;
    overflow-x: hidden;
}

/* =========================================
   1. أيقونة المعرض الذهبية بلمعان قوس قزح
   ========================================= */
.launcher-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at center, #1e293b 0%, #090d16 100%);
    padding: 20px;
    text-align: center;
}

.gold-rainbow-sticker {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 22px 55px;
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--brown-text);
    background: linear-gradient(135deg, #bf953f 0%, #fcf6ba 25%, #b38728 50%, #fbf5b7 75%, #aa771c 100%);
    border: 4px solid #fff8dc;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 15px 35px rgba(212, 175, 55, 0.4), inset 0 0 15px rgba(255, 255, 255, 0.8);
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    user-select: none;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.7);
}

/* طبقة لمعان قوس قزح الهولوجرافية */
.gold-rainbow-sticker::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        rgba(255, 0, 0, 0) 20%,
        rgba(255, 0, 128, 0.35) 35%,
        rgba(255, 255, 0, 0.35) 45%,
        rgba(0, 255, 128, 0.35) 55%,
        rgba(0, 128, 255, 0.35) 65%,
        rgba(255, 0, 0, 0) 80%
    );
    transform: rotate(30deg);
    animation: rainbowShine 3.5s infinite linear;
    pointer-events: none;
    mix-blend-mode: overlay;
}

/* لمعة إضافية */
.gold-rainbow-sticker::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.85), transparent);
    transform: skewX(-25deg);
    animation: glint 4s infinite ease-in-out;
    pointer-events: none;
}

@keyframes rainbowShine {
    0% { transform: translateX(-30%) translateY(-30%) rotate(25deg); }
    50% { transform: translateX(30%) translateY(30%) rotate(25deg); }
    100% { transform: translateX(-30%) translateY(-30%) rotate(25deg); }
}

@keyframes glint {
    0%, 60% { left: -100%; }
    100% { left: 200%; }
}

.gold-rainbow-sticker:hover {
    transform: scale(1.08) rotate(-1deg);
    box-shadow: 0 20px 45px rgba(212, 175, 55, 0.65), 0 0 25px rgba(255, 215, 0, 0.5);
}

.gold-rainbow-sticker:active {
    transform: scale(0.97);
}

/* =========================================
   2. واجهة المعرض الرئيسية
   ========================================= */
#gallery-app {
    display: none;
    max-width: 1300px;
    margin: 0 auto;
    padding: 20px;
    animation: fadeIn 0.4s ease;
}

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

header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    padding: 15px 25px;
    border-radius: 16px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    margin-bottom: 25px;
    gap: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-title h1 {
    font-size: 1.5rem;
    background: linear-gradient(to left, #fcf6ba, #d4af37);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    cursor: pointer;
    border: none;
    border-radius: 10px;
    padding: 9px 16px;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-gold {
    background: linear-gradient(135deg, #d4af37, #aa771c);
    color: #fff;
}
.btn-gold:hover { filter: brightness(1.15); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--gold-primary);
    color: var(--gold-light);
}
.btn-outline:hover { background: rgba(212, 175, 55, 0.15); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }

.btn-secondary { background: #334155; color: white; }
.btn-secondary:hover { background: #475569; }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; border-radius: 6px; }

/* شريط التنقل (Breadcrumbs) */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    background: rgba(30, 41, 59, 0.6);
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 0.95rem;
}

.breadcrumb span {
    cursor: pointer;
    color: var(--gold-light);
}
.breadcrumb span:hover { text-decoration: underline; }
.breadcrumb .current { color: var(--text-muted); cursor: default; text-decoration: none; }

/* =========================================
   3. بطاقات الأقسام والمجموعات
   ========================================= */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
    gap: 25px;
}

.section-card, .group-card {
    background: linear-gradient(145deg, #1e293b, #151e2e);
    border: 2px solid rgba(212, 175, 55, 0.35);
    border-radius: 18px;
    padding: 25px;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 10px 20px rgba(0,0,0,0.25);
}

.section-card:hover, .group-card:hover {
    transform: translateY(-6px);
    border-color: var(--gold-primary);
    box-shadow: 0 15px 30px rgba(212, 175, 55, 0.2);
}

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

.card-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--gold-light);
    margin-bottom: 8px;
}

.card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge-video {
    position: absolute;
    top: 15px;
    left: 15px;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: white;
    font-size: 0.75rem;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: bold;
}

/* =========================================
   4. إطارات الصور المزينة الأنيقة
   ========================================= */
.gallery-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
}

/* الإطار المزخرف الفاخر */
.ornate-frame-wrapper {
    background: #161f30;
    border-radius: 16px;
    padding: 14px;
    position: relative;
    /* إطار مزدوج مزين */
    border: 3px solid var(--gold-primary);
    box-shadow: 
        0 0 0 4px #1e293b,
        0 0 0 6px rgba(212, 175, 55, 0.45),
        0 15px 35px rgba(0, 0, 0, 0.45);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.ornate-frame-wrapper:hover {
    transform: translateY(-5px);
}

/* زوايا زخرفية للإطار */
.ornate-frame-wrapper::before,
.ornate-frame-wrapper::after {
    content: '✦';
    position: absolute;
    color: var(--gold-light);
    font-size: 1.1rem;
    z-index: 2;
    text-shadow: 0 0 5px #000;
}
.ornate-frame-wrapper::before { top: 4px; right: 7px; }
.ornate-frame-wrapper::after { top: 4px; left: 7px; }

.media-box {
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(252, 246, 186, 0.3);
    background: #090d16;
    cursor: pointer;
}

.media-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.ornate-frame-wrapper:hover .media-box img {
    transform: scale(1.06);
}

/* زر تشغيل الفيديو فوق شاشة الفيديو */
.video-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.media-box:hover .video-play-overlay {
    background: rgba(0, 0, 0, 0.2);
}

.play-circle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4af37, #aa771c);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.8);
    border: 2px solid #fff;
}

.platform-tag {
    margin-top: 8px;
    background: rgba(0,0,0,0.75);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    color: var(--gold-light);
}

.item-details {
    padding: 15px 5px 5px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.item-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold-light);
    margin-bottom: 6px;
}

.item-desc {
    font-size: 0.9rem;
    color: #cbd5e1;
    line-height: 1.5;
    margin-bottom: 12px;
    flex-grow: 1;
}

.item-link-hint {
    font-size: 0.8rem;
    color: var(--gold-primary);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    font-weight: 600;
}

/* =========================================
   5. أدوات الإداري (تظهر فقط بعد تسجيل الدخول)
   ========================================= */
.admin-controls {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed rgba(255,255,255,0.15);
    flex-wrap: wrap;
}

.admin-banner {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.2), rgba(212, 175, 55, 0.2));
    border: 1px solid var(--success);
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* =========================================
   6. النوافذ المنبثقة (Modals)
   ========================================= */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-box {
    background: var(--bg-card);
    border: 2px solid var(--gold-primary);
    border-radius: 18px;
    width: 100%;
    max-width: 520px;
    padding: 25px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.6);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-box.video-modal {
    max-width: 850px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.modal-header h3 {
    color: var(--gold-light);
}

.close-modal {
    background: transparent;
    color: var(--text-muted);
    font-size: 1.5rem;
    padding: 0 5px;
}

.form-group {
    margin-bottom: 15px;
}

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #475569;
    background: #0f172a;
    color: white;
    font-size: 0.95rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--gold-primary);
}

.file-upload-box {
    border: 2px dashed var(--gold-primary);
    padding: 15px;
    text-align: center;
    border-radius: 10px;
    background: rgba(212, 175, 55, 0.05);
    cursor: pointer;
    margin-bottom: 10px;
}

.video-player-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.video-player-container iframe,
.video-player-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 16px;
    border: 1px dashed #475569;
    color: var(--text-muted);
    grid-column: 1 / -1;
}

/* =========================================
   7. الإضافات الجديدة
   ========================================= */
header.app-header {
    position: sticky;
    top: 8px;
    z-index: 50;
}

.btn-back {
    background: linear-gradient(135deg, #d4af37, #aa771c);
    color: #fff;
    padding: 7px 14px;
    font-size: 0.9rem;
}
.btn-back:hover { filter: brightness(1.15); }
.btn-back:disabled { opacity: .5; cursor: default; }

.sync-status {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.sync-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}
.sync-status.syncing .sync-dot { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; animation: pulse 1s infinite; }
.sync-status.offline .sync-dot { background: var(--danger); box-shadow: 0 0 6px var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

.toast-wrap {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: calc(100% - 30px);
    max-width: 460px;
}
.toast {
    background: #0b1220;
    border: 1px solid var(--gold-primary);
    color: var(--gold-light);
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0,0,0,.5);
    animation: fadeIn .25s ease;
    text-align: center;
}
.toast.error { border-color: var(--danger); color: #fecaca; }
.toast.success { border-color: var(--success); color: #bbf7d0; }

.update-banner {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 4000;
    background: linear-gradient(90deg, #d4af37, #aa771c);
    color: #fff;
    text-align: center;
    padding: 10px;
    font-weight: 700;
    display: none;
}

#confirm-modal { z-index: 1100; }
.confirm-warning {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 15px;
    color: #fecaca;
    font-size: 0.92rem;
    line-height: 1.7;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions button { flex: 1; justify-content: center; }
.field-error { color: var(--danger); font-size: .85rem; margin-bottom: 10px; display: none; }

.upload-status {
    font-size: 0.85rem;
    margin: 8px 0;
    padding: 8px 12px;
    border-radius: 8px;
    display: none;
}
.upload-status.loading { display: block; background: rgba(245,158,11,.12); color: #fde68a; border: 1px solid rgba(245,158,11,.4); }
.upload-status.error { display: block; background: rgba(239,68,68,.12); color: #fecaca; border: 1px solid rgba(239,68,68,.4); }

.link-result {
    display: none;
    background: rgba(16,185,129,.1);
    border: 1px solid rgba(16,185,129,.5);
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: .85rem;
}
.link-result .link-row { display: flex; gap: 6px; margin-top: 6px; }
.link-result input { direction: ltr; text-align: left; font-size: .8rem; }

.loading-screen {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    #gallery-app { padding: 12px; }
    header.app-header { padding: 12px; }
    .header-title h1 { font-size: 1.15rem; }
}

.launcher-logo {
    width: min(220px, 55vw);
    height: auto;
    margin-bottom: 28px;
    border-radius: 50%;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.35);
}
.header-logo { width: 38px; height: 38px; border-radius: 50%; }

/* =========================================
   8. أيقونات نسخ الروابط
   ========================================= */
.copy-link-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    right: auto;
    z-index: 3;
    width: 34px;
    height: 34px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.05rem;
    background: rgba(15, 23, 42, 0.75);
    border: 1px solid rgba(212, 175, 55, 0.6);
    color: var(--gold-light);
    backdrop-filter: blur(4px);
}
.copy-link-btn:hover { background: var(--gold-primary); color: #1a1205; transform: scale(1.08); }
.copy-link-btn.copied { background: var(--success); border-color: var(--success); color: #fff; }

.breadcrumb { flex-wrap: wrap; }
.copy-page-btn {
    margin-inline-start: auto;
    background: transparent;
    border: 1px solid var(--gold-primary);
    color: var(--gold-light);
    padding: 5px 12px;
    font-size: 0.82rem;
    border-radius: 20px;
}
.copy-page-btn:hover { background: rgba(212, 175, 55, 0.18); }
.copy-page-btn.copied { background: var(--success); border-color: var(--success); color: #fff; }

.group-card .badge-video { left: 54px; top: 14px; }
.toast-wrap .toast:nth-child(n+3) { display: none; }
