/* home.css */

@import url('./app/user.css');
@import url('./app/discover.css');
@import url('./app/government.css');
@import url('./app/community/feed.css');

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

:root {
    --primary: #1e3a8a;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --accent: #0ea5e9;
    --accent-light: #38bdf8;
    --blue: #0284c7;
    --blue-light: #e0f2fe;
    --blue-dark: #075985;
    --bg-light: #f8fafc;
    --bg-cream: #fef9e7;
    --bg-white: #ffffff;
    --text-dark: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: rgba(15, 23, 42, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ── Header nav layout ───────────────────────────────────────
   .nav-links  = page-section links   → hidden on mobile
   .nav-auth   = avatar / bell / CTA  → always visible
*/
.nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

/* Auth controls always sit to the right, always visible */
.nav-auth {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    transition: all 0.2s;
    cursor: pointer;
    font-size: 0.95rem;
}
.nav-link:hover { background: rgba(255,255,255,0.1); color: white; }
.nav-link.active { background: rgba(255,255,255,0.15); color: white; }

.btn-primary {
    background: var(--accent);
    color: white;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.btn-primary:hover { background: var(--accent-light); transform: translateY(-1px); }

.btn-icon-notif {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: white;
}
.btn-icon-notif:hover { background: rgba(255,255,255,0.2); }
.btn-icon-notif svg { display: block; }

/* Hamburger — never used */
.mobile-menu-toggle { display: none !important; }

/* Old FAB — replaced by bottom tab */
.fab-create-post { display: none !important; }

/* ── Utilities ─────────────────────────────────────────────── */
.content-section { display: none; }
.content-section.active { display: block; }

.loading { text-align: center; padding: 3rem; color: var(--text-muted); }

.error-message {
    background: #fee2e2; color: #991b1b;
    padding: 1rem; border-radius: 8px; margin-bottom: 1rem;
}
.success-message {
    background: #dcfce7; color: #166534;
    padding: 1rem; border-radius: 8px; margin-bottom: 1rem;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Toast notifications ────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    background: var(--text-dark);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastIn 0.25s ease, toastOut 0.3s ease 2.2s forwards;
    white-space: nowrap;
    pointer-events: all;
}
.toast.toast-success { background: #166534; border-left: 4px solid var(--success); }
.toast.toast-error   { background: #991b1b; border-left: 4px solid var(--danger); }
@keyframes toastIn  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }

/* ── Bottom tab navigator (mobile only) ─────────────────────── */
.bottom-tab-nav { display: none; }

@media (max-width: 1100px) {
    /* Pad so content doesn't hide behind the bar */
    body { padding-bottom: 68px; }

    /* Hide page nav links — bottom bar handles section switching */
    .nav-links { display: none !important; }

    /* Slim the header slightly */
    .header { padding: 0.625rem 0; }

    /* Show the bottom bar */
    .bottom-tab-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: #fff;
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 16px rgba(15, 23, 42, 0.1);
        z-index: 500;
        align-items: stretch;
        padding-bottom: env(safe-area-inset-bottom);
    }

    .bottom-tab {
        flex: 1;
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-muted);
        font-size: 0.6rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
        transition: color 0.15s;
        padding: 0.5rem 0.25rem;
        -webkit-tap-highlight-color: transparent;
        font-family: inherit;
    }

    .bottom-tab svg {
        width: 22px;
        height: 22px;
        stroke-width: 1.75;
        transition: transform 0.15s;
        flex-shrink: 0;
    }

    .bottom-tab:active svg,
    .bottom-tab:active .bottom-tab-avatar { transform: scale(0.85); }

    .bottom-tab.active { color: var(--accent); }

    /* Active indicator pip */
    .bottom-tab.active::before {
        content: '';
        position: absolute;
        top: 6px;
        width: 20px;
        height: 3px;
        border-radius: 2px;
        background: var(--accent);
    }

    /* Avatar inside the profile tab */
    .bottom-tab-avatar {
        width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--accent);
        color: white;
        font-size: 0.65rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        transition: transform 0.15s;
    }
    .bottom-tab.active .bottom-tab-avatar {
        box-shadow: 0 0 0 2px var(--accent);
    }
}

/* ── Responsive — layout ────────────────────────────────────── */
@media (max-width: 1200px) {
    .feed-layout { grid-template-columns: 1fr; }
    .communities-sidebar, .feed-sidebar { display: none; }
    .nav-links { gap: 1rem; }
    .nav-link { padding: 0.5rem 0.875rem; font-size: 0.9rem; }
    .btn-primary { padding: 0.55rem 1rem; font-size: 0.9rem; }
}

@media (max-width: 768px) {
    .container { padding: 1rem; }
    .header-container { padding: 0 1rem; }
    .stance-selector { grid-template-columns: 1fr; }
    .feed-layout { grid-template-columns: 1fr; gap: 1rem; }
    .communities-sidebar, .feed-sidebar { display: none; }
    .feed-header { padding: 1.25rem; }
    .feed-header h1 { font-size: 1.5rem !important; }
    .feed-header p { font-size: 0.9rem !important; }
    .filter-row { gap: 0.375rem; }
    .chip { padding: 0.4rem 0.75rem; font-size: 0.8rem; }
    .post-card, .bill-card, .legislator-card, .research-card { padding: 1rem; border-left-width: 3px; }
    .post-header { flex-direction: column; align-items: flex-start; }
    .post-vote { order: -1; flex-direction: column; padding: 0.375rem 0.75rem; margin-bottom: 0.75rem; }
    .post-title { font-size: 1rem; }
    .post-content { font-size: 0.9rem; }
    .intelligence-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .intel-card { padding: 1rem; }
    .intel-number { font-size: 2rem; }
    .search-section { padding: 1rem; }
    .search-input { padding: 0.75rem 1rem 0.75rem 2.5rem; font-size: 0.9rem; }
    .modal-content { width: 95%; padding: 1.5rem; max-height: 95vh; }
    #chatModal .modal-content { padding: 0; height: 90vh; max-height: 90vh; }
    #chatModal .modal-header { padding: 1rem; border-bottom: 2px solid var(--border); }
    #chatModal .modal-header h2 { font-size: 1.25rem; }
    #chatModal .close-modal { top: 1rem; right: 1rem; }
    #chatModal > .modal-content > div[style*="display: flex"] { flex-direction: column !important; }
    #conversationsList { width: 100% !important; max-height: 200px !important; border-right: none !important; border-bottom: 2px solid var(--border) !important; }
    #activeChat { flex: 1 !important; }
    .message-bubble { max-width: 85%; padding: 0.625rem 0.875rem; font-size: 0.9rem; }
    .chat-message { margin-bottom: 1rem; }
    #chatMessages { padding: 1rem !important; }
    #chatInput { padding: 0.75rem !important; }
    #chatInput form { flex-direction: column !important; }
    #chatMessageInput { min-height: 60px !important; }
    #chatInput .btn { height: auto !important; padding: 0.75rem 1.5rem !important; }
    .conversation-item { padding: 0.75rem; }
    .conversation-preview { font-size: 0.8rem; }
    .chat-avatar { width: 36px; height: 36px; font-size: 0.9rem; }
}

@media (max-width: 640px) {
    .modal-content { width: 100%; max-width: 100%; padding: 1.5rem; border-radius: 0; max-height: 100vh; }
    .modal-header h2 { font-size: 1.4rem; }
    .close-modal { top: 1rem; right: 1rem; width: 28px; height: 28px; font-size: 1.25rem; }
    .stance-selector { grid-template-columns: 1fr; gap: 0.5rem; }
    .stance-option { padding: 1rem; }
    .form-input, .form-textarea, .form-select { padding: 0.625rem; font-size: 0.9rem; }
    .form-textarea { min-height: 100px; }
    .modal-content form > div[style*="display: flex"] { flex-direction: column !important; }
    .btn { width: 100%; padding: 0.625rem 1rem; font-size: 0.9rem; }
    .bill-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; gap: 0; }
    .bill-tab { padding: 0.625rem 1rem; white-space: nowrap; font-size: 0.85rem; }
    #conversationsList { display: none; }
    #conversationsList.show-mobile { display: block; position: absolute; top: 0; left: 0; width: 100% !important; height: 100% !important; max-height: none !important; z-index: 10; }
    #chatHeader { display: flex; align-items: center; gap: 0.75rem; }
    .chat-back-btn { background: var(--bg-light); border: 1px solid var(--border); border-radius: 6px; padding: 0.5rem; cursor: pointer; display: flex; align-items: center; justify-content: center; }
    .opinion-bar { height: 32px; }
    .opinion-segment { font-size: 0.75rem; }
    .poll-option-content { padding: 0.625rem 0.75rem; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
    .post-footer { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .comment { padding: 0.75rem; }
    .comment-avatar { width: 28px; height: 28px; font-size: 0.75rem; }
    .bill-detail { padding: 1.25rem; }
    .bill-detail h1 { font-size: 1.5rem !important; }
}

@media (hover: none) and (pointer: coarse) {
    .chip { padding: 0.5rem 0.875rem; }
    .vote-btn { padding: 0.5rem 0.75rem; }
    .btn { padding: 0.875rem 1.25rem; }
}