/* new-layout.css - Refined High-Fidelity Design */
/* Clean white, light grey, emerald green color scheme */

:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    --secondary-color: #ec4899;
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --tab-bar-height: 60px;
}

/* Reset and base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Main Layout Container */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Bottom Tab Bar (Mobile) */
.bottom-tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background: var(--sidebar-bg);
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    padding: 0 8px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.tab-button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
}

.tab-button.active {
    color: var(--primary-color);
}

.tab-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    stroke-width: 2;
}

.tab-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.tab-button .badge {
    position: absolute;
    top: 4px;
    right: 50%;
    transform: translateX(12px);
    background: var(--secondary-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    font-weight: 600;
}

/* Tab Content Areas */
.tab-content {
    display: none;
    flex-direction: column;
    height: calc(100vh - var(--tab-bar-height));
    overflow: hidden;
    background: var(--bg-color);
}

.tab-content.active {
    display: flex;
}

/* ==================== TRIBES TAB ==================== */

.tribes-header {
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
    width: 20px;
    height: 20px;
    stroke: var(--text-tertiary);
    margin-right: 10px;
    flex-shrink: 0;
}

.search-bar input {
    border: none;
    background: none;
    outline: none;
    flex: 1;
    font-size: 15px;
    color: var(--text-primary);
}

.search-bar input::placeholder {
    color: var(--text-tertiary);
}

.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 2px 0;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-chip:hover {
    background: var(--card-bg);
    border-color: var(--primary-color);
}

.filter-chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Tribes Feed */
.tribes-feed {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0;
}

.post-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
}

.post-card:hover {
    box-shadow: var(--shadow-lg);
}

.post-header {
    margin-bottom: 12px;
}

.tribe-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-color);
    padding: 6px 12px;
    border-radius: 20px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.tribe-badge:hover {
    background: var(--primary-light);
}

.tribe-badge img {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.tribe-emoji {
    font-size: 16px;
}

.tribe-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.post-author {
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.post-author:hover {
    color: var(--primary-color);
}

.post-time {
    color: var(--text-tertiary);
}

.post-content {
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 14px;
    cursor: pointer;
}

.post-content a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.post-content a:hover {
    text-decoration: underline;
}

.post-content .mention {
    color: var(--primary-color);
    font-weight: 600;
    cursor: pointer;
}

.post-content .mention:hover {
    text-decoration: underline;
}

.post-content .hashtag {
    color: var(--primary-color);
    font-weight: 600;
}

.post-actions {
    display: flex;
    gap: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.action-btn.liked {
    color: var(--secondary-color);
}

.action-btn.liked:hover {
    background: rgba(236, 72, 153, 0.1);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* FAB (Floating Action Button) */
.fab {
    position: fixed;
    bottom: calc(var(--tab-bar-height) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 50;
}

.fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 20px rgba(16, 185, 129, 0.5);
}

.fab:active {
    transform: scale(0.95);
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* Feed States */
.feed-loading,
.feed-empty,
.feed-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.feed-empty .empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.feed-empty h3 {
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}

.feed-empty p {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-retry {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

/* ==================== DESKTOP SIDEBAR ==================== */

.desktop-sidebar {
    display: none;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo-icon {
    font-size: 32px;
    line-height: 1;
}

.sidebar-logo-text {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    padding: 16px 0;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    position: relative;
}

.sidebar-nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
    border-radius: 0 3px 3px 0;
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.sidebar-nav-item:hover {
    background: var(--bg-color);
}

.sidebar-nav-item.active {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.sidebar-nav-item.active::before {
    transform: scaleY(1);
}

.sidebar-nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.sidebar-nav-label {
    flex: 1;
}

.sidebar-nav-badge {
    background: var(--secondary-color);
    color: white;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    min-width: 22px;
    text-align: center;
    font-weight: 700;
}

.sidebar-section {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-tertiary);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.sidebar-tribe-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-tribe-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-tribe-item:hover {
    background: var(--bg-color);
}

.sidebar-tribe-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    box-shadow: var(--shadow-sm);
}

.sidebar-tribe-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.sidebar-tribe-unread {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--primary-color);
    flex-shrink: 0;
    box-shadow: 0 0 0 2px var(--sidebar-bg);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--sidebar-bg);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.sidebar-user:hover {
    background: var(--bg-color);
}

.sidebar-user-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.sidebar-user-status {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

/* ==================== DESKTOP RIGHT PANEL ==================== */

.desktop-right-panel {
    display: none;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.right-panel-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.right-panel-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.trending-post-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: var(--bg-color);
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.trending-post-item:hover {
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.trending-post-content {
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    color: var(--text-primary);
}

.trending-post-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 600;
}

.suggested-tribe-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.suggested-tribe-item:hover {
    background: var(--card-bg);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.suggested-tribe-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    flex-shrink: 0;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
}

.suggested-tribe-info {
    flex: 1;
    min-width: 0;
}

.suggested-tribe-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.suggested-tribe-members {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 600;
}

.online-members-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.online-member-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.online-member-item:hover {
    background: var(--bg-color);
}

.online-member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.online-member-avatar::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border: 2px solid var(--sidebar-bg);
    border-radius: 50%;
}

.online-member-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ==================== MODALS ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-overlay.hidden {
    display: none;
}

.modal-container {
    background: var(--card-bg);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    box-shadow: var(--shadow-lg);
}

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

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: var(--bg-color);
}

/* ==================== RESPONSIVE ==================== */

/* Tablet */
@media (min-width: 768px) {
    .bottom-tab-bar {
        display: none;
    }

    #app-container {
        flex-direction: row;
    }

    .tab-content {
        height: 100vh;
        background: var(--bg-color);
    }

    /* Show desktop sidebar */
    .desktop-sidebar {
        display: flex !important;
        width: 280px;
        flex-direction: column;
    }

    .fab {
        bottom: 24px;
    }

    /* Center content area */
    #mainContent {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    /* Header spans full width */
    .tribes-header {
        width: 100%;
        padding: 16px 20px;
    }

    /* But search bar and filters are constrained */
    .tribes-header .search-bar,
    .tribes-header .filter-chips {
        max-width: 100%;
    }

    /* Feed content is centered */
    .tribes-feed,
    .discover-content {
        padding: 20px;
        width: 100%;
        max-width: 100%;
        align-self: center;
    }

    /* Conversation list should have no outer padding — items handle their own */
    .chats-list {
        padding: 0;
        width: 100%;
    }

    .post-card:first-child {
        margin-top: 0;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .desktop-sidebar {
        width: 280px;
    }

    .tribes-header {
        padding: 20px 32px;
    }

    .tribes-feed,
    .discover-content {
        max-width: none;
        width: 100%;
        padding: 24px 32px;
    }
}

/* Large Desktop - Show right panel */
@media (min-width: 1280px) {
    .desktop-right-panel {
        display: flex !important;
        width: 340px;
        flex-direction: column;
    }

    .tribes-header {
        padding: 20px 40px;
    }

    .tribes-feed,
    .discover-content {
        max-width: 800px;
        padding: 24px 40px;
    }

    .desktop-sidebar {
        width: 300px;
    }
}

/* Extra Large Desktop - More breathing room */
@media (min-width: 1600px) {
    .tribes-header {
        padding: 20px 60px;
    }

    .tribes-feed,
    .discover-content {
        max-width: 900px;
        padding: 24px 60px;
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: calc(var(--tab-bar-height) + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-primary);
    color: white;
    padding: 14px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 2000;
    animation: toastSlide 0.3s ease;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 768px) {
    .toast {
        bottom: 20px;
    }
}

@keyframes toastSlide {
    from {
        transform: translate(-50%, 100px);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Login Screen Override */
#loginScreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#loginScreen.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

