/* Community Layout - Shared 3-column layout CSS */
/* Extracted from dashboard.html for consistency across all community pages */

:root {
    --accent: #ff914d;
    --accent-hover: #ff7a2e;
    --accent-red: #ff6b6b;
    --gradient: linear-gradient(135deg, #ff914d, #ffde59);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --transition: 0.2s ease;
    --sidebar-w: 260px;
    --right-w: 320px;
}

[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #16181c;
    --bg-tertiary: #1d1f23;
    --bg-hover: #1d1f23;
    --bg-card: #16181c;
    --border-color: #2f3336;
    --text-primary: #e7e9ea;
    --text-secondary: #71767b;
    --text-tertiary: #536471;
    --text-link: #ff914d;
    --icon-color: #71767b;
    --overlay: rgba(91, 112, 131, 0.4);
    --nav-active-bg: rgba(255, 145, 77, 0.1);
    --card-shadow: none;
    --input-bg: #16181c;
    --badge-bg: #1d1f23;
}

[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f9f9;
    --bg-tertiary: #eff3f4;
    --bg-hover: #f7f9f9;
    --bg-card: #ffffff;
    --border-color: #eff3f4;
    --text-primary: #0f1419;
    --text-secondary: #536471;
    --text-tertiary: #71767b;
    --text-link: #ff914d;
    --icon-color: #536471;
    --overlay: rgba(0, 0, 0, 0.4);
    --nav-active-bg: rgba(255, 145, 77, 0.1);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.04);
    --input-bg: #f7f9f9;
    --badge-bg: #eff3f4;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
img { max-width: 100%; }

/* 3-COLUMN LAYOUT */
.app-layout {
    display: flex;
    max-width: 1280px;
    margin: 0 auto;
    min-height: 100vh;
}

/* LEFT SIDEBAR */
.sidebar-left {
    width: var(--sidebar-w);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}
.sidebar-logo { padding: 0.75rem; margin-bottom: 0.25rem; }
.sidebar-logo img { height: 36px; display: block; }
.nav-items { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: flex; align-items: center; gap: 1rem; padding: 0.75rem 1rem;
    border-radius: var(--radius-full); color: var(--text-primary);
    font-size: 1.05rem; font-weight: 400;
    transition: background var(--transition), color var(--transition); white-space: nowrap;
}
.nav-item:hover { background: var(--bg-hover); }
.nav-item.active { font-weight: 700; }
.nav-item svg { width: 24px; height: 24px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; }
.nav-item.active svg { stroke-width: 2.5; }
.nav-item .nav-badge {
    margin-left: auto; background: var(--accent); color: #fff;
    font-size: 0.7rem; font-weight: 700; padding: 0.1rem 0.45rem;
    border-radius: var(--radius-full); min-width: 18px; text-align: center;
}
.nav-cta {
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient); color: #fff; font-weight: 700; font-size: 1rem;
    padding: 0.85rem; border-radius: var(--radius-full); border: none;
    width: 100%; margin-top: 1rem;
    transition: opacity var(--transition), transform var(--transition);
}
.nav-cta:hover { opacity: 0.9; transform: scale(1.02); }

/* Sidebar user */
.sidebar-user {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem;
    border-radius: var(--radius-full); margin-top: auto;
    transition: background var(--transition); cursor: pointer; position: relative;
}
.sidebar-user:hover { background: var(--bg-hover); }
.sidebar-user .avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--gradient); display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.95rem; flex-shrink: 0; overflow: hidden;
}
.sidebar-user .avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-info .name { font-weight: 700; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-info .handle { color: var(--text-secondary); font-size: 0.8rem; }
.sidebar-user .more-icon { color: var(--text-secondary); flex-shrink: 0; }

.user-dropdown {
    position: absolute; bottom: 100%; left: 0; right: 0;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-lg); box-shadow: 0 0 15px rgba(0,0,0,0.2);
    padding: 0.5rem 0; display: none; margin-bottom: 0.5rem; z-index: 100;
}
.user-dropdown.show { display: block; }
.user-dropdown a, .user-dropdown button {
    display: block; width: 100%; text-align: left; padding: 0.75rem 1rem;
    color: var(--text-primary); background: none; border: none;
    font-size: 0.9rem; font-weight: 500; transition: background var(--transition);
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg-hover); }
.user-dropdown .danger { color: #f4212e; }

/* MAIN CONTENT */
.main-content { flex: 1; min-width: 0; border-right: 1px solid var(--border-color); }
.main-header {
    position: sticky; top: 0; z-index: 50;
    background: var(--bg-primary); border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem; display: flex; align-items: center; justify-content: space-between;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
}
.main-header h1 { font-size: 1.25rem; font-weight: 800; }
.main-header .header-actions { display: flex; align-items: center; gap: 0.5rem; }

/* Theme toggle */
.theme-toggle {
    background: none; border: none; padding: 0.5rem;
    border-radius: 50%; color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: block; }
[data-theme="light"] .icon-sun { display: block; }
[data-theme="light"] .icon-moon { display: none; }

/* RIGHT SIDEBAR */
.sidebar-right {
    width: var(--right-w); position: sticky; top: 0; height: 100vh;
    overflow-y: auto; padding: 0.75rem 1.25rem; flex-shrink: 0;
}
.sidebar-right::-webkit-scrollbar { width: 0; }

.search-box { position: relative; margin-bottom: 1rem; }
.search-box input {
    width: 100%; padding: 0.7rem 1rem 0.7rem 2.75rem;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-full); color: var(--text-primary);
    font-size: 0.9rem; font-family: inherit;
    transition: border-color var(--transition), background var(--transition);
}
.search-box input::placeholder { color: var(--text-secondary); }
.search-box input:focus { outline: none; border-color: var(--accent); background: var(--bg-primary); }
.search-box svg {
    position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--text-secondary);
}

.right-card {
    background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-xl); margin-bottom: 1rem; overflow: hidden;
}
.right-card-header { padding: 0.875rem 1rem; font-size: 1.1rem; font-weight: 800; }
.right-card-footer { padding: 0.75rem 1rem; }
.right-card-footer a { color: var(--accent); font-size: 0.85rem; font-weight: 500; }
.right-card-footer a:hover { text-decoration: underline; }

/* Leaderboard rows */
.lb-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; transition: background var(--transition);
}
.lb-row:hover { background: var(--bg-hover); }
.lb-rank { width: 26px; font-weight: 800; font-size: 0.85rem; text-align: center; color: var(--text-secondary); }
.lb-rank.gold { color: #fbbf24; }
.lb-rank.silver { color: #94a3b8; }
.lb-rank.bronze { color: #d97706; }
.lb-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.85rem; flex-shrink: 0; overflow: hidden;
}
.lb-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lb-info { flex: 1; min-width: 0; }
.lb-info .lb-name { font-weight: 700; font-size: 0.875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-points { font-weight: 700; font-size: 0.85rem; color: var(--accent); flex-shrink: 0; }

/* Badge pills */
.badge-list { padding: 0.5rem 1rem 1rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.badge-pill {
    display: flex; align-items: center; gap: 0.4rem;
    background: var(--badge-bg); border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem; border-radius: var(--radius-full);
    font-size: 0.8rem; font-weight: 500; transition: border-color var(--transition);
}
.badge-pill:hover { border-color: var(--accent); }
.badge-pill .badge-icon { font-size: 1rem; }

/* Quick actions */
.quick-actions { padding: 0.75rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.action-btn {
    display: flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.7rem 1rem; border-radius: var(--radius-full);
    font-weight: 700; font-size: 0.875rem; border: none;
    transition: all var(--transition); text-decoration: none;
}
.action-btn.primary { background: var(--gradient); color: #fff; }
.action-btn.primary:hover { opacity: 0.9; }
.action-btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.action-btn.secondary:hover { background: var(--nav-active-bg); }
.action-btn svg { width: 18px; height: 18px; }

/* Sidebar footer */
.sidebar-footer { padding: 1rem 0; }
.sidebar-footer p { font-size: 0.75rem; color: var(--text-tertiary); line-height: 1.6; }
.sidebar-footer a { color: var(--text-tertiary); font-size: 0.75rem; }
.sidebar-footer a:hover { text-decoration: underline; }

/* MOBILE BOTTOM NAV */
.mobile-nav {
    display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: var(--bg-primary); border-top: 1px solid var(--border-color);
    z-index: 200; padding: 0.4rem 0 calc(0.4rem + env(safe-area-inset-bottom, 0px));
}
.mobile-nav-items { display: flex; justify-content: space-around; align-items: center; }
.mobile-nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 0.15rem;
    padding: 0.4rem 0.75rem; color: var(--text-secondary);
    font-size: 0.65rem; font-weight: 500; border-radius: var(--radius-sm);
    transition: color var(--transition); text-decoration: none;
}
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item svg { width: 24px; height: 24px; }

/* Mobile header */
.mobile-header {
    display: none; position: sticky; top: 0; z-index: 100;
    background: var(--bg-primary); border-bottom: 1px solid var(--border-color);
    padding: 0.6rem 1rem; align-items: center; justify-content: space-between;
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg-primary) 85%, transparent);
}
.mobile-header .mobile-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 0.8rem; overflow: hidden;
}
.mobile-header .mobile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mobile-header .mobile-logo img { height: 28px; }

/* RESPONSIVE */
@media (max-width: 1100px) { .sidebar-right { width: 280px; } }
@media (max-width: 1000px) { .sidebar-right { display: none; } .main-content { border-right: none; } }
@media (max-width: 768px) {
    .sidebar-left { display: none; }
    .mobile-header { display: flex; }
    .mobile-nav { display: block; }
    .main-content { padding-bottom: 70px; border-right: none; }
    .main-header { display: none; }
}

/* Scrollbar */
[data-theme="dark"] ::-webkit-scrollbar { width: 4px; }
[data-theme="dark"] ::-webkit-scrollbar-track { background: transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }

/* Fade animation */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease forwards; }

/* ===== PWA / MOBILE RESPONSIVE ADDITIONS ===== */

/* iOS safe area for standalone PWA */
@supports (padding-top: env(safe-area-inset-top)) {
    .mobile-header {
        padding-top: calc(0.6rem + env(safe-area-inset-top));
    }
    body.pwa-standalone .sidebar-left {
        padding-top: env(safe-area-inset-top);
    }
}

/* Tighter layout on small phones (360px and below) */
@media (max-width: 380px) {
    .main-content { padding: 0; }
    .mobile-header { padding: 0.5rem 0.75rem; }
    .mobile-header .mobile-logo img { height: 24px; }
}

/* Tool pages inside PWA — full width, no overflow */
.tool-content {
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

/* Responsive tool nav on small screens */
@media (max-width: 480px) {
    .tool-nav { padding: 0.75rem 1rem; }
    .tool-nav h1 { font-size: 1rem; }
    .tool-content { padding: 1.25rem 1rem; }
    .calc-grid { grid-template-columns: 1fr !important; }
    .location-input { flex-wrap: wrap; }
    .location-input input { min-width: 120px; flex: 1 1 120px; }
    .location-input button { flex: 1 1 auto; }
}

/* Prevent horizontal scroll on all community pages */
html, body { overflow-x: hidden; max-width: 100vw; }
