/* =========================================
   Apps Page — site-themed App Store layout
   ========================================= */

.apps-page {
    min-height: 100vh;
    background-color: #DFFAAA;
    padding-top: calc(9rem + env(safe-area-inset-top, 0px));
    padding-bottom: 4rem;
    transition: background-color 0.3s ease;
}

body.dark .apps-page {
    background-color: #141414;
}

/* ---- Page Header ---- */
.apps-page-header {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    text-align: center;
}

.apps-page-title {
    font-family: 'Helvetica', Arial, sans-serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: #0a192f;
    letter-spacing: -0.02em;
}

body.dark .apps-page-title {
    color: #fff;
}

.apps-page-sub {
    font-size: 0.9rem;
    color: rgba(10,25,47,0.5);
    margin-top: 0.35rem;
}

body.dark .apps-page-sub {
    color: rgba(255,255,255,0.4);
}

/* ---- Section ---- */
.apps-section {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ---- App List / Grid ---- */
.apps-list {
    display: flex;
    flex-direction: column;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
    background-image: linear-gradient(144.46deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0) 100%);
    backdrop-filter: blur(21px);
    -webkit-backdrop-filter: blur(21px);
}

body.dark .apps-list {
    background-image: linear-gradient(144.46deg, rgba(30,41,59,0.6) 0%, rgba(30,41,59,0.2) 100%);
    border-color: rgba(255,255,255,0.08);
}

.apps-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid rgba(0,0,0,0.07);
}

body.dark .apps-row {
    border-bottom-color: rgba(255,255,255,0.06);
}

.apps-row:last-child {
    border-bottom: none;
}

.apps-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.25rem;
    cursor: pointer;
    border-right: 1px solid rgba(0,0,0,0.07);
    transition: background 0.18s ease;
}

body.dark .apps-item {
    border-right-color: rgba(255,255,255,0.06);
}

.apps-item:last-child {
    border-right: none;
}

.apps-item:hover {
    background: rgba(42,157,143,0.07);
}

.apps-item--ghost {
    pointer-events: none;
    visibility: hidden;
}

.apps-item-icon {
    width: 70px;
    height: 70px;
    border-radius: 16px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.apps-item-info {
    flex: 1;
    min-width: 0;
}

.apps-item-name {
    font-size: 1rem;
    font-weight: 600;
    color: #0a192f;
}

body.dark .apps-item-name {
    color: #fff;
}

.apps-item-desc {
    font-size: 0.85rem;
    color: rgba(10,25,47,0.45);
    margin-top: 0.15rem;
}

body.dark .apps-item-desc {
    color: rgba(255,255,255,0.4);
}

.apps-item-iap {
    font-size: 0.75rem;
    color: rgba(10,25,47,0.3);
    margin-top: 0.35rem;
}

body.dark .apps-item-iap {
    color: rgba(255,255,255,0.2);
}

.apps-item-btn {
    flex-shrink: 0;
    background: #2A9D8F;
    border: none;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.38rem 1.1rem;
    border-radius: 20px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s ease, transform 0.15s ease;
}

.apps-item-btn:hover {
    background: #21867a;
    transform: scale(1.04);
}

@media (max-width: 560px) {
    .apps-row {
        grid-template-columns: 1fr;
    }
    .apps-item {
        border-right: none;
        border-bottom: 1px solid rgba(0,0,0,0.07);
    }
    .apps-item--ghost {
        display: none;
    }
}

/* =========================================
   App Detail Slide-in Panel
   ========================================= */
.apps-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.apps-detail-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.apps-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 720px;
    height: 100%;
    background: #f0fcd4;
    border-left: 1px solid rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 3001;
}

body.dark .apps-detail-panel {
    background: #1c1c1e;
    border-left-color: rgba(255,255,255,0.08);
}

.apps-detail-overlay.visible .apps-detail-panel {
    transform: translateX(0);
}

.apps-detail-topbar {
    display: flex;
    align-items: center;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    background: rgba(255,255,255,0.4);
    backdrop-filter: blur(12px);
}

body.dark .apps-detail-topbar {
    border-bottom-color: rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.04);
}

.apps-detail-back {
    background: none;
    border: none;
    color: #2A9D8F;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.apps-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.75rem;
}

/* Detail — Hero */
.adetail-hero {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

body.dark .adetail-hero {
    border-bottom-color: rgba(255,255,255,0.07);
}

.adetail-icon {
    width: 100px;
    height: 100px;
    border-radius: 20px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.adetail-name {
    font-family: 'Helvetica', Arial, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0a192f;
    margin-bottom: 0.2rem;
}

body.dark .adetail-name {
    color: #fff;
}

.adetail-tagline {
    font-size: 0.88rem;
    color: rgba(10,25,47,0.45);
    margin-bottom: 0.9rem;
}

body.dark .adetail-tagline {
    color: rgba(255,255,255,0.4);
}

.adetail-get-btn {
    background: #2A9D8F;
    border: none;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.42rem 1.4rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.adetail-get-btn:hover {
    background: #21867a;
}

/* Detail — Stats */
.adetail-stats {
    display: flex;
    border-top: 1px solid rgba(0,0,0,0.07);
    border-bottom: 1px solid rgba(0,0,0,0.07);
    margin-bottom: 1.75rem;
}

body.dark .adetail-stats {
    border-color: rgba(255,255,255,0.07);
}

.adetail-stat {
    flex: 1;
    text-align: center;
    padding: 0.7rem 0.4rem;
    border-right: 1px solid rgba(0,0,0,0.07);
}

body.dark .adetail-stat {
    border-right-color: rgba(255,255,255,0.07);
}

.adetail-stat:last-child {
    border-right: none;
}

.adetail-stat-label {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(10,25,47,0.35);
    margin-bottom: 0.3rem;
}

body.dark .adetail-stat-label {
    color: rgba(255,255,255,0.3);
}

.adetail-stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(10,25,47,0.7);
}

body.dark .adetail-stat-value {
    color: rgba(255,255,255,0.7);
}

.adetail-stat-sub {
    font-size: 0.62rem;
    color: rgba(10,25,47,0.3);
    margin-top: 0.1rem;
}

body.dark .adetail-stat-sub {
    color: rgba(255,255,255,0.25);
}

/* Detail — Screenshots */
.adetail-screenshots {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    margin-bottom: 1.75rem;
    scrollbar-width: none;
}

.adetail-screenshots::-webkit-scrollbar {
    display: none;
}

.adetail-screenshot {
    height: 220px;
    border-radius: 10px;
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,0.08);
}

/* Detail — Platform / Description */
.adetail-platform {
    font-size: 0.8rem;
    color: rgba(10,25,47,0.35);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

body.dark .adetail-platform {
    color: rgba(255,255,255,0.3);
}

.adetail-description {
    font-size: 0.92rem;
    line-height: 1.75;
    color: rgba(10,25,47,0.7);
    margin-bottom: 2rem;
}

body.dark .adetail-description {
    color: rgba(255,255,255,0.6);
}

/* Detail — Developer links */
.adetail-dev-row {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    border-top: 1px solid rgba(0,0,0,0.08);
    padding-top: 1.25rem;
}

body.dark .adetail-dev-row {
    border-top-color: rgba(255,255,255,0.07);
}

.adetail-dev-link {
    font-size: 0.88rem;
    color: #2A9D8F;
    cursor: pointer;
    font-weight: 500;
}

/* =========================================
   App Detail — Full Page (/toolkit/apps/:id)
   ========================================= */
.app-detail-page {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 1.5rem 5rem;
}

/* Hero */
.adp-hero {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    padding-bottom: 1.75rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

body.dark .adp-hero { border-bottom-color: rgba(255,255,255,0.07); }

.adp-icon {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 6px 20px rgba(0,0,0,0.14);
}

.adp-name {
    font-family: 'Helvetica', Arial, sans-serif;
    font-size: 1.9rem;
    font-weight: 700;
    color: #0a192f;
    margin-bottom: 0.2rem;
    line-height: 1.15;
}

body.dark .adp-name { color: #fff; }

.adp-tagline {
    font-size: 0.9rem;
    color: rgba(10,25,47,0.45);
    margin-bottom: 1rem;
}

body.dark .adp-tagline { color: rgba(255,255,255,0.4); }

.adp-get-btn {
    background: #2A9D8F;
    border: none;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    padding: 0.52rem 1.8rem;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 0.01em;
    display: inline-block;
    text-decoration: none;
}

.adp-get-btn:hover { background: #21867a; }

/* Stats — scrollable on mobile */
.adp-stats {
    display: flex;
    border-top: 1px solid rgba(0,0,0,0.08);
    border-bottom: 1px solid rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    background: rgba(255,255,255,0.45);
    border-radius: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.adp-stats::-webkit-scrollbar { display: none; }

body.dark .adp-stats {
    border-color: rgba(255,255,255,0.07);
    background: rgba(255,255,255,0.04);
}

.adp-stat {
    flex: 1;
    min-width: 80px;
    text-align: center;
    padding: 1.2rem 0.75rem;
    border-right: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

body.dark .adp-stat { border-right-color: rgba(255,255,255,0.07); }
.adp-stat:last-child { border-right: none; }

.adp-stat-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(10,25,47,0.35);
    margin-bottom: 0.4rem;
}

body.dark .adp-stat-label { color: rgba(255,255,255,0.3); }

.adp-stat-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: rgba(10,25,47,0.72);
}

body.dark .adp-stat-value { color: rgba(255,255,255,0.7); }

.adp-stat-value--sm { font-size: 0.9rem; }

.adp-stat-sub {
    font-size: 0.68rem;
    color: rgba(10,25,47,0.3);
    margin-top: 0.15rem;
}

body.dark .adp-stat-sub { color: rgba(255,255,255,0.25); }

/* Screenshots */
.adp-screenshots {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    margin-bottom: 1.75rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.adp-screenshots::-webkit-scrollbar { display: none; }

.adp-screenshot {
    height: 320px;
    border-radius: 14px;
    flex-shrink: 0;
    object-fit: cover;
    border: 1px solid rgba(0,0,0,0.07);
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

/* Platform row — App Store style */
.adp-platform-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 0;
    border-top: 1px solid rgba(0,0,0,0.07);
    border-bottom: 1px solid rgba(0,0,0,0.07);
    margin-bottom: 1.5rem;
}

body.dark .adp-platform-row {
    border-color: rgba(255,255,255,0.07);
}

.adp-platform-icons {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: rgba(10,25,47,0.3);
}

body.dark .adp-platform-icons { color: rgba(255,255,255,0.3); }

.adp-platform-label {
    font-size: 0.82rem;
    color: rgba(10,25,47,0.4);
    flex: 1;
}

body.dark .adp-platform-label { color: rgba(255,255,255,0.35); }

/* Description */
.adp-description {
    font-size: 0.95rem;
    line-height: 1.78;
    color: #0a0a0a;
    margin-bottom: 2.5rem;
}

.adp-description p {
    margin-bottom: 1rem;
}

.adp-description ul {
    margin: 0.5rem 0 1rem 0;
    padding-left: 1.25rem;
}

.adp-description li {
    margin-bottom: 0.75rem;
}

body.dark .adp-description { color: rgba(255,255,255,0.9); }


/* Developer card — App Store style at bottom */
.adp-developer-card {
    display: flex;
    align-items: center;
    padding: 1rem 0;
    border-top: 1px solid rgba(0,0,0,0.08);
    cursor: default;
}

body.dark .adp-developer-card { border-top-color: rgba(255,255,255,0.07); }

.adp-developer-info { flex: 1; }

.adp-developer-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: rgba(10,25,47,0.6);
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

body.dark .adp-developer-name { color: rgba(255,255,255,0.5); }

.adp-developer-role {
    font-size: 0.78rem;
    color: rgba(10,25,47,0.35);
    margin-top: 0.15rem;
}

body.dark .adp-developer-role { color: rgba(255,255,255,0.25); }

.adp-developer-chevron {
    font-size: 1.1rem !important;
    color: rgba(10,25,47,0.2);
}

body.dark .adp-developer-chevron { color: rgba(255,255,255,0.15); }

/* =========================================
   Mobile responsive
   ========================================= */
@media (max-width: 640px) {
    .apps-page {
        padding-top: calc(7rem + env(safe-area-inset-top, 0px));
    }

    .app-detail-page {
        padding: 0 1.1rem 5rem;
    }

    .adp-icon {
        width: 88px;
        height: 88px;
        border-radius: 20px;
    }

    .adp-name {
        font-size: 1.45rem;
    }

    .adp-screenshot {
        height: 420px;
    }

    .adp-hero {
        gap: 1.1rem;
    }

    .apps-page-title {
        font-size: 2rem;
    }
}
