* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    outline: none !important;
    -webkit-tap-highlight-color: transparent !important;
    border: none !important;
}

*::before,
*::after {
    border: none !important;
    outline: none !important;
}

*:focus,
*:active {
    outline: none !important;
    box-shadow: none !important;
}

:root {
    --davys-gray: #58525C;
    --black-bean: #350B15;
    --misty-rose: #E4D1D0;
    --raisin-black: #26212A;
    --rich-black: #14151D;
}

html, body {
    width: 100vw;
    max-width: 100vw;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    position: relative;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--rich-black) 0%, var(--raisin-black) 100%);
    color: var(--misty-rose);
    min-height: 100vh;
}

* {
    max-width: 100vw;
}

#mainPage,
#categoryAppsPage,
#appDetailsPage,
#searchResultsPage {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
}

.header {
    background: rgba(38, 33, 42, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: slideDown 0.5s ease;
    width: 100%;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.header-content {
    width: 100%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.store-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--misty-rose);
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.search-container {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1.5rem;
    border: 2px solid var(--davys-gray);
    border-radius: 50px;
    background: var(--rich-black);
    color: var(--misty-rose);
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none !important;
}

.search-input:focus {
    outline: none !important;
    border-color: var(--misty-rose);
    box-shadow: 0 0 20px rgba(228, 209, 208, 0.3);
}

.search-icon {
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    opacity: 0.7;
    cursor: pointer;
}

.news-section {
    width: 100%;
    margin: 2rem 0;
    padding: 0 1rem;
    display: none;
}

.news-section.active {
    display: block;
}

.news-slider {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.news-slider::-webkit-scrollbar {
    display: none;
}

.news-card {
    min-width: 300px;
    height: 150px;
    border-radius: 15px;
    background: linear-gradient(135deg, var(--black-bean), var(--davys-gray));
    display: flex;
    align-items: flex-end;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    background-size: cover;
    background-position: center;
    position: relative;
    overflow: hidden;
    outline: none !important;
    animation: googlePlayCard 0.6s ease-out;
}

@keyframes googlePlayCard {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.news-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.7) 100%);
    z-index: 1;
}

.news-card h3 {
    position: relative;
    z-index: 2;
}

.news-card:hover {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 8px 25px rgba(228, 209, 208, 0.2);
}

.news-card h3 {
    font-size: 1.2rem;
    color: var(--misty-rose);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.container {
    width: 100%;
    margin: 0;
    padding: 1rem;
}

/* Featured Section - Google Play Style */
/* تم نقل قسم الأكثر تحميلاً ليكون فوق شريط التصنيفات */
.featured-section {
    margin: 2rem 0 1rem 0;
    padding: 0 1rem;
    order: -1; /* لجعله يظهر أولاً */
}

.section-title {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
    color: var(--misty-rose);
    font-weight: 600;
}

.featured-apps-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.featured-app-card {
    background: linear-gradient(135deg, var(--raisin-black), var(--rich-black));
    border-radius: 20px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    border: 2px solid transparent;
    animation: googlePlayCard 0.6s ease-out;
}

.featured-app-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(228, 209, 208, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.featured-app-card:hover::before {
    opacity: 1;
}

.featured-app-card:hover {
    transform: translateY(-8px) scale(1.02);
    border-color: var(--misty-rose);
    box-shadow: 0 12px 40px rgba(228, 209, 208, 0.2);
}

.featured-app-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    z-index: 2;
}

.featured-app-icon {
    width: 80px;
    height: 80px;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.featured-app-info {
    flex: 1;
}

.featured-app-name {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--misty-rose);
}

.featured-app-desc {
    font-size: 0.9rem;
    color: rgba(228, 209, 208, 0.8);
    line-height: 1.4;
}

.category-filter {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    width: 100%;
    padding-right: 0;
    padding-left: 0;
}

.category-filter::-webkit-scrollbar {
    display: none;
}

.category-btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 25px;
    background: var(--raisin-black);
    color: var(--misty-rose);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    white-space: nowrap;
    flex-shrink: 0;
    outline: none !important;
}

.category-btn:hover, .category-btn.active {
    background: var(--davys-gray);
    box-shadow: 0 4px 15px rgba(228, 209, 208, 0.2);
}

.more-categories-btn {
    padding: 0.7rem 1rem;
    border: none;
    border-radius: 25px;
    background: var(--raisin-black);
    color: var(--misty-rose);
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    white-space: nowrap;
    flex-shrink: 0;
    outline: none !important;
}

.more-categories-btn:hover {
    background: var(--davys-gray);
    box-shadow: 0 4px 15px rgba(228, 209, 208, 0.2);
}

.apps-grid {
    display: flex;
    gap: 2rem;
    margin-top: 2rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.apps-grid::-webkit-scrollbar {
    display: none;
}

.app-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: taptapCard 0.5s ease;
    flex-shrink: 0;
    outline: none !important;
}

@keyframes taptapCard {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-card:hover {
    transform: translateY(-10px);
}

.app-icon {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
    border: 3px solid transparent;
    outline: none !important;
}

.app-card:hover .app-icon {
    box-shadow: 0 12px 30px rgba(228, 209, 208, 0.3);
    border-color: var(--misty-rose);
    transform: scale(1.05);
}

.app-name {
    margin-top: 0.8rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--misty-rose);
    max-width: 120px;
    word-wrap: break-word;
}

/* Search Results Page */
.search-results-page {
    display: none;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--rich-black) 0%, var(--raisin-black) 100%);
    animation: fadeInPage 0.4s ease;
}

.search-results-page.active {
    display: block;
}

.search-results-page.closing {
    animation: fadeOutPage 0.4s ease;
}

.search-results-container {
    width: 100%;
    margin: 0;
    padding: 1rem;
}

.search-results-title {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: var(--misty-rose);
    text-align: center;
}

/* تغيير عرض نتائج البحث إلى شبكة عمودية */
.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    padding-bottom: 1rem;
}

.app-details-page {
    display: none;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--rich-black) 0%, var(--raisin-black) 100%);
    animation: fadeInPage 0.4s ease;
}

.app-details-page.active {
    display: block;
}

.app-details-page.closing {
    animation: fadeOutPage 0.4s ease;
}

@keyframes fadeInPage {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOutPage {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50px);
    }
}

.back-btn {
    background: var(--raisin-black);
    border: none;
    color: var(--misty-rose);
    font-size: 1.3rem;
    padding: 0.5rem 0.8rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    outline: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    width: 50px;
    height: 50px;
}
.back-btn:hover {
    background: var(--davys-gray);
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(228, 209, 208, 0.2);
}

.app-details-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
}

.app-details-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.app-details-icon {
    width: 120px;
    height: 120px;
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    outline: none !important;
}

.app-details-info h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--misty-rose);
}

.app-meta {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.meta-item {
    background: var(--rich-black);
    padding: 0.5rem 1rem;
    border-radius: 10px;
    font-size: 0.9rem;
    border: 1px solid var(--davys-gray);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-description {
    margin: 2rem 0;
    line-height: 1.8;
    font-size: 1.1rem;
}

.app-description p {
    margin-bottom: 1.5rem;
    color: rgba(228, 209, 208, 0.9);
}

.developer-info {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--rich-black);
    border-radius: 15px;
    border: 2px solid var(--davys-gray);
}

.download-btn {
    width: 100%;
    padding: 1.2rem;
    background: linear-gradient(135deg, var(--black-bean), var(--davys-gray));
    color: var(--misty-rose);
    border: none;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 2rem;
    outline: none !important;
}

.download-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(228, 209, 208, 0.3);
}

.random-apps-section {
    width: 100%;
    margin: 3rem 0 2rem;
    padding: 0 1rem;
}

.category-section {
    margin-bottom: 3rem;
}

.category-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--misty-rose);
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

.category-section h3:hover {
    color: var(--davys-gray);
    transform: translateX(-5px);
}

.random-apps-grid {
    display: flex;
    gap: 2rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.random-apps-grid::-webkit-scrollbar {
    display: none;
}

.category-apps-page {
    display: none;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--rich-black) 0%, var(--raisin-black) 100%);
    animation: fadeInPage 0.4s ease;
}

.category-apps-page.active {
    display: block;
}

.category-apps-page.closing {
    animation: fadeOutPage 0.4s ease;
}

.category-apps-container {
    width: 100%;
    margin: 0;
    padding: 1rem;
}

.category-apps-title {
    font-size: 2rem;
    margin-bottom: 2rem;
    color: var(--misty-rose);
    text-align: center;
}

/* تغيير عرض تطبيقات التصنيف إلى شبكة عمودية */
.category-apps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
    padding-bottom: 1rem;
}

.floating-btn {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--black-bean), var(--davys-gray));
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;
    outline: none !important;
}

.floating-btn:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 12px 35px rgba(228, 209, 208, 0.4);
}

.floating-btn svg {
    width: 30px;
    height: 30px;
    fill: var(--misty-rose);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--davys-gray);
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Bottom Sheet - TapTap Style */
.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.bottom-sheet-overlay.active {
    opacity: 1;
    visibility: visible;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--raisin-black), var(--rich-black));
    border-radius: 20px 20px 0 0;
    z-index: 1000;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.bottom-sheet.active {
    transform: translateY(0);
}

.bottom-sheet-header {
    padding: 1rem;
    border-bottom: 1px solid var(--davys-gray);
    position: relative;
}

.bottom-sheet-drag-handle {
    width: 40px;
    height: 4px;
    background: var(--davys-gray);
    border-radius: 2px;
    margin: 0 auto 1rem;
    cursor: grab;
}

.bottom-sheet-drag-handle:active {
    cursor: grabbing;
}

.bottom-sheet-header h2 {
    text-align: center;
    color: var(--misty-rose);
    font-size: 1.3rem;
}

.bottom-sheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.bottom-sheet .categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.bottom-sheet .category-item {
    padding: 1.2rem 1rem;
    border: 2px solid var(--davys-gray);
    border-radius: 15px;
    background: var(--raisin-black);
    color: var(--misty-rose);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.9rem;
}

.bottom-sheet .category-item:hover {
    background: var(--davys-gray);
    border-color: var(--misty-rose);
    transform: scale(1.05);
}

.close-btn {
    outline: none !important;
}

.close-btn:focus,
.close-btn:active {
    outline: none !important;
    box-shadow: none !important;
}

a {
    outline: none !important;
}

a:focus,
a:active {
    outline: none !important;
    box-shadow: none !important;
}

img {
    outline: none !important;
}

img:focus,
img:active {
    outline: none !important;
}

@media (max-width: 768px) {
    * {
        max-width: 100vw !important;
    }
    
    html, body {
        width: 100vw;
        overflow-x: hidden;
    }
    
    .header {
        padding: 1rem;
        width: 100vw;
    }
    
    .header-content {
        width: 100%;
        padding: 0;
    }
    
    .container,
    .random-apps-section,
    .category-apps-container,
    .search-results-container {
        width: 100vw;
        max-width: 100vw;
        padding: 1rem;
    }

    .store-title {
        font-size: 1.5rem;
    }

    .app-icon {
        width: 80px;
        height: 80px;
    }

    .app-details-header {
        flex-direction: column;
        text-align: center;
    }

    .app-details-icon {
        width: 100px;
        height: 100px;
    }

    .floating-btn {
        bottom: 1rem;
        left: 1rem;
        width: 50px;
        height: 50px;
    }

    .news-card {
        min-width: 250px;
        height: 130px;
    }

    .featured-apps-container {
        grid-template-columns: 1fr;
    }

    .bottom-sheet {
        max-height: 70vh;
    }
    
    .search-results-title {
        font-size: 1.5rem;
    }
    
    .category-apps-grid,
    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 1.5rem;
    }
}

/* زر المشاركة وترتيب الأزرار */
.app-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
}

.share-btn {
    background: var(--raisin-black);
    border: none;
    color: var(--misty-rose);
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    outline: none !important;
    width: auto;
    min-width: 50px;
    height: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.share-btn:hover {
    background: var(--davys-gray);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(228, 209, 208, 0.3);
}

.share-btn i {
    font-size: 1.2rem;
}

/* إشعار النسخ */
.copy-notification {
    position: fixed;
    top: 20px;
    right: 50%;
    transform: translateX(50%) translateY(-100px);
    background: linear-gradient(135deg, var(--black-bean), #8B1538);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    opacity: 0;
    transition: all 0.3s ease;
}

.copy-notification.show {
    opacity: 1;
    transform: translateX(50%) translateY(0);
}

.copy-notification i {
    font-size: 1.2rem;
}

/* تعديل زر الرجوع ليتناسق مع زر المشاركة */
.app-header-actions .back-btn {
    margin-bottom: 0;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .back-btn {
        width: 35px;
        height: 35px;
        font-size: 1.1rem;
        padding: 0.4rem 0.7rem;
    }
    
    .share-btn {
        font-size: 1rem;
        padding: 0.4rem 0.8rem;
        min-width: 35px;
        height: 35px;
    }
    
    .share-btn i {
        font-size: 1rem;
    }
    
    .copy-notification {
        font-size: 0.9rem;
        padding: 0.8rem 1.2rem;
        top: 15px;
    }
}

.count-loading {
    opacity: 0.6;
    font-size: 0.9em;
}

/* زر إعادة التحميل */
.reload-btn {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, var(--black-bean), #8B1538);
    color: var(--misty-rose);
    border: none;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    z-index: 10001;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
    opacity: 0;
}

.reload-btn.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.reload-btn:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 12px 40px rgba(139, 21, 56, 0.6);
}

.reload-btn i {
    font-size: 1.2rem;
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .reload-btn {
        font-size: 1rem;
        padding: 0.9rem 1.5rem;
    }
}