/* ── Fodis3App Web – Material 3 Expressive ─────────────────────── */
:root {
    --md-primary: #4A6741;
    --md-on-primary: #ffffff;
    --md-primary-container: #CBE8C1;
    --md-on-primary-container: #082105;
    --md-secondary: #526350;
    --md-secondary-container: #D5E8D0;
    --md-tertiary: #39656B;
    --md-tertiary-container: #BCEBF2;
    --md-surface: #F8FAF5;
    --md-surface-variant: #DEE5D8;
    --md-on-surface: #1A1C19;
    --md-on-surface-variant: #424940;
    --md-outline: #727970;
    --md-outline-variant: #C2C9BD;
    --md-error: #BA1A1A;
    --md-error-container: #FFDAD6;
    --md-surface-dim: #D8DBD4;
    --md-surface-bright: #F8FAF5;
    --md-surface-container: #ECEEE8;
    --md-surface-container-low: #F2F4EE;
    --md-surface-container-high: #E6E9E2;
    --md-surface-container-highest: #E1E3DD;
    --radius-xs: 8px;
    --radius-sm: 12px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --shadow-1: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.12);
    --shadow-2: 0 3px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.08);
    --shadow-3: 0 6px 12px rgba(0,0,0,.1), 0 3px 6px rgba(0,0,0,.06);
}

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

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--md-surface);
    color: var(--md-on-surface);
    line-height: 1.5;
    min-height: 100vh;
    padding-bottom: 72px;
}

/* ── Header ───────────────────────────────────────────────────── */
.header {
    position: sticky; top: 0; z-index: 100;
    background: var(--md-surface);
    border-bottom: 1px solid var(--md-outline-variant);
    backdrop-filter: blur(12px);
}
.header-inner {
    max-width: 1200px; margin: 0 auto;
    display: flex; align-items: center; gap: 16px;
    padding: 8px 16px; height: 64px;
}
.logo {
    display: flex; align-items: center; gap: 8px;
    text-decoration: none; color: var(--md-primary);
    font-weight: 800; font-size: 20px; flex-shrink: 0;
}
.logo-icon { font-size: 28px; color: var(--md-primary); }
.search-bar {
    flex: 1; max-width: 600px;
    display: flex; align-items: center; gap: 8px;
    background: var(--md-surface-container-high);
    border-radius: var(--radius-full);
    padding: 8px 16px;
    transition: background .2s, box-shadow .2s;
}
.search-bar:focus-within {
    background: var(--md-surface-container-highest);
    box-shadow: var(--shadow-1);
}
.search-bar .material-icons-round { color: var(--md-on-surface-variant); font-size: 20px; }
.search-bar input {
    border: none; background: transparent; outline: none;
    font-family: inherit; font-size: 14px; width: 100%;
    color: var(--md-on-surface);
}
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 24px;
    border-radius: var(--radius-full);
    font-family: inherit; font-weight: 600; font-size: 14px;
    cursor: pointer; border: none; text-decoration: none;
    transition: all .2s;
}
.btn-primary {
    background: var(--md-primary);
    color: var(--md-on-primary);
}
.btn-primary:hover { box-shadow: var(--shadow-2); filter: brightness(1.1); }
.btn-outlined {
    background: transparent;
    color: var(--md-primary);
    border: 1px solid var(--md-outline);
}
.btn-outlined:hover { background: var(--md-primary-container); }
.btn-tonal {
    background: var(--md-secondary-container);
    color: var(--md-on-primary-container);
}
.btn-text { background: transparent; color: var(--md-primary); padding: 8px 12px; }
.btn-icon {
    width: 40px; height: 40px; padding: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: transparent; color: var(--md-on-surface-variant);
    border: none; cursor: pointer;
}
.btn-icon:hover { background: var(--md-surface-container-high); }
.btn-close { background:transparent;border:none;cursor:pointer;color:var(--md-on-surface-variant);padding:4px; }

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

/* ── Cards ────────────────────────────────────────────────────── */
.section-title {
    font-size: 20px; font-weight: 700; margin-bottom: 16px;
    color: var(--md-on-surface);
}
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}
.app-card {
    background: var(--md-surface-container-low);
    border-radius: var(--radius-md);
    padding: 12px; cursor: pointer;
    transition: transform .15s, box-shadow .15s;
    text-decoration: none; color: inherit;
    display: flex; flex-direction: column;
}
.app-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.app-card-icon {
    width: 64px; height: 64px; border-radius: var(--radius-sm);
    background: var(--md-surface-container-high);
    overflow: hidden; margin-bottom: 8px;
    display: flex; align-items: center; justify-content: center;
}
.app-card-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-card-icon .material-icons-round { font-size: 32px; color: var(--md-outline); }
.app-card-name {
    font-weight: 600; font-size: 14px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-card-dev { font-size: 12px; color: var(--md-on-surface-variant); margin-top: 2px; }
.app-card-meta {
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; color: var(--md-on-surface-variant); margin-top: 6px;
}
.app-card-meta .material-icons-round { font-size: 14px; color: #FFC107; }

/* ── Horizontal Scroll ────────────────────────────────────────── */
.h-scroll {
    display: flex; gap: 12px; overflow-x: auto;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
    padding-bottom: 4px; scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll .app-card { min-width: 160px; scroll-snap-align: start; flex-shrink: 0; }

/* ── App Detail ───────────────────────────────────────────────── */
.app-detail { max-width: 800px; margin: 0 auto; }
.app-detail-header { display: flex; gap: 16px; margin-bottom: 24px; }
.app-detail-icon {
    width: 96px; height: 96px; border-radius: var(--radius-lg);
    overflow: hidden; flex-shrink: 0;
    background: var(--md-surface-container-high);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-1);
}
.app-detail-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-detail-icon .material-icons-round { font-size: 48px; color: var(--md-outline); }
.app-detail-info { flex: 1; }
.app-detail-info h1 { font-size: 24px; font-weight: 800; margin-bottom: 4px; line-height: 1.2; }
.app-detail-info .developer { color: var(--md-primary); font-weight: 600; font-size: 14px; }
.app-detail-stats {
    display: flex; gap: 24px; margin-top: 8px; flex-wrap: wrap;
}
.stat { text-align: center; }
.stat-value { font-weight: 700; font-size: 16px; }
.stat-label { font-size: 12px; color: var(--md-on-surface-variant); }
.app-detail-actions { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.app-detail-actions .btn-primary { flex: 1; justify-content: center; min-width: 200px; }

.app-detail-section { margin-bottom: 24px; }
.app-detail-section h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }

.screenshots-scroll {
    display: flex; gap: 8px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.screenshots-scroll::-webkit-scrollbar { display: none; }
.screenshots-scroll img {
    height: 300px; border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; border-radius: var(--radius-xs);
    background: var(--md-surface-container-high);
    font-size: 12px; color: var(--md-on-surface-variant);
    margin: 2px;
}
.info-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}
.info-item {
    padding: 12px; border-radius: var(--radius-sm);
    background: var(--md-surface-container-low);
}
.info-item .label { font-size: 12px; color: var(--md-on-surface-variant); }
.info-item .value { font-weight: 600; font-size: 14px; margin-top: 2px; }

/* ── Reviews ──────────────────────────────────────────────────── */
.review-card {
    padding: 12px; border-radius: var(--radius-sm);
    background: var(--md-surface-container-low);
    margin-bottom: 8px;
}
.review-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.review-user { font-weight: 600; font-size: 14px; }
.review-stars { color: #FFC107; font-size: 14px; }
.review-date { font-size: 12px; color: var(--md-on-surface-variant); margin-left: auto; }
.review-text { font-size: 14px; color: var(--md-on-surface); }

/* ── Categories ───────────────────────────────────────────────── */
.cat-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.cat-card {
    background: var(--md-surface-container-low);
    border-radius: var(--radius-md);
    padding: 20px 16px; text-align: center;
    cursor: pointer; transition: all .2s;
    text-decoration: none; color: inherit;
}
.cat-card:hover { background: var(--md-primary-container); transform: translateY(-2px); }
.cat-card .material-icons-round { font-size: 36px; color: var(--md-primary); }
.cat-card span { display: block; margin-top: 8px; font-weight: 600; font-size: 14px; }

/* ── Upload Form ──────────────────────────────────────────────── */
.form-card {
    background: var(--md-surface-container-low);
    border-radius: var(--radius-lg);
    padding: 24px; max-width: 600px; margin: 0 auto;
}
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 14px; font-weight: 600;
    margin-bottom: 6px; color: var(--md-on-surface);
}
.form-control {
    width: 100%; padding: 12px 16px;
    border: 1px solid var(--md-outline-variant);
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px;
    background: var(--md-surface);
    color: var(--md-on-surface);
    transition: border-color .2s;
}
.form-control:focus { outline: none; border-color: var(--md-primary); }
textarea.form-control { min-height: 100px; resize: vertical; }
select.form-control { cursor: pointer; }

.file-drop {
    border: 2px dashed var(--md-outline-variant);
    border-radius: var(--radius-md);
    padding: 32px; text-align: center;
    cursor: pointer; transition: all .2s;
}
.file-drop:hover, .file-drop.drag-over {
    border-color: var(--md-primary);
    background: var(--md-primary-container);
}
.file-drop .material-icons-round { font-size: 48px; color: var(--md-primary); }
.file-drop p { margin-top: 8px; color: var(--md-on-surface-variant); font-size: 14px; }
.file-drop .formats { font-size: 12px; color: var(--md-outline); margin-top: 4px; }

.upload-progress {
    margin-top: 12px; display: none;
}
.progress-bar {
    height: 4px; background: var(--md-surface-container-high);
    border-radius: 2px; overflow: hidden;
}
.progress-bar-fill {
    height: 100%; background: var(--md-primary);
    transition: width .3s; width: 0%;
}

/* ── Auth Modal ───────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.4); z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; backdrop-filter: blur(4px);
}
.modal {
    background: var(--md-surface);
    border-radius: var(--radius-xl);
    padding: 24px; width: 100%; max-width: 400px;
    box-shadow: var(--shadow-3); animation: modalIn .2s ease-out;
}
@keyframes modalIn { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { font-size: 22px; font-weight: 800; margin-bottom: 16px; text-align: center; }
.modal-tabs {
    display: flex; gap: 0; margin-bottom: 16px;
    border-radius: var(--radius-full);
    background: var(--md-surface-container-high);
    padding: 4px;
}
.modal-tab {
    flex: 1; padding: 8px; text-align: center;
    border-radius: var(--radius-full);
    font-weight: 600; font-size: 14px; cursor: pointer;
    transition: all .2s; border: none; font-family: inherit;
    background: transparent; color: var(--md-on-surface-variant);
}
.modal-tab.active { background: var(--md-primary); color: var(--md-on-primary); }

/* ── Bottom Nav ───────────────────────────────────────────────── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--md-surface);
    border-top: 1px solid var(--md-outline-variant);
    display: flex; z-index: 100; height: 64px;
}
.nav-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    text-decoration: none; color: var(--md-on-surface-variant);
    font-size: 11px; gap: 2px; transition: color .2s;
}
.nav-item.active { color: var(--md-primary); }
.nav-item .material-icons-round { font-size: 24px; }

/* ── Install Banner ───────────────────────────────────────────── */
.install-banner {
    position: fixed; bottom: 72px; left: 0; right: 0;
    z-index: 90; padding: 8px 16px;
    animation: slideUp .3s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); } }
.install-banner.hidden { display: none; }
.install-banner-content {
    background: var(--md-tertiary-container);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
    max-width: 600px; margin: 0 auto;
}
.install-banner-content .material-icons-round { font-size: 32px; color: var(--md-tertiary); flex-shrink: 0; }
.install-banner-content div { flex: 1; }
.install-banner-content strong { font-size: 14px; }
.install-banner-content p { font-size: 12px; color: var(--md-on-surface-variant); }

/* ── Loading ──────────────────────────────────────────────────── */
.loading-spinner {
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 60px 0;
}
.spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--md-surface-container-high);
    border-top-color: var(--md-primary);
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-spinner p { margin-top: 12px; color: var(--md-on-surface-variant); font-size: 14px; }

.empty-state {
    text-align: center; padding: 48px 16px; color: var(--md-on-surface-variant);
}
.empty-state .material-icons-round { font-size: 64px; margin-bottom: 16px; color: var(--md-outline); }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--md-on-surface); margin-bottom: 4px; }

.toast {
    position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
    background: var(--md-on-surface); color: var(--md-surface);
    padding: 12px 24px; border-radius: var(--radius-full);
    font-size: 14px; font-weight: 500; z-index: 300;
    animation: toastIn .3s ease-out;
}
@keyframes toastIn { from { transform: translateX(-50%) translateY(20px); opacity: 0; } }

/* ── Responsive ───────────────────────────────────────────────── */
@media (min-width: 768px) {
    .bottom-nav { display: none; }
    body { padding-bottom: 0; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
    .install-banner { bottom: 16px; }
}
@media (max-width: 600px) {
    .logo-text { display: none; }
    .header-inner { gap: 8px; }
    .app-detail-header { flex-direction: column; align-items: center; text-align: center; }
    .app-detail-stats { justify-content: center; }
}
