/* ============================================================
   APK Platform - Main Stylesheet
   ============================================================ */

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #1f2937;
    background: #f9fafb;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
a { color: #2563eb; text-decoration: none; transition: color 0.2s; }
a:hover { color: #1d4ed8; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
ul, ol { list-style: none; }
input, button, textarea, select { font: inherit; }

/* Utility Classes */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.text-center { text-align: center; }

/* Skip Link */
.skip-link {
    position: absolute; top: -40px; left: 0;
    background: #2563eb; color: #fff;
    padding: 8px 16px; z-index: 100;
    transition: top 0.3s;
}
.skip-link:focus { top: 0; }

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 50;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
    gap: 1rem;
}
.header-brand .logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: #1f2937;
}
.logo-icon {
    width: 32px; height: 32px;
    background: #2563eb;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.logo-icon svg { width: 20px; height: 20px; }

/* Navigation */
.header-nav .nav-list { display: flex; gap: 1.5rem; align-items: center; }
.nav-item { position: relative; }
.nav-link {
    color: #4b5563;
    font-weight: 500;
    padding: 0.5rem 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.nav-link:hover, .nav-link.is-active { color: #2563eb; }

/* Dropdown */
.nav-dropdown-toggle {
    background: none;
    border: none;
    color: #4b5563;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}
.nav-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    padding: 0.5rem 0;
    z-index: 100;
}
.has-dropdown:hover .nav-dropdown { display: block; }
.nav-dropdown a {
    display: block;
    padding: 0.5rem 1rem;
    color: #4b5563;
}
.nav-dropdown a:hover { background: #f3f4f6; color: #2563eb; }
.dropdown-divider { border-top: 1px solid #e5e7eb; margin: 0.5rem 0; }

/* Header Actions */
.header-actions { display: flex; align-items: center; gap: 1rem; }

/* Search Form */
.search-form-inner {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 0.25rem;
}
.search-input {
    border: none;
    background: transparent;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-width: 200px;
    outline: none;
}
.search-button {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.search-button:hover { background: #1d4ed8; }
.search-icon { color: #9ca3af; margin-left: 0.5rem; }
.search-button-icon { display: none; }

/* Language Indicator */
.language-indicator {
    background: #e5e7eb;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Mobile toggles */
.mobile-menu-toggle, .mobile-search-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    color: #4b5563;
}
.hamburger { display: flex; flex-direction: column; gap: 4px; }
.hamburger-line { width: 20px; height: 2px; background: currentColor; }

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 50%, #60a5fa 100%);
    color: #fff;
    padding: 4rem 0;
    position: relative;
    overflow: hidden;
}
.hero__container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    position: relative;
    z-index: 1;
}
.hero__content {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}
.hero__title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}
.hero__subtitle {
    font-size: 1.125rem;
    opacity: 0.9;
    margin-bottom: 2rem;
}
.hero__search { margin-bottom: 2rem; }
.hero__search-wrapper {
    display: flex;
    background: #fff;
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.hero__search-icon { color: #9ca3af; margin: 0 0.75rem; flex-shrink: 0; }
.hero__search-input {
    flex: 1;
    border: none;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    outline: none;
    min-width: 0;
}
.hero__search-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    white-space: nowrap;
}
.hero__search-btn:hover { background: #1d4ed8; }
.hero__stats { display: flex; justify-content: center; gap: 3rem; }
.hero__stat { text-align: center; }
.hero__stat-number { display: block; font-size: 1.75rem; font-weight: 700; }
.hero__stat-label { font-size: 0.875rem; opacity: 0.8; }

/* Hero Decoration */
.hero__decoration { position: absolute; inset: 0; pointer-events: none; }
.hero__decoration-circle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}
.hero__decoration-circle--1 { width: 400px; height: 400px; top: -200px; right: -100px; }
.hero__decoration-circle--2 { width: 300px; height: 300px; bottom: -150px; left: -100px; }
.hero__decoration-circle--3 { width: 200px; height: 200px; top: 50%; left: 10%; transform: translateY(-50%); }

/* ============================================================
   SECTIONS
   ============================================================ */
.section { padding: 3rem 0; }
.section__container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.section__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.section__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0;
}
.section__title-icon { color: #3b82f6; }
.section__link {
    color: #2563eb;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}
.section--categories { background: #f9fafb; }
.section--cta { background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); }

/* ============================================================
   FEATURED APPS GRID
   ============================================================ */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}
.featured-card {
    display: flex;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
}
.featured-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #d1d5db;
}
.featured-card__badge {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #ec4899, #db2777);
    color: #fff;
    border-radius: 6px;
    z-index: 1;
}
.featured-card__link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
    color: inherit;
    min-width: 0;
}
.featured-card__icon img {
    width: 72px;
    height: 72px;
    border-radius: 16px;
    object-fit: cover;
    flex-shrink: 0;
}
.featured-card__content { flex: 1; min-width: 0; }
.featured-card__name {
    font-size: 1rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.featured-card__developer {
    font-size: 0.8125rem;
    color: #6b7280;
    margin: 0 0 0.5rem 0;
}
.featured-card__meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.8125rem;
}
.featured-card__rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #f59e0b;
    font-weight: 500;
}
.featured-card__size { color: #9ca3af; }
.featured-card__download {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    background: #2563eb;
    color: #fff;
    transition: background 0.2s;
}
.featured-card__download:hover { background: #1d4ed8; }

/* ============================================================
   CATEGORY GRID
   ============================================================ */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
}
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    text-align: center;
    transition: all 0.2s;
}
.category-card:hover {
    border-color: var(--category-color, #3b82f6);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.category-card__icon {
    width: 56px;
    height: 56px;
    background: color-mix(in srgb, var(--category-color, #3b82f6) 10%, transparent);
    color: var(--category-color, #3b82f6);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}
.category-card__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.25rem 0;
}
.category-card__count {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
}

/* ============================================================
   TOP DOWNLOADS LIST
   ============================================================ */
.top-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 0.75rem;
}
.top-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: all 0.2s;
}
.top-item:hover {
    border-color: #d1d5db;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.top-item__rank {
    min-width: 28px;
    height: 28px;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 0.8125rem;
    font-weight: 700;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.top-item__rank--top3 {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}
.top-item__link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    color: inherit;
    min-width: 0;
}
.top-item__icon img { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; }
.top-item__content { flex: 1; min-width: 0; }
.top-item__name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.125rem 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-item__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
}
.top-item__developer {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-item__category::before {
    content: '•';
    margin-right: 0.5rem;
}
.top-item__downloads {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

/* ============================================================
   NEW RELEASES GRID
   ============================================================ */
.new-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}
.new-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.2s;
    position: relative;
}
.new-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); border-color: #d1d5db; }
.new-card__badge {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.25rem 0.625rem;
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 4px;
    z-index: 1;
}
.new-card__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1.5rem 1rem 1rem;
    text-align: center;
    color: inherit;
}
.new-card__icon img {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    margin-bottom: 0.75rem;
    object-fit: cover;
}
.new-card__name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 0.125rem 0;
}
.new-card__developer {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0 0 0.5rem 0;
}
.new-card__meta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    font-size: 0.75rem;
}
.new-card__rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: #f59e0b;
    font-weight: 500;
}
.new-card__size { color: #9ca3af; }

/* ============================================================
   CTA SECTION
   ============================================================ */
.cta {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 3rem 2rem;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.cta__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 0.5rem 0;
}
.cta__text {
    color: #6b7280;
    margin: 0 0 1.5rem 0;
    max-width: 400px;
}
.cta__actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}
.cta__btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
    font-size: 0.9375rem;
}
.cta__btn--primary { background: #2563eb; color: #fff; }
.cta__btn--primary:hover { background: #1d4ed8; }
.cta__btn--secondary { background: #fff; color: #374151; border: 1px solid #e5e7eb; }
.cta__btn--secondary:hover { background: #f9fafb; border-color: #d1d5db; }

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: #1f2937;
    color: #fff;
    padding: 3rem 0 1.5rem;
    margin-top: auto;
}
.footer-top {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 3rem;
    margin-bottom: 2rem;
}
.footer-logo { font-size: 1.25rem; font-weight: 700; color: #fff; }
.footer-tagline { color: #9ca3af; margin-top: 0.5rem; font-size: 0.875rem; }
.footer-nav-columns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.footer-heading {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}
.footer-links li { margin-bottom: 0.5rem; }
.footer-links a { color: #9ca3af; font-size: 0.875rem; }
.footer-links a:hover { color: #fff; }
.footer-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1.5rem;
    border-top: 1px solid #374151;
    flex-wrap: wrap;
    gap: 1rem;
}
.copyright { color: #9ca3af; font-size: 0.875rem; }
.social-links { display: flex; gap: 1rem; }
.social-link { color: #9ca3af; transition: color 0.2s; }
.social-link:hover { color: #fff; }

/* ============================================================
   MOBILE NAV
   ============================================================ */
.mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}
.mobile-nav.is-open { display: block; }
.mobile-nav-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}
.mobile-nav-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 300px;
    max-width: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
}
.mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}
.mobile-nav-logo { font-weight: 700; color: #1f2937; }
.mobile-nav-close {
    background: none;
    border: none;
    padding: 0.5rem;
    color: #6b7280;
}
.mobile-nav-search { padding: 1rem; border-bottom: 1px solid #e5e7eb; }
.mobile-nav-links { flex: 1; overflow-y: auto; padding: 1rem; }
.mobile-nav-list a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    color: #1f2937;
    border-radius: 8px;
}
.mobile-nav-list a:hover { background: #f3f4f6; }
.mobile-nav-icon { color: #6b7280; }
.mobile-nav-section { margin-top: 1.5rem; }
.mobile-nav-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 0.5rem;
    padding: 0 0.75rem;
}
.mobile-nav-list--compact a { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.mobile-nav-footer {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.mobile-nav-footer-links {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
}
.mobile-nav-footer-links a { color: #6b7280; }

/* Mobile Search Bar */
.mobile-search-bar { padding: 1rem; background: #f9fafb; border-bottom: 1px solid #e5e7eb; }
.mobile-search-bar[hidden] { display: none; }

/* ============================================================
   PAGE WRAPPER
   ============================================================ */
.page-wrapper { flex: 1; }
.main-content { padding: 2rem 0; }

/* ============================================================
   404 ERROR PAGE
   ============================================================ */
.error-page { text-align: center; padding: 4rem 1rem; }
.error-page h1 { font-size: 6rem; font-weight: 800; color: #e5e7eb; line-height: 1; }
.error-page h2 { font-size: 1.5rem; margin-bottom: 1rem; color: #1f2937; }
.error-page p { color: #6b7280; margin-bottom: 2rem; }
.error-page .btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #2563eb;
    color: #fff;
    border-radius: 8px;
    font-weight: 500;
}
.error-page .btn:hover { background: #1d4ed8; }

/* ============================================================
   RTL SUPPORT
   ============================================================ */
[dir="rtl"] .section__link svg,
[dir="rtl"] .featured-card__badge { transform: scaleX(-1); }
[dir="rtl"] .top-item__category::before { margin-right: 0; margin-left: 0.5rem; }
[dir="rtl"] .search-icon { margin-left: 0; margin-right: 0.5rem; }

/* ============================================================
   RESPONSIVE DESIGN
   ============================================================ */
@media (max-width: 768px) {
    .header-nav { display: none; }
    .mobile-menu-toggle, .mobile-search-toggle { display: flex; }
    .header-search { display: none; }

    .hero { padding: 3rem 0; }
    .hero__title { font-size: 1.75rem; }
    .hero__subtitle { font-size: 1rem; }
    .hero__search-wrapper { flex-direction: column; padding: 0.75rem; gap: 0.75rem; }
    .hero__search-icon { display: none; }
    .hero__search-input { width: 100%; text-align: center; }
    .hero__search-btn { width: 100%; }
    .hero__stats { gap: 1.5rem; }
    .hero__stat-number { font-size: 1.5rem; }

    .section { padding: 2rem 0; }
    .section__title { font-size: 1.25rem; }

    .featured-grid { grid-template-columns: 1fr; }
    .category-grid { grid-template-columns: repeat(2, 1fr); }
    .top-list { grid-template-columns: 1fr; }
    .new-grid { grid-template-columns: repeat(2, 1fr); }

    .cta { padding: 2rem 1.5rem; }
    .cta__title { font-size: 1.25rem; }
    .cta__actions { flex-direction: column; width: 100%; }
    .cta__btn { width: 100%; text-align: center; }

    .footer-top { grid-template-columns: 1fr; }
    .footer-nav-columns { grid-template-columns: repeat(2, 1fr); }
    .footer-bottom { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
    .hero__container { padding: 2.5rem 1rem; }
    .hero__title { font-size: 1.5rem; }
    .hero__stats { flex-wrap: wrap; }

    .section__header { flex-direction: column; align-items: flex-start; }

    .category-grid { gap: 0.75rem; }
    .category-card { padding: 1rem 0.75rem; }
    .category-card__icon { width: 48px; height: 48px; }

    .new-grid { gap: 0.75rem; }
    .new-card__link { padding: 1rem 0.75rem; }
    .new-card__icon img { width: 56px; height: 56px; }

    .featured-card__icon img { width: 60px; height: 60px; }
    .top-item__icon img { width: 44px; height: 44px; }
}
