@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Inter:wght@400;500;600&display=swap');

/* ===== Design Tokens ===== */
:root {
    --primary: #2563eb;
    --primary-light: #dbeafe;
    --primary-dark: #1d4ed8;
    --accent: #0ea5e9;
    --accent-light: #e0f2fe;
    --success: #059669;
    --success-light: #d1fae5;

    --bg-body: #f0f4f8;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --border-color: #e2e8f0;
    --border-light: #f1f5f9;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-focus: 0 0 0 3px rgba(37,99,235,0.15);

    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 999px;

    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-body);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-size: 16px;
    line-height: 1.6;
}

/* Force mobile-only max width */
@media (min-width: 481px) {
    body {
        max-width: 480px;
        margin: 0 auto;
        box-shadow: -1px 0 0 var(--border-color), 1px 0 0 var(--border-color);
    }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
}

p {
    font-family: 'Inter', sans-serif;
    line-height: 1.7;
    color: var(--text-secondary);
}

a {
    color: var(--primary);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== Header / Navbar ===== */
.site-header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.25rem;
    padding-top: calc(0.85rem + var(--safe-top));
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
}

.site-logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.85rem;
}

.site-logo-text {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.3px;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-header {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-header:active {
    transform: scale(0.92);
    background: var(--border-light);
}

/* ===== Hero / Welcome Section ===== */
.welcome-section {
    padding: 1.75rem 1.25rem 1.25rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-light);
}

.welcome-greeting {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.welcome-title {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0;
    line-height: 1.5;
}

/* ===== Search Bar ===== */
.search-section {
    padding: 1rem 1.25rem 0.75rem;
    background: var(--bg-elevated);
    position: sticky;
    top: 54px;
    z-index: 90;
}

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-body);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-full);
    padding: 0 1rem;
    transition: all 0.25s ease;
}

.search-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
    background: var(--bg-card);
}

.search-icon {
    color: var(--text-muted);
    font-size: 0.95rem;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 0.75rem 0.65rem;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 16px; /* Prevents iOS zoom */
    outline: none;
    width: 100%;
}

.search-input::placeholder {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Section Headers ===== */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.25rem 0.75rem;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-full);
    background: var(--primary-light);
    color: var(--primary);
}

/* ===== App List (Editorial List Style) ===== */
.content-area {
    flex: 1;
    padding: 0 0 2rem;
}

.app-list {
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* ===== App Card (List Row Style) ===== */
.app-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.app-card:active {
    transform: scale(0.985);
    background: var(--border-light);
}

.app-card-rank {
    width: 24px;
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}

.app-logo-wrapper {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--border-light);
    box-shadow: var(--shadow-sm);
}

.app-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-logo-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent-light));
    color: var(--primary);
}

.app-info {
    flex: 1;
    min-width: 0; /* Enable text truncation */
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.app-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-category {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
}

.app-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.app-actions {
    flex-shrink: 0;
}

.btn-get {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: var(--text-inverse);
    border: none;
    border-radius: var(--radius-full);
    padding: 0.5rem 1.1rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 0.8rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.2px;
    min-width: 60px;
    text-align: center;
}

.btn-get:active {
    transform: scale(0.94);
}

.btn-get.btn-disabled {
    background: var(--border-light);
    color: var(--text-muted);
    cursor: default;
    box-shadow: none;
}

.btn-get.btn-disabled:active {
    transform: none;
}

/* ===== Featured Banner ===== */
.featured-banner {
    margin: 0 1.25rem 0.5rem;
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    color: white;
    position: relative;
    overflow: hidden;
}

.featured-banner::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -20%;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.featured-banner::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -10%;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
}

.featured-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.65rem;
    opacity: 0.85;
}

.featured-title {
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 0.35rem;
    color: white;
    position: relative;
    z-index: 1;
}

.featured-desc {
    font-size: 0.82rem;
    opacity: 0.8;
    line-height: 1.5;
    color: white;
    position: relative;
    z-index: 1;
}

/* ===== Info Card (Trust Signals) ===== */
.trust-section {
    padding: 0.5rem 1.25rem 0.75rem;
}

.trust-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.trust-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.5rem;
    text-align: center;
}

.trust-icon {
    font-size: 1.3rem;
    margin-bottom: 0.35rem;
    display: block;
}

.trust-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    display: none;
    animation: fadeIn 0.4s ease;
}

.empty-state.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    font-size: 1.6rem;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ===== Footer ===== */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 1.75rem 1.25rem;
    padding-bottom: calc(1.75rem + var(--safe-bottom));
    margin-top: auto;
    text-align: center;
}

.footer-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.footer-logo-text {
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-primary);
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 1.25rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.footer-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}

.footer-nav a:active {
    color: var(--primary);
}

.footer-copyright {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.footer-disclaimer {
    font-size: 0.7rem;
    color: var(--text-muted);
    opacity: 0.7;
    line-height: 1.5;
    max-width: 340px;
    margin: 0.75rem auto 0;
}

/* ===== Cookie Consent Banner ===== */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color);
    padding: 1.15rem 1.25rem;
    padding-bottom: calc(1.15rem + var(--safe-bottom));
    z-index: 1050;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@media (min-width: 481px) {
    .cookie-banner {
        max-width: 480px;
        margin: 0 auto;
    }
}

.cookie-banner.show {
    transform: translateY(0);
}

.cookie-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 0.85rem;
}

.cookie-text a {
    color: var(--primary);
    font-weight: 600;
}

.cookie-actions {
    display: flex;
    gap: 0.6rem;
}

.btn-cookie {
    flex: 1;
    border: none;
    padding: 0.7rem;
    border-radius: var(--radius-sm);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cookie:active {
    transform: scale(0.97);
}

.btn-cookie-outline {
    background: var(--bg-body);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-cookie-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ===== Content Pages (Privacy, Terms, Contact) ===== */
.page-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-content {
    flex: 1;
    padding: 1.25rem;
}

.content-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.25rem;
    box-shadow: var(--shadow-sm);
}

.content-card h1 {
    font-size: 1.4rem;
    margin-bottom: 0.35rem;
}

.content-card .page-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    display: block;
}

.content-card h2 {
    font-size: 1.1rem;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.content-card p {
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
}

.content-card ul {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.content-card li {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.6;
}

.content-card a {
    color: var(--primary);
    font-weight: 600;
}

/* ===== Back Button ===== */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', sans-serif;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:active {
    transform: scale(0.95);
    background: var(--border-light);
}

/* ===== Contact Page ===== */
.contact-info-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-light);
}

.contact-info-item:last-child {
    border-bottom: none;
}

.contact-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.contact-detail strong {
    display: block;
    font-size: 0.85rem;
    color: var(--text-primary);
    margin-bottom: 0.1rem;
}

.contact-detail span,
.contact-detail a {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Form Styles */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    color: var(--text-primary);
    background: var(--bg-body);
    outline: none;
    transition: all 0.2s ease;
    -webkit-appearance: none;
}

.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: var(--shadow-focus);
    background: var(--bg-card);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.btn-submit {
    width: 100%;
    padding: 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--text-inverse);
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 700;
    font-size: 0.92rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-submit:active {
    transform: scale(0.98);
}

.alert-success {
    background: var(--success-light);
    border: 1px solid #a7f3d0;
    color: var(--success);
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

/* ===== Utility ===== */
.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;
}

/* ===== Print ===== */
@media print {
    .site-header, .cookie-banner, .search-section {
        display: none !important;
    }
}