/* =====================================================================
   PULLY — stile minimal, colori presi dal logo (rosa/magenta -> rosso)
   ===================================================================== */

:root {
    --primary: #ff0073;
    --primary-2: #ff2e63;
    --primary-dark: #c2005a;
    --gradient: linear-gradient(135deg, #ff0073, #ff2e63);
    --bg: #faf9fb;
    --surface: #ffffff;
    --border: #eeeef1;
    --text: #17151a;
    --text-muted: #8a8891;
    --danger: #ff3b3b;
    --radius: 14px;
    --radius-sm: 9px;
    --nav-height: 64px;
    --header-height: 56px;
    --shadow: 0 2px 10px rgba(20, 10, 20, 0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

.hidden { display: none !important; }

/* ---------- Layout base ---------- */

.page-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-header h1 {
    font-size: 19px;
    font-weight: 700;
    margin: 0;
}
.page-header-back .back-btn {
    font-size: 20px;
    line-height: 1;
    padding: 4px 8px 4px 0;
    color: var(--text);
}

.page-content {
    padding: 16px 16px calc(var(--nav-height) + 24px);
    max-width: 560px;
    margin: 0 auto;
    min-height: calc(100vh - var(--header-height));
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 10px;
    font-size: 14px;
}

.hint {
    color: var(--text-muted);
    font-size: 13px;
    margin: 10px 2px;
}

/* ---------- Bottom navbar ---------- */

.navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 30;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 10px;
    flex: 1;
    padding: 6px 0;
}
.nav-item svg { width: 22px; height: 22px; }
.nav-item.active { color: var(--primary); }
.nav-item.disabled { opacity: 0.35; }
.nav-create { flex: 0.9; }
.fab {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 300;
    box-shadow: 0 4px 12px rgba(255, 0, 115, 0.35);
}
.fab-create {
    position: fixed;
    right: 20px;
    bottom: calc(var(--nav-height) + 16px);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 14px rgba(255, 0, 115, 0.4);
    z-index: 25;
}

/* ---------- Bottoni / form ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--gradient); color: #fff; }
.btn-primary:active { opacity: 0.85; }
.btn-secondary { background: #f1eef2; color: var(--text); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(255,59,59,0.3); margin-top: 8px; }
.btn:disabled { opacity: 0.5; }

.stacked-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.stacked-form label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 8px; }
.stacked-form input[type="text"],
.stacked-form input[type="password"],
.stacked-form select,
.stacked-form textarea,
#group-search {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 15px;
    color: var(--text);
    width: 100%;
}
.stacked-form textarea { resize: vertical; min-height: 70px; }
.optional { font-weight: 400; color: var(--text-muted); }

.alert {
    background: #fff0f0;
    color: var(--danger);
    border: 1px solid rgba(255,59,59,0.25);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin: 10px 0;
}
.form-feedback { font-size: 13px; margin-top: 4px; min-height: 16px; }
.form-feedback.success { color: #1d9a4a; }
.form-feedback.error { color: var(--danger); }

/* ---------- Auth ---------- */

.auth-page main, .auth-wrap {
    max-width: 380px;
    margin: 0 auto;
    padding: 60px 24px 40px;
    text-align: center;
}
.auth-logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 18px; }
.auth-title { font-size: 24px; margin: 0 0 4px; font-weight: 800; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }
.auth-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth-form input {
    padding: 13px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 15px;
}
.auth-switch { margin-top: 20px; font-size: 13px; color: var(--text-muted); }
.auth-switch a { color: var(--primary); font-weight: 600; }

/* ---------- Badges / chips ---------- */

.badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
}
.badge-public { background: #e7f7ee; color: #1d9a4a; }
.badge-private { background: #fff1e0; color: #cf7c00; }

.chip {
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    background: #f1eef2;
    color: var(--text);
    border: none;
    cursor: pointer;
}
.chip-danger { background: #fff0f0; color: var(--danger); }

/* ---------- Gruppi: slot ---------- */

.slots { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.slot {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.slot-empty {
    justify-content: center;
    flex-direction: column;
    color: var(--text-muted);
    border-style: dashed;
    padding: 26px 16px;
    gap: 6px;
}
.slot-plus { font-size: 26px; color: var(--primary); }
.slot-name-row { display: flex; align-items: center; gap: 8px; }
.slot-name { font-weight: 700; font-size: 15px; }
.slot-members { font-size: 12px; color: var(--text-muted); }
.slot-info { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Tabs (group_browse) ---------- */

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 13px;
}
.tab-btn.active { background: var(--gradient); color: #fff; border-color: transparent; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.group-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.group-list-item {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px;
}
.group-list-item .glm-name { font-weight: 700; font-size: 14px; }
.group-list-item .glm-sub { font-size: 12px; color: var(--text-muted); }

.segmented { display: flex; gap: 8px; }
.segmented-opt { flex: 1; }
.segmented-opt input { display: none; }
.segmented-opt span {
    display: block; text-align: center; padding: 10px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    font-size: 13px; font-weight: 600; color: var(--text-muted);
}
.segmented-opt input:checked + span { background: var(--gradient); color: #fff; border-color: transparent; }

.create-result { text-align: center; margin-top: 20px; }
.invite-code {
    font-size: 28px; font-weight: 800; letter-spacing: 4px;
    background: #fff0f6; color: var(--primary-dark);
    border-radius: var(--radius-sm); padding: 14px; margin: 14px 0;
}

/* ---------- Post card ---------- */

.post-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.post-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px;
}
.post-card-user { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; }
.post-card-meta { font-size: 11px; color: var(--text-muted); font-weight: 400; }
.rarity-badge {
    font-size: 10px; font-weight: 800; letter-spacing: 0.3px;
    padding: 4px 9px; border-radius: 20px; color: #fff; text-transform: uppercase;
}
.post-card-img-wrap { width: 100%; aspect-ratio: 1 / 1; background: #f2f2f4; }
.post-card-img-wrap img { width: 100%; height: 100%; object-fit: cover; }
.post-card-body { padding: 10px 14px 14px; }
.post-card-group { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.post-card-desc { font-size: 13px; margin: 4px 0 8px; }

.post-actions { display: flex; align-items: center; gap: 18px; padding: 4px 14px 10px; }
.action-btn {
    display: flex; align-items: center; gap: 6px;
    background: none; border: none; color: var(--text-muted);
    font-size: 13px; font-weight: 600; cursor: pointer; padding: 4px 0;
}
.action-btn svg { width: 20px; height: 20px; }
.action-btn.liked { color: var(--primary); }
.action-btn.liked svg { fill: var(--primary); stroke: var(--primary); }

.comments-section { border-top: 1px solid var(--border); padding: 10px 14px; display: none; }
.comments-section.open { display: block; }
.comment-item { display: flex; gap: 6px; font-size: 13px; margin-bottom: 8px; align-items: baseline; }
.comment-item b { font-weight: 700; }
.comment-time { font-size: 10px; color: var(--text-muted); margin-left: 4px; }
.comment-form { display: flex; gap: 8px; margin-top: 6px; }
.comment-form input {
    flex: 1; border: 1px solid var(--border); border-radius: 20px;
    padding: 9px 14px; font-size: 13px;
}
.comment-form button {
    border: none; background: var(--gradient); color: #fff; border-radius: 20px;
    padding: 0 16px; font-size: 13px; font-weight: 700;
}

/* ---------- Gruppo header ---------- */

.group-header { flex-direction: row; align-items: flex-start; }
.group-header-main { flex: 1; }
.group-title-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.group-title-row h1 { font-size: 18px; }
.group-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Membri / Classifica ---------- */

.member-item, .lb-item {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px;
}
.avatar-circle {
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--gradient); color: #fff; display: flex;
    align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
    flex-shrink: 0;
}
.member-name { font-weight: 600; font-size: 14px; flex: 1; }
.owner-tag { font-size: 10px; color: var(--primary); font-weight: 700; }
.lb-rank { font-weight: 800; color: var(--text-muted); width: 22px; text-align: center; }
.lb-points { margin-left: auto; font-weight: 800; color: var(--primary-dark); font-size: 14px; }
.lb-item:nth-child(1) .lb-rank { color: #ffb400; }
.lb-item:nth-child(2) .lb-rank { color: #9a9a9a; }
.lb-item:nth-child(3) .lb-rank { color: #c27a3b; }

/* ---------- Crea Post ---------- */

.photo-picker { position: relative; display: block; cursor: pointer; margin-bottom: 4px; }
.photo-picker input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-placeholder {
    aspect-ratio: 1/1; border: 2px dashed var(--border); border-radius: var(--radius);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 8px; color: var(--text-muted); font-size: 13px; background: var(--surface);
}
.photo-icon { font-size: 34px; }
#photo-preview { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: var(--radius); }

/* ---------- Chat ---------- */

.chat-page .page-content { display: none; }
.chat-messages {
    padding: 14px 14px calc(var(--nav-height) + 70px);
    max-width: 560px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 10px;
    min-height: calc(100vh - var(--header-height) - 56px);
}
.chat-bubble-row { display: flex; flex-direction: column; max-width: 78%; }
.chat-bubble-row.mine { align-self: flex-end; align-items: flex-end; }
.chat-bubble-row.theirs { align-self: flex-start; align-items: flex-start; }
.chat-author { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; padding: 0 4px; }
.chat-bubble {
    padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.35;
    word-break: break-word;
}
.chat-bubble-row.mine .chat-bubble { background: var(--gradient); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble-row.theirs .chat-bubble { background: #f1eef2; color: var(--text); border-bottom-left-radius: 4px; }
.chat-time { font-size: 10px; color: var(--text-muted); margin-top: 2px; padding: 0 4px; }

.chat-input-bar {
    position: fixed; left: 0; right: 0; bottom: var(--nav-height);
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 10px 12px; display: flex; gap: 8px; z-index: 25;
}
.chat-input-bar input {
    flex: 1; border: 1px solid var(--border); border-radius: 22px;
    padding: 11px 16px; font-size: 14px;
}
.chat-send-btn {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--gradient); color: #fff; font-size: 16px; flex-shrink: 0;
}

/* ---------- Impostazioni ---------- */

.settings-block {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
}
.settings-block h2 { font-size: 15px; margin: 0 0 10px; }

@media (min-width: 640px) {
    .navbar, .chat-input-bar { max-width: 560px; left: 50%; transform: translateX(-50%); }
}
