/* ═══════════════════════════════════════════════
   Flavor Apps Theme — APKPure-Style CSS
   ═══════════════════════════════════════════════ */

:root {
    --primary: #00c853;
    --primary-dark: #00a844;
    --primary-light: #e8f5e9;
    --bg: #f5f5f5;
    --card: #ffffff;
    --text: #212121;
    --text-light: #757575;
    --border: #e0e0e0;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, -apple-system, 'Noto Sans Arabic', sans-serif; background: var(--bg); color: var(--text); line-height: 1.7; font-size: 15px; }
body.rtl { direction: rtl; }
a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; height: auto; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ═══ HEADER ═══ */
.site-header { background: var(--card); box-shadow: var(--shadow); position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; gap: 20px; padding: 12px 0; }
.header-logo a { display: flex; align-items: center; }
.header-logo img { height: 36px; }
.logo-text { font-size: 22px; font-weight: 800; color: var(--primary-dark); }
.header-search { flex: 1; max-width: 500px; }
.search-wrapper { position: relative; }
.search-wrapper input { width: 100%; padding: 10px 16px; border: 2px solid var(--border); border-radius: 24px; font-size: 14px; outline: none; background: var(--bg); }
.search-wrapper input:focus { border-color: var(--primary); }
.search-btn { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 18px; cursor: pointer; }
body.rtl .search-btn { left: auto; right: 8px; }
.search-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: var(--card); border-radius: var(--radius); box-shadow: 0 4px 20px rgba(0,0,0,0.15); display: none; z-index: 200; max-height: 400px; overflow-y: auto; }
.search-dropdown.active { display: block; }
.search-dropdown .search-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid #f5f5f5; color: var(--text); }
.search-dropdown .search-item:hover { background: var(--primary-light); }
.search-dropdown .search-item img { width: 40px; height: 40px; border-radius: 10px; }
.search-dropdown .search-item .search-item-title { font-weight: 600; }
.search-dropdown .search-item .search-item-cat { font-size: 12px; color: var(--text-light); }
.header-nav ul { display: flex; gap: 5px; list-style: none; }
.header-nav a { padding: 8px 14px; border-radius: 8px; color: var(--text); font-weight: 500; font-size: 14px; }
.header-nav a:hover { background: var(--primary-light); color: var(--primary-dark); }
.header-nav.mobile-open { display: block !important; position: absolute; top: 100%; left: 0; right: 0; background: var(--card); box-shadow: 0 4px 20px rgba(0,0,0,0.12); padding: 10px; z-index: 200; }
.header-nav.mobile-open ul { flex-direction: column; }
.header-nav.mobile-open a { display: block; padding: 12px 16px; }
.mobile-menu-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }

/* ═══ BREADCRUMBS ═══ */
.apk-breadcrumbs { padding: 14px 0; font-size: 13px; color: #999; }
.apk-breadcrumbs a { color: var(--primary-dark); }
.apk-breadcrumbs a:hover { text-decoration: underline; }
.apk-breadcrumbs span { margin: 0 4px; }
.apk-breadcrumbs .current { color: #666; }
.breadcrumbs { padding: 12px 0; font-size: 13px; color: var(--text-light); }
.breadcrumbs a { color: var(--text-light); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs span { margin: 0 6px; }

/* ═══════════════════════════════════════════════
   SINGLE APP PAGE — APKPure Layout
   ═══════════════════════════════════════════════ */

/* --- App Header --- */
.apk-app-header {
    background: var(--card);
    padding: 30px 20px;
    border-bottom: 1px solid #eee;
}
.apk-app-header-inner {
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    max-width: 900px;
    margin: 0 auto;
    gap: 30px;
}
.apk-app-info-side {
    flex: 1 1 auto;
    min-width: 0;
    order: 2;
}
.apk-app-icon-side {
    flex: 0 0 auto;
    order: 3;
}
body.rtl .apk-app-info-side { order: 3; }
body.rtl .apk-app-icon-side { order: 2; }

.apk-main-icon {
    width: 180px;
    height: 180px;
    border-radius: 24px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    display: block;
    object-fit: cover;
}
.apk-share-btn {
    width: 36px; height: 36px;
    border: 1px solid #ddd; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    color: #999; cursor: pointer; margin-bottom: 12px;
}
.apk-share-btn:hover { border-color: var(--primary); color: var(--primary); }
.apk-app-title {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
}
.apk-developer { margin-bottom: 2px; }
.apk-developer a { color: var(--primary-dark); font-size: 15px; font-weight: 500; }
.apk-developer a:hover { text-decoration: underline; }
.apk-date { color: #999; font-size: 13px; margin-top: 4px; margin-bottom: 20px; }

/* --- Stats Bar (HORIZONTAL) --- */
.apk-stats-bar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 0;
    margin-bottom: 24px;
    overflow-x: auto;
}
.apk-stat-item {
    text-align: center;
    padding: 0 18px;
    flex-shrink: 0;
}
.apk-stat-item + .apk-stat-item {
    border-inline-start: 1px solid #eee;
}
.apk-stat-item:first-child {
    padding-inline-start: 0;
}
.apk-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    white-space: nowrap;
}
.apk-stat-label {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
    white-space: nowrap;
}
.apk-star { color: #ffc107; }
.apk-safe-icon {
    color: var(--primary);
    font-weight: 700;
    background: var(--primary-light);
    width: 24px; height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* --- Download Buttons (Top) --- */
.apk-download-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.apk-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: var(--primary);
    color: #fff !important;
    padding: 14px 40px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 700;
    transition: background 0.2s;
    cursor: pointer;
    text-decoration: none;
}
.apk-btn-download:hover {
    background: var(--primary-dark);
    color: #fff !important;
}
.apk-btn-download.full-width {
    width: 100%;
    justify-content: center;
}

/* --- Content Wrapper --- */
.apk-content-wrapper {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0;
}
.apk-main-col {
    width: 100%;
}

/* --- Sections --- */
.apk-section {
    background: var(--card);
    margin-bottom: 20px;
    padding: 24px 28px;
    border: 1px solid #f0f0f0;
}
.apk-section-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 16px;
    padding-bottom: 0;
    border: none;
}

/* --- Description --- */
.apk-badges-row { margin-bottom: 12px; }
.apk-badge {
    background: #fff3e0;
    color: #e65100;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}
.apk-description-body {
    color: #555;
    line-height: 1.8;
    font-size: 15px;
}
.apk-description-body h2 { font-size: 18px; color: #333; margin: 22px 0 10px; font-weight: 700; }
.apk-description-body h3 { font-size: 16px; color: #444; margin: 18px 0 8px; font-weight: 600; }
.apk-description-body p { margin-bottom: 12px; }
.apk-description-body ul,
.apk-description-body ol { margin: 10px 24px; }
.apk-description-body li { margin-bottom: 6px; }
.apk-description-body strong { color: #333; }

/* --- What's New --- */
.apk-last-updated { color: #999; font-size: 13px; margin-bottom: 12px; }
.apk-whatsnew-content { color: #555; line-height: 1.8; }

/* --- Screenshots Carousel --- */
.apk-screenshots-carousel { position: relative; overflow: hidden; }
.apk-screenshots-track {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 4px 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.apk-screenshots-track::-webkit-scrollbar { display: none; }
.apk-ss-item {
    flex: 0 0 200px;
    width: 200px;
    height: 360px;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.apk-ss-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.apk-play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    color: #fff;
}
.apk-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px; height: 36px;
    background: var(--card);
    border: 1px solid #ddd;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.apk-carousel-btn.prev { left: 4px; }
.apk-carousel-btn.next { right: 4px; }
body.rtl .apk-carousel-btn.prev { left: auto; right: 4px; }
body.rtl .apk-carousel-btn.next { right: auto; left: 4px; }

/* --- Info Table --- */
.apk-info-table { border: 1px solid #f0f0f0; border-radius: 8px; overflow: hidden; }
.apk-info-row {
    display: flex;
    flex-direction: row;
    border-bottom: 1px solid #f0f0f0;
}
.apk-info-row:last-child { border-bottom: none; }
.apk-info-cell {
    flex: 1;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.apk-info-cell + .apk-info-cell {
    border-inline-start: 1px solid #f0f0f0;
}
.apk-info-label { font-size: 12px; color: #999; }
.apk-info-val { font-size: 14px; font-weight: 600; color: #333; }
.apk-info-val a { color: var(--primary-dark); }

/* --- Security Box --- */
.apk-security-box { border: 2px solid var(--primary-light); }
.apk-security-header { margin-bottom: 12px; }
.apk-safe-badge { color: var(--primary); font-size: 16px; font-weight: 700; }
.apk-safe-text { color: var(--primary); }
.apk-security-details {
    display: flex;
    flex-direction: row;
    gap: 24px;
    margin-bottom: 12px;
}
.apk-security-item { color: #555; font-size: 13px; white-space: nowrap; }
.apk-security-id { color: #999; font-size: 12px; }

/* --- Download Section (Bottom) --- */
.apk-download-section { border: 2px solid var(--primary); }
.apk-dl-list { display: flex; flex-direction: column; gap: 10px; }
.apk-dl-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--primary);
    color: #fff !important;
    border-radius: 10px;
    transition: background 0.2s;
    text-decoration: none;
}
.apk-dl-item:hover { background: var(--primary-dark); color: #fff !important; }
.apk-dl-icon { flex-shrink: 0; }
.apk-dl-info { flex: 1; }
.apk-dl-name { font-size: 16px; font-weight: 700; }
.apk-dl-meta { font-size: 12px; opacity: 0.85; margin-top: 2px; }

/* --- Related Apps Grid --- */
.apk-related-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}
.apk-related-card {
    text-align: center;
    padding: 12px 8px;
    border-radius: 10px;
    transition: all 0.2s;
    color: #333;
    display: block;
}
.apk-related-card:hover { background: #f5f5f5; color: #333; }
.apk-related-icon {
    width: 72px; height: 72px;
    border-radius: 16px;
    margin: 0 auto 8px;
    display: block;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.apk-related-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 2px; }
.apk-related-dev { font-size: 11px; color: #999; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apk-related-rating { font-size: 12px; color: #ffc107; font-weight: 600; margin-top: 4px; }

/* --- Video Modal --- */
.apk-modal { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; }
.apk-modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.85); }
.apk-modal-content { position: relative; width: 90%; max-width: 800px; aspect-ratio: 16/9; }
.apk-modal-close { position: absolute; top: -40px; right: 0; background: none; border: none; color: #fff; font-size: 28px; cursor: pointer; }
.apk-modal-video iframe { width: 100%; height: 100%; border: none; border-radius: 12px; }


/* ═══════════════════════════════════════════════
   ARCHIVE / HOME / GRID PAGES
   ═══════════════════════════════════════════════ */

/* --- Layout --- */
.page-layout { display: flex; gap: 24px; padding: 20px 0; }
.page-layout.with-sidebar .main-content { flex: 1; min-width: 0; }
.page-layout:not(.with-sidebar) .main-content { flex: 1; }
.sidebar { width: 300px; flex-shrink: 0; }
.sidebar .widget { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.widget-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--primary); }

/* --- Section Header --- */
.section-header { margin-bottom: 20px; }
.section-header h1,
.section-header h2 { font-size: 22px; font-weight: 700; }

/* --- Apps Grid --- */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.app-card { background: var(--card); border-radius: var(--radius); overflow: hidden; transition: transform 0.2s, box-shadow 0.2s; box-shadow: var(--shadow); }
.app-card:hover { transform: translateY(-4px); box-shadow: 0 4px 20px rgba(0,0,0,0.12); }
.app-card-link { display: block; padding: 16px; text-align: center; color: var(--text); }
.app-card-icon img,
.app-card-icon-placeholder { width: 72px; height: 72px; border-radius: 16px; margin: 0 auto 12px; display: block; object-fit: cover; }
.app-card-icon-placeholder { background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 28px; }
.app-card-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-card-cat { font-size: 12px; color: var(--text-light); }
.app-card-meta { display: flex; justify-content: center; gap: 8px; margin-top: 8px; font-size: 12px; }
.app-card-rating { color: #f59e0b; font-weight: 600; }
.app-card-price.free { color: var(--primary-dark); font-weight: 600; }

/* --- Categories Bar --- */
.categories-bar { display: flex; gap: 8px; overflow-x: auto; padding: 16px 0; margin-bottom: 16px; }
.categories-bar::-webkit-scrollbar { height: 0; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; background: var(--card); border-radius: 20px; font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; box-shadow: var(--shadow); transition: all 0.2s; }
.cat-chip:hover, .cat-chip.active { background: var(--primary); color: #fff; }
.cat-count { background: rgba(0,0,0,0.1); padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.cat-chip.active .cat-count { background: rgba(255,255,255,0.3); }

/* --- Star Rating (helpers.php) --- */
.star-rating { display: inline-flex; align-items: center; gap: 2px; }
.star-rating .star { color: #f59e0b; font-size: 14px; }
.star-rating .star.empty { color: #e0e0e0; }
.star-rating .rating-num { margin-inline-start: 4px; font-weight: 600; color: var(--text); }

/* --- Pagination --- */
.pagination { margin: 30px 0; text-align: center; }
.pagination .nav-links { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.pagination .page-numbers { padding: 8px 14px; border-radius: 8px; background: var(--card); box-shadow: var(--shadow); font-weight: 600; color: var(--text); }
.pagination .page-numbers.current { background: var(--primary); color: #fff; }
.pagination .page-numbers:hover:not(.current) { background: var(--primary-light); }

/* --- No Results --- */
.no-results { text-align: center; padding: 60px 20px; }
.no-results h1,
.no-results h2 { font-size: 24px; margin-bottom: 10px; }

/* --- Post/Page Content --- */
.app-content-body { line-height: 1.8; }
.app-content-body h2, .app-content-body h3 { margin: 20px 0 10px; }
.app-content-body p { margin-bottom: 12px; }
.app-content-body ul, .app-content-body ol { margin: 10px 20px; }
.post-meta { color: var(--text-light); font-size: 13px; margin-bottom: 20px; }

/* --- Comments --- */
#commentform label { display: block; margin-bottom: 4px; font-weight: 600; }
#commentform input[type="text"],
#commentform input[type="email"],
#commentform input[type="url"],
#commentform textarea { width: 100%; padding: 10px 14px; border: 2px solid var(--border); border-radius: 8px; font-size: 14px; margin-bottom: 12px; }
#commentform input:focus, #commentform textarea:focus { border-color: var(--primary); outline: none; }
.comment-list li { padding: 16px 0; border-bottom: 1px solid var(--border); list-style: none; }
.comment-author img { border-radius: 50%; margin-inline-end: 8px; vertical-align: middle; }


/* ═══════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════ */

.site-footer { background: #1e293b; color: #94a3b8; padding: 40px 0 0; margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; gap: 30px; padding-bottom: 30px; border-bottom: 1px solid #334155; }
.footer-info h3 { color: #fff; margin-bottom: 8px; }
.footer-nav ul { list-style: none; display: flex; gap: 20px; }
.footer-nav a { color: #94a3b8; }
.footer-nav a:hover { color: #fff; }
.footer-bottom { padding: 16px 0; text-align: center; font-size: 13px; }


/* ═══════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════ */

@media (max-width: 768px) {
    /* Header */
    .header-inner { flex-wrap: wrap; }
    .header-search { order: 3; flex: 100%; }
    .header-nav { display: none; }
    .mobile-menu-toggle { display: block; margin-inline-start: auto; }

    /* Single App Header */
    .apk-app-header-inner {
        flex-direction: column-reverse !important;
        align-items: center !important;
        text-align: center;
    }
    .apk-app-info-side { order: unset !important; }
    .apk-app-icon-side { order: unset !important; }
    .apk-main-icon { width: 120px; height: 120px; margin: 0 auto; }
    .apk-share-btn { margin: 0 auto 12px; }
    .apk-stats-bar { flex-wrap: wrap !important; justify-content: center; gap: 8px; }
    .apk-stat-item { padding: 8px 12px; }
    .apk-stat-item + .apk-stat-item { border: none !important; }
    .apk-download-buttons { justify-content: center; }
    .apk-btn-download { width: 100%; justify-content: center; }
    .apk-section { padding: 18px 16px; }
    .apk-app-title { font-size: 22px; }

    /* Screenshots */
    .apk-ss-item { flex: 0 0 150px; width: 150px; height: 270px; }

    /* Info Table */
    .apk-info-row { flex-direction: column !important; }
    .apk-info-cell + .apk-info-cell { border-inline-start: none !important; border-top: 1px solid #f0f0f0; }

    /* Security */
    .apk-security-details { flex-direction: column; gap: 8px; }

    /* Related */
    .apk-related-grid { grid-template-columns: repeat(3, 1fr); }

    /* Archive */
    .page-layout { flex-direction: column; }
    .sidebar { width: 100%; }
    .apps-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

    /* Footer */
    .footer-inner { flex-direction: column; }
}

@media (max-width: 480px) {
    .apk-related-grid { grid-template-columns: repeat(3, 1fr); }
    .apk-related-icon { width: 56px; height: 56px; }
    .apps-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .apk-stats-bar { gap: 4px; }
}
