:root {
    --bg: #000000;
    --surface: #1a1a1a;
    --text: #ffffff;
    --text-light: #aaaaaa;
    --accent: #00ff88;
    --accent-glow: rgba(0, 255, 136, 0.25);
    --border: #2a2a2a;
    --radius: 16px;
    --card-radius: 20px;
    --transition: 0.2s ease;
    --ios-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
    width: 100%;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--ios-font);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 20px;
}

header, footer {
    background: #0a0a0a;
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
}

header {
    padding: 1rem;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
}

.site-name {
    font-family: Arial, sans-serif;
    font-size: 2.5rem;
    font-weight: bold;
    color: #00ff88;
    text-shadow: 0 0 10px var(--accent-glow);
    letter-spacing: 4px;
    margin: 0;
}

.main-nav {
    display: flex;
    gap: 0.6rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    justify-content: center;
    padding: 0.3rem 0;
    width: 100%;
}

.main-nav::-webkit-scrollbar { display: none; }

.main-nav a {
    color: #aaa;
    text-decoration: none;
    font-weight: 600;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    transition: 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.main-nav a.active {
    background: var(--accent);
    color: #000;
}

.main-nav a .material-symbols-outlined { font-size: 1.1rem; }

.header-stats {
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
    justify-content: center;
}

/* شريط البحث */
.search-bar {
    padding: 0.8rem 1rem;
    margin: 0 auto;
    max-width: 600px;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-bar input {
    flex: 1;
    padding: 0.8rem 2.5rem 0.8rem 2.5rem;
    background: #1c1c1e;
    border: 1px solid var(--border);
    border-radius: 30px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    min-width: 0;
}

.search-icon {
    position: absolute;
    right: 4.2rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 1;
}

.clear-search {
    position: absolute;
    left: 4.2rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.4rem;
    cursor: pointer;
    display: none;
    line-height: 1;
    padding: 0.3rem;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
    z-index: 1;
}

.clear-search:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.clear-search.visible { display: block; }

.items-select {
    background: #1c1c1e;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: #fff;
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    outline: none;
    cursor: pointer;
    appearance: none;
    flex-shrink: 0;
}

.toggle-view-btn {
    background: #1c1c1e;
    border: 1px solid var(--border);
    color: #fff;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.toggle-view-btn:hover { background: #333; }

/* آخر الإضافات */
.latest-section { padding: 0 1rem 1rem; width: 100%; }

.latest-scroll {
    display: flex;
    gap: 0.8rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
    width: 100%;
}

.latest-card {
    min-width: 110px;
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 0.7rem;
    text-align: center;
    border: 1px solid var(--border);
    scroll-snap-align: start;
    transition: transform 0.2s;
    flex-shrink: 0;
}
.latest-card:hover { transform: scale(0.97); }
.latest-card img {
    width: 50px; height: 50px;
    border-radius: 12px;
    object-fit: cover;
}

/* البطاقات */
main {
    flex: 1;
    width: 100%;
    max-width: 100%;
    padding: 0;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.2rem;
    padding: 0 1rem;
    width: 100%;
}

.cards-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0 1rem;
}

.cards-container.list-view .card {
    flex-direction: row;
    text-align: right;
    padding: 1rem;
    gap: 1rem;
}

.cards-container.list-view .card img:first-child {
    width: 60px; height: 60px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: 0 8px 20px rgba(0,255,136,0.15);
}

.card img:first-child {
    width: 80px; height: 80px;
    border-radius: 22px;
    object-fit: cover;
    margin-bottom: 0.8rem;
    max-width: 100%;
}

.new-badge {
    position: absolute;
    top: 10px; right: 10px;
    background: #ff3b30;
    color: white;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    z-index: 1;
}

.card-tag {
    position: absolute;
    top: 10px; left: 10px;
    background: var(--accent);
    color: #000;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    z-index: 1;
}

.card-info {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 0.2rem 0;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.download-btn, .share-btn {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85rem;
    text-decoration: none;
    background: var(--accent);
    color: #000;
    border: none;
    cursor: pointer;
    transition: 0.2s;
}

.share-btn { background: #2a2a2a; color: #fff; }
.share-btn:hover { background: #3a3a3a; }

/* الترقيم */
.pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    padding: 0 1rem;
}

.pagination button {
    background: #2a2a2a;
    border: 1px solid var(--border);
    color: white;
    padding: 0.4rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    min-width: 2.5rem;
}

.pagination button.active { background: var(--accent); color: #000; }

footer {
    text-align: center;
    padding: 1.5rem;
    margin-top: 2rem;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.social-links a {
    color: var(--accent);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
}

/* رسالة BETA */
.beta-bar {
    display: none;
    background: #ff3b30;
    color: white;
    text-align: center;
    padding: 0.4rem;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 20;
    font-size: 0.8rem;
}

@media (max-width: 767px) {
    .beta-bar { display: block; }
}

/* Cookie Consent */
.cookie-bar {
    position: fixed;
    bottom: 40px;
    left: 0;
    right: 0;
    background: #141414;
    color: white;
    padding: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    gap: 0.5rem;
}

.cookie-bar button {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 0.4rem 1rem;
    border-radius: 15px;
    cursor: pointer;
    white-space: nowrap;
}

/* تحذير PC */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal-overlay.visible { display: flex; }

.ios-alert {
    background: #1c1c1e;
    border-radius: 20px;
    padding: 2rem;
    max-width: 320px;
    width: 90%;
    text-align: center;
}

.alert-icon { font-size: 40px; }
.ios-alert h2 { color: #ff3b30; margin: 0.5rem 0; }
.ios-btn {
    background: #ff3b30;
    color: white;
    border: none;
    padding: 0.6rem 2rem;
    border-radius: 20px;
    margin-top: 1rem;
    cursor: pointer;
    font-size: 1rem;
}

/* Skeleton Loading */
.skeleton-card {
    background: #1a1a1a;
    border-radius: var(--card-radius);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid #2a2a2a;
    position: relative;
    overflow: hidden;
}

.skeleton-img {
    width: 80px;
    height: 80px;
    border-radius: 22px;
    background: #2a2a2a;
    margin-bottom: 0.8rem;
}

.skeleton-line {
    height: 14px;
    background: #2a2a2a;
    border-radius: 8px;
    margin: 0.4rem 0;
    width: 80%;
}

.skeleton-line.short { width: 50%; }

.skeleton-card::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.03), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* زر العودة للأعلى */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 20px;
    background: var(--accent);
    color: #000;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(0,255,136,0.3);
    display: none;
    z-index: 40;
    justify-content: center;
    align-items: center;
}

.back-to-top.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== تحسينات الهاتف ========== */
@media (max-width: 767px) {
    .site-name { font-size: 2rem; }

    .main-nav a {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

    .search-bar input {
        font-size: 0.9rem;
        padding: 0.7rem 2.2rem 0.7rem 2.2rem;
    }

    .cards-container {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 0 0.8rem;
    }

    .card { padding: 1.2rem; }
    .card img:first-child { width: 70px; height: 70px; }
    .card h3 { font-size: 1rem; }
    .card p { font-size: 0.8rem; }

    .download-btn, .share-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    footer { padding: 1rem; font-size: 0.85rem; }
    .back-to-top { bottom: 40px; right: 15px; width: 40px; height: 40px; }
    .cookie-bar {
        flex-direction: column;
        text-align: center;
        bottom: 35px;
        font-size: 0.8rem;
    }
    .latest-card { min-width: 95px; }
}