:root {
    --bg-color: #202124;
    --text-color: #e8eaed;
    --nav-bg: #202124;
    --border-color: #3c4043;
    --search-bg: #303134;
    --search-focus-bg: #3c4043;
    --icon-color: #9aa0a6;
    --active-color: #8ab4f8;
    --card-bg: #292a2d;
    --card-shadow: 0 1px 2px rgba(0,0,0,0.5);
    --shadow-hover: 0 2px 6px rgba(0,0,0,0.5);
    --nav-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

body.light-mode {
    --bg-color: #ffffff;
    --text-color: #202124;
    --nav-bg: #ffffff;
    --border-color: #e8eaed;
    --search-bg: #f1f3f4;
    --search-focus-bg: #ffffff;
    --icon-color: #5f6368;
    --active-color: #018786;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-hover: 0 2px 6px rgba(32,33,36,0.2);
    --nav-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s, color 0.3s;
}

/* ---- Top Nav ---- */
.top-nav {
    position: sticky; top: 0; z-index: 1000;
    background-color: var(--nav-bg);
    padding: 8px 16px;
    box-shadow: var(--nav-shadow);
    transition: background-color 0.3s;
}
.search-bar-container { display: flex; justify-content: center; }
.search-bar {
    display: flex; align-items: center;
    background-color: var(--search-bg);
    border-radius: 24px; padding: 0 16px;
    height: 48px; width: 100%; max-width: 720px;
    box-shadow: var(--card-shadow);
    transition: background-color 0.2s, box-shadow 0.2s;
}
.search-bar:focus-within { background-color: var(--search-focus-bg); box-shadow: var(--shadow-hover); }
.search-icon { color: var(--icon-color); margin-right: 12px; flex-shrink: 0; }
.search-bar input {
    flex: 1; border: none; background: transparent;
    font-size: 16px; outline: none; color: var(--text-color);
    min-width: 0; /* Prevents input from overflowing flex container */
}
.top-right-actions { display: flex; align-items: center; gap: 8px; margin-left: 12px; flex-shrink: 0; }
#lang-selector {
    background: transparent; border: 1px solid var(--border-color);
    color: var(--text-color); border-radius: 4px;
    padding: 4px 6px; font-size: 12px; cursor: pointer; outline: none;
    max-width: 100px;
}
#lang-selector option { background: var(--card-bg); color: var(--text-color); }
.theme-toggle {
    background: none; border: none; color: var(--icon-color);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ---- Categories ---- */
.categories {
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 64px; z-index: 999;
    transition: background-color 0.3s, border-color 0.3s;
}
.categories ul {
    list-style: none; display: flex; overflow-x: auto;
    padding: 0 16px; scroll-behavior: smooth;
    -ms-overflow-style: none; scrollbar-width: none;
}
.categories ul::-webkit-scrollbar { display: none; }
.categories li {
    padding: 12px 16px; cursor: pointer;
    font-size: 14px; font-weight: 500;
    color: var(--icon-color); white-space: nowrap; position: relative;
}
.categories li.active { color: var(--active-color); }
.categories li.active::after {
    content: ''; position: absolute; bottom: 0; left: 16px; right: 16px;
    height: 3px; background-color: var(--active-color); border-radius: 3px 3px 0 0;
}

/* ---- Main Content ---- */
.main-content {
    padding: 24px 16px 80px 16px;
    max-width: 1200px; margin: 0 auto;
}

.home-section { margin-bottom: 32px; }

.section-title {
    font-size: 18px; margin-bottom: 16px; font-weight: 500;
    color: var(--text-color); display: flex;
    justify-content: space-between; align-items: center;
}
.section-title::after {
    content: 'arrow_forward'; font-family: 'Material Icons Outlined';
    font-size: 20px; color: var(--icon-color);
}

/* ---- Horizontal Scroll Section ---- */
.horizontal-scroll {
    display: flex; gap: 12px;
    overflow-x: auto; padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none; scrollbar-width: none;
}
.horizontal-scroll::-webkit-scrollbar { display: none; }
.app-card-h {
    flex: 0 0 140px; scroll-snap-align: start;
    cursor: pointer; text-align: center;
}
.app-icon-h {
    width: 100%; aspect-ratio: 1; border-radius: 20%;
    object-fit: cover; box-shadow: var(--card-shadow); margin-bottom: 8px;
}
.app-info-h .app-title {
    font-size: 13px; font-weight: 400;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 2px;
}
.app-info-h .app-developer, .app-info-h .app-meta {
    font-size: 11px; color: var(--icon-color);
}
.app-info-h .app-meta { display: flex; align-items: center; justify-content: center; gap: 4px; }

/* ---- Vertical App Grid ---- */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 16px 12px;
}
.app-card {
    display: flex; flex-direction: column;
    cursor: pointer; background: var(--card-bg); border-radius: 8px;
}
.app-icon {
    width: 100%; aspect-ratio: 1; border-radius: 20%;
    margin-bottom: 8px; object-fit: cover; box-shadow: var(--card-shadow);
}
.app-title {
    font-size: 13px; font-weight: 400; color: var(--text-color);
    line-height: 1.2; margin-bottom: 2px;
    display: -webkit-box; -webkit-line-clamp: 2;
    -webkit-box-orient: vertical; overflow: hidden; text-overflow: ellipsis;
}
.app-developer {
    font-size: 12px; color: var(--icon-color);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-category {
    font-size: 12px; color: var(--icon-color);
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.app-list-rating {
    display: inline-flex; align-items: center;
    color: var(--text-color); font-weight: 500;
}
.list-star { font-size: 10px !important; margin-left: 2px; color: #fbbc04; }

/* ---- Dropdown & Actions ---- */
.app-actions { display: flex; flex-direction: column; gap: 8px; margin-left: auto; justify-content: center; }
.app-actions button { border: none; cursor: pointer; }
.coming-soon-text {
    font-size: 12px;
    color: var(--icon-color);
    font-weight: 500;
    white-space: nowrap;
    padding-right: 8px;
}
.dropdown { position: relative; display: inline-block; }
.btn-action {
    background: transparent; color: var(--icon-color);
    display: flex; align-items: center; justify-content: center;
    padding: 8px; border-radius: 50%;
}
.btn-action:hover { background-color: rgba(128,128,128,0.1); }
.dropdown-menu {
    display: none; position: absolute; right: 0; top: 100%;
    background-color: var(--card-bg); min-width: 120px;
    box-shadow: var(--shadow-hover); z-index: 1000;
    border-radius: 4px; overflow: hidden; flex-direction: column;
    border: 1px solid var(--border-color);
}
.dropdown-menu.show { display: flex; }
.dropdown-item {
    padding: 12px 16px; color: var(--text-color);
    cursor: pointer; font-size: 14px; transition: background-color 0.2s;
}
.dropdown-item:hover { background-color: rgba(128,128,128,0.1); }

/* ---- App Detail View ---- */
.detail-header { margin-bottom: 16px; }
.btn-back {
    background: transparent; border: none; color: var(--icon-color);
    cursor: pointer; padding: 8px; border-radius: 50%;
}
.btn-back:hover { background: rgba(128,128,128,0.1); }
.detail-top { display: flex; gap: 16px; margin-bottom: 24px; }
.detail-icon {
    width: 96px; height: 96px; border-radius: 20%;
    object-fit: cover; box-shadow: var(--card-shadow);
}
.detail-info { display: flex; flex-direction: column; justify-content: center; }
.detail-title { font-size: 22px; font-weight: 500; margin-bottom: 4px; }
.detail-developer { color: var(--active-color); font-size: 14px; margin-bottom: 2px; }
.detail-category { color: var(--icon-color); font-size: 14px; margin-bottom: 4px; }
.detail-stats {
    display: flex; gap: 16px; margin-bottom: 8px;
    font-size: 13px; color: var(--icon-color); font-weight: 500;
}
.stat-item { display: flex; align-items: center; gap: 4px; }
.stat-item .material-icons-outlined { font-size: 16px; }
.detail-rating {
    display: flex; align-items: center; gap: 4px;
    font-size: 14px; margin-bottom: 8px;
}
.detail-btn-row { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 10px; 
    margin-top: 12px; 
    width: 100%;
}
.detail-btn-row > button, .detail-btn-row > .coming-soon-badge {
    flex: 1 1 auto;
    min-width: 100px;
    text-align: center;
    justify-content: center;
    display: flex;
    align-items: center;
}
.detail-install {
    padding: 10px 24px; border-radius: 20px; border: none;
    cursor: pointer; font-weight: 500; font-size: 14px;
    background-color: var(--active-color); color: white;
}
.btn-launch {
    padding: 10px 24px; border-radius: 20px;
    border: 1px solid var(--active-color); background: transparent;
    color: var(--active-color); font-weight: 500; font-size: 14px; cursor: pointer;
}
.btn-launch:hover { background-color: rgba(138,180,248,0.1); }
.detail-btn-row .btn-secondary {
    padding: 10px 24px; border-radius: 20px;
    border: 1px solid var(--error-color) !important; 
    color: var(--error-color) !important;
}
.coming-soon-badge {
    padding: 8px 16px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    background: var(--search-bg);
    color: var(--icon-color);
    border: 1px solid var(--border-color);
    display: inline-block;
}

/* ---- Screenshots ---- */
.detail-section { margin-bottom: 32px; }
.detail-section-title { font-size: 16px; font-weight: 500; margin-bottom: 12px; }
.detail-screenshots {
    display: flex; gap: 12px; overflow-x: auto;
    padding-bottom: 8px; scroll-snap-type: x mandatory;
    -ms-overflow-style: none; scrollbar-width: none;
}
.detail-screenshots::-webkit-scrollbar { display: none; }
.detail-screenshots img {
    height: 300px; border-radius: 12px; box-shadow: var(--card-shadow);
    scroll-snap-align: start;
}
.detail-description { font-size: 14px; line-height: 1.6; color: var(--text-color); }

/* ---- Reviews ---- */
.review-form {
    display: flex; flex-direction: column; gap: 8px;
    margin-bottom: 24px; padding: 16px;
    background: var(--card-bg); border-radius: 8px; box-shadow: var(--card-shadow);
}
.star-rating-input { display: flex; gap: 4px; }
.star-icon { cursor: pointer; color: #fbbc04; font-size: 28px; }
.star-filled { color: #fbbc04 !important; }
.star-empty { color: var(--border-color); }
.review-form input {
    padding: 10px; border: 1px solid var(--border-color);
    border-radius: 4px; background: var(--search-bg);
    color: var(--text-color); outline: none; font-size: 14px;
}
.review-form button { align-self: flex-end; }
.review-card { padding: 16px 0; border-bottom: 1px solid var(--border-color); }
.review-user { font-weight: 500; margin-bottom: 4px; }
.review-stars { display: flex; gap: 2px; margin-bottom: 8px; font-size: 16px; }
.review-text { font-size: 14px; color: var(--text-color); line-height: 1.4; }
.no-reviews { color: var(--icon-color); font-size: 14px; padding: 12px 0; }

/* ---- Developer Console ---- */
.dev-header { margin-bottom: 24px; }
.dev-title { font-size: 24px; font-weight: 500; margin-bottom: 8px; }
.dev-subtitle { font-size: 14px; color: var(--icon-color); }
.dev-panel {
    background-color: var(--card-bg); padding: 20px;
    border-radius: 8px; box-shadow: var(--card-shadow);
    max-width: 640px; margin: 0 auto 20px auto;
}
.panel-title { font-size: 16px; font-weight: 500; margin-bottom: 16px; }
.sub-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sub-badge {
    padding: 6px 14px; border-radius: 16px;
    font-size: 12px; font-weight: 700; text-transform: uppercase;
}
.sub-badge.pro { background: linear-gradient(135deg, #4285f4, #34a853); color: #fff; }
.sub-badge.free { background: var(--border-color); color: var(--text-color); }
.sub-expires { font-size: 13px; color: var(--icon-color); }
.btn-upgrade {
    padding: 8px 20px; border-radius: 20px; border: none;
    cursor: pointer; font-weight: 500; font-size: 13px;
    background-color: var(--active-color); color: white;
}
.my-apps-list { display: flex; flex-direction: column; gap: 12px; }
.my-app-row {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px; border-radius: 8px;
    background: var(--bg-color); transition: background 0.2s;
}
.my-app-row:hover { background: var(--search-bg); }
.my-app-icon { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; flex-shrink: 0; }
.my-app-info { flex: 1 1 120px; min-width: 0; }
.my-app-info .app-title { white-space: normal; word-break: keep-all; line-height: 1.3; }
.app-hidden .my-app-icon, .app-hidden .my-app-info { opacity: 0.5; }
.app-blocked { border: 1px solid var(--error-color); background: rgba(255, 69, 58, 0.05); }
.app-blocked .my-app-icon, .app-blocked .my-app-info { opacity: 0.7; }
.my-app-controls {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-left: auto;
}
.dev-app-actions { display: flex; gap: 4px; }
.btn-icon {
    background: transparent; border: none; color: var(--icon-color);
    cursor: pointer; padding: 6px; border-radius: 50%; display: flex;
}
.btn-icon:hover { background-color: rgba(128,128,128,0.1); color: var(--text-color); }
.status-badge {
    padding: 4px 10px; border-radius: 12px;
    font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.status-active { background: #34a85333; color: #34a853; }
.status-pending { background: #fbbc0433; color: #fbbc04; }
.status-rejected { background: #ea433533; color: #ea4335; }

/* ---- Form ---- */
.form-group { margin-bottom: 16px; display: flex; flex-direction: column; }
.form-group label { margin-bottom: 8px; font-size: 14px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
    padding: 12px; border: 1px solid var(--border-color);
    border-radius: 4px; background-color: var(--search-bg);
    color: var(--text-color); font-size: 14px; outline: none;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--active-color); }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* ---- Modals ---- */
.modal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.6); z-index: 2000;
    align-items: center; justify-content: center;
}
.modal-content {
    background-color: var(--card-bg); color: var(--text-color);
    padding: 24px; border-radius: 12px;
    width: 90%; max-width: 400px; box-shadow: var(--shadow-hover);
}
.modal-content h3 { margin-bottom: 12px; font-size: 18px; }
.modal-content p { margin-bottom: 24px; font-size: 14px; color: var(--icon-color); }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; }
.modal-actions button {
    padding: 8px 16px; border-radius: 4px; border: none;
    cursor: pointer; font-size: 14px; font-weight: 500;
}
.btn-secondary { background: transparent; color: var(--active-color); }
.btn-primary { background-color: var(--active-color); color: #ffffff; border: none; border-radius: 4px; padding: 8px 16px; font-weight: 500; cursor: pointer; }

/* ---- Launch iframe modal ---- */
.launch-content {
    width: 90vw; height: 85vh; max-width: 1100px;
    background: var(--card-bg); border-radius: 12px; overflow: hidden;
    display: flex; flex-direction: column; box-shadow: var(--shadow-hover);
}
.launch-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 16px; background: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}
#launch-iframe { flex: 1; width: 100%; border: none; background: white; }

/* ---- Toast ---- */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: var(--card-bg); color: var(--text-color);
    padding: 12px 24px; border-radius: 8px;
    box-shadow: var(--shadow-hover); border: 1px solid var(--border-color);
    font-size: 14px; z-index: 3000;
    opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ---- Empty State ---- */
.empty-state {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 20px; color: var(--icon-color);
}
.empty-state .material-icons-outlined { font-size: 64px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

/* ---- Bottom Navigation ---- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background-color: var(--nav-bg); display: none;
    justify-content: space-around; padding: 8px 0;
    box-shadow: 0 -1px 4px rgba(0,0,0,0.2); z-index: 1000;
    transition: background-color 0.3s;
}
body.light-mode .bottom-nav { box-shadow: 0 -1px 4px rgba(0,0,0,0.08); }
.nav-item {
    display: flex; flex-direction: column; align-items: center;
    color: var(--icon-color); cursor: pointer; flex: 1;
}
.nav-item span.material-icons-outlined { font-size: 24px; margin-bottom: 4px; }
.nav-item span:last-child { font-size: 11px; font-weight: 500; }
.nav-item.active { color: var(--active-color); }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .bottom-nav { display: flex; }
    .top-nav { padding: 8px 12px; }
    .search-bar { height: 44px; padding: 0 12px; }
    .search-bar input { font-size: 14px; }
    .search-icon { margin-right: 8px; }
    .top-right-actions { gap: 4px; margin-left: 8px; }
    #lang-selector { padding: 4px; font-size: 11px; max-width: 70px; }
    .categories { top: 60px; }
    .categories li { padding: 10px 12px; }

    .app-grid { grid-template-columns: 1fr; gap: 12px; }
    .app-card {
        flex-direction: row; align-items: center; padding: 8px;
        border-radius: 12px;
    }
    .app-icon { width: 64px; height: 64px; margin-bottom: 0; margin-right: 12px; }
    .app-info { flex: 1; }
    .app-title { font-size: 15px; font-weight: 500; margin-bottom: 4px; }

    .horizontal-scroll { gap: 10px; }
    .app-card-h { flex: 0 0 110px; }

    .detail-screenshots img { height: 200px; }
}

@media (min-width: 769px) {
    .main-content { padding-bottom: 40px; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 24px; }
}
