:root {
    --bg-color: #000000;
    --sidebar-bg: #000000;
    --card-bg: #161e27;
    --border-color: #2f3336;
    --text-primary: #e7e9ea;
    --text-secondary: #71767b;
    --accent-color: #ffb400; /* Mercato Gold */
    --accent-hover: #ffc840;
    --offer-color: #00ba7c;
    --request-color: #1d9bf0;
    --sidebar-width: 275px;
    --sidebar-collapsed-width: 88px;
}

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

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(1px 1px at 20px 30px, #fff, rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 150px 200px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 100px 50px, rgba(255,255,255,0.8), rgba(0,0,0,0)),
        radial-gradient(1.2px 1.2px at 300px 150px, #fff, rgba(0,0,0,0)),
        radial-gradient(1px 1px at 250px 400px, rgba(255,255,255,0.7), rgba(0,0,0,0)),
        radial-gradient(1.5px 1.5px at 450px 300px, #fff, rgba(0,0,0,0));
    background-size: 600px 600px;
    background-attachment: fixed;
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.3;
    -webkit-font-smoothing: antialiased;
}

#root {
    display: flex;
    min-height: 100vh;
    justify-content: center;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: sticky;
    top: 0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.logo {
    padding: 12px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo-icon {
    font-size: 1.8rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--accent-color);
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px;
    border-radius: 9999px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.25rem;
    transition: background 0.2s;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
    font-weight: 700;
}

.btn-post-primary {
    margin-top: 24px;
    background-color: var(--accent-color);
    color: #000;
    border: none;
    border-radius: 9999px;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: transform 0.1s, background 0.2s;
}

.btn-post-primary:hover {
    background-color: var(--accent-hover);
    transform: scale(1.02);
}

.user-mini {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 9999px;
    cursor: pointer;
    transition: background 0.2s;
}

.user-mini:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.user-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--accent-color), #555);
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    overflow: hidden;
}

.user-name {
    font-weight: 700;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-handle {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Main Content */
.main-content {
    width: 600px;
    min-height: 100vh;
    border-right: 1px solid var(--border-color);
}

.main-header {
    height: 53px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.main-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Quick Post Prompt */
.quick-post-prompt {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.quick-post-prompt:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.prompt-text {
    flex: 1;
    color: var(--text-secondary);
    font-size: 1.2rem;
}

.prompt-icons {
    display: flex;
    gap: 12px;
    color: var(--accent-color);
    font-size: 1.2rem;
}

/* Welcome Card */
.welcome-card {
    padding: 32px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.welcome-card h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: var(--accent-color);
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-compact {
    display: flex;
    max-width: 320px;
    margin: 0 auto;
    gap: 8px;
}

.login-compact input {
    flex: 1;
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 8px;
    color: white;
}

.login-compact button {
    background: var(--accent-color);
    border: none;
    padding: 0 20px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

/* Feed Items */
.feed-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.feed-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.item-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #222;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.item-avatar-subtle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    color: #444;
}

.item-avatar-inline {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
    color: #666;
}

.item-body {
    flex: 1;
}

.item-header {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 4px;
}

.item-author {
    font-weight: 700;
}

.item-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Listing Card Style */
.listing-card {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    margin-top: 8px;
}

.listing-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 900;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.type-offer { background: rgba(0, 186, 124, 0.1); color: var(--offer-color); border: 1px solid rgba(0, 186, 124, 0.3); }
.type-request { background: rgba(29, 155, 240, 0.1); color: var(--request-color); border: 1px solid rgba(29, 155, 240, 0.3); }

.listing-title {
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.listing-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.listing-trade {
    display: flex;
    gap: 16px;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.listing-loc {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--accent-color);
}

/* Right Sidebar */
.right-sidebar {
    width: 350px;
    padding: 12px 24px;
    display: block; /* Visible by default, width/position handled by media queries */
}

@media (max-width: 1000px) {
    .right-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border-color);
    }
}

.search-bar {
    background-color: #202327;
    border-radius: 9999px;
    padding: 10px 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 16px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: white;
    outline: none;
    flex: 1;
}

.stats-card {
    background-color: #16181c;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

.stats-card h3 {
    margin-bottom: 16px;
    font-size: 1.25rem;
}

.stat-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-color);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-links {
    margin-top: 24px;
    padding: 0 16px;
    font-size: 0.8rem;
    color: #71767b;
    line-height: 1.6;
}

.footer-links div {
    margin-bottom: 4px;
}

.footer-links a {
    color: inherit;
    text-decoration: underline;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--accent-color);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(91, 112, 131, 0.4);
    backdrop-filter: blur(2px);
    display: none;
    justify-content: center;
    align-items: flex-start;
    padding-top: 5vh;
    z-index: 1000;
}

.modal-card {
    background: #000;
    width: 100%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-close-modal {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.btn-close-modal:hover { background: rgba(255, 255, 255, 0.1); }

.btn-submit-top {
    background: var(--accent-color);
    color: #000;
    border: none;
    padding: 6px 16px;
    border-radius: 9999px;
    font-weight: 700;
    cursor: pointer;
}

.modal-form {
    padding: 0 16px 16px;
}

.form-main {
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
}

.input-area { flex: 1; }

.title-input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    outline: none;
    margin-bottom: 8px;
}

.desc-input {
    width: 100%;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: var(--text-secondary);
    outline: none;
    resize: none;
    min-height: 100px;
}

.photo-uploader {
    margin: 16px 0;
}

.photo-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-color);
    font-weight: 700;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px dashed var(--border-color);
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.preview-img {
    aspect-ratio: 1;
    border-radius: 8px;
    background-size: cover;
    background-position: center;
    border: 1px solid var(--border-color);
}

.listing-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 12px;
    display: block;
}

.listing-detail-image {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
}

.trade-details {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.form-details {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.role-selector {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.radio-chip {
    cursor: pointer;
}

.radio-chip input { display: none; }
.radio-chip span {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    font-weight: 700;
    transition: all 0.2s;
}

.radio-chip input:checked + span {
    background: var(--accent-color);
    color: #000;
    border-color: var(--accent-color);
}

.detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.input-group input {
    width: 100%;
    background: #111;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    color: white;
}

.location-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.location-row {
    display: flex;
    gap: 8px;
}

.location-row input {
    flex: 1;
    background: #111;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    color: white;
}

.btn-geo {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 0 12px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.geo-label {
    margin-top: 4px;
    font-size: 0.8rem;
    color: var(--offer-color);
}

/* Location Tabs */
.location-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.loc-tab {
    flex: 1;
    padding: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.loc-tab:hover {
    border-color: var(--accent-color);
}

.loc-tab.active {
    background: var(--accent-color);
    color: var(--bg-color);
    border-color: var(--accent-color);
}

.loc-panel {
    margin-bottom: 10px;
}

#loc-manual input[type="number"] {
    flex: 1;
    background: #111;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    color: white;
}

#loc-manual button {
    background: var(--accent-color);
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    color: #000;
    font-weight: 700;
    cursor: pointer;
}

#picker-map {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.location-group input[type="text"] {
    width: 100%;
    background: #111;
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 8px;
    color: white;
}

/* Profile Hover Card */
.hover-card {
    position: fixed;
    width: 300px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: none;
    pointer-events: none;
}

.hover-card.visible {
    display: block;
}

.hover-card-header {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.hover-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(45deg, var(--accent-color), #555);
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.hover-card-names {
    flex: 1;
    overflow: hidden;
}

.hover-card-display {
    font-weight: 700;
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hover-card-handle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hover-card-bio {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 12px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.hover-card-stats {
    display: flex;
    gap: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.hover-card-stats strong {
    color: var(--text-primary);
}

/* Hoverable elements in feed */
.hoverable {
    cursor: pointer;
}

.hoverable:hover {
    text-decoration: underline;
}

/* Speech-to-text input */
.input-with-mic {
    position: relative;
    display: flex;
    align-items: flex-start;
}

.input-with-mic input,
.input-with-mic textarea {
    flex: 1;
    padding-right: 40px;
}

.btn-mic {
    position: absolute;
    right: 4px;
    top: 4px;
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: all 0.2s;
    opacity: 0.5;
}

.btn-mic:hover {
    opacity: 1;
    background: rgba(255, 180, 0, 0.2);
}

.btn-mic.recording {
    opacity: 1;
    color: #ff4444;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.preview-img {
    position: relative;
}

.preview-size {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 0.65rem;
    padding: 2px 5px;
    border-radius: 4px;
}

.preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    border-radius: 50%;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.preview-remove:hover {
    opacity: 1;
    background: #ff4444;
}

/* Response for Mobile */
@media (max-width: 600px) {
    #root {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: 64px;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border-color);
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(20px);
        padding: 0 10px;
        justify-content: space-around;
        z-index: 1000;
        margin: 0;
    }

    .logo {
        display: none;
    }

    .nav-links {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        gap: 0;
        flex: 1;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px;
        border-radius: 0;
        flex: 1;
        align-items: center;
        justify-content: center;
        height: 100%;
    }

    .nav-item:hover { background: transparent; }

    .nav-icon {
        font-size: 1.4rem;
        margin: 0;
    }

    .nav-label {
        display: block !important;
        font-size: 0.65rem;
    }

    .user-mini {
        margin-top: 0;
        padding: 0;
        width: 60px;
        justify-content: center;
        height: 100%;
    }

    .user-info {
        display: none !important;
    }

    .user-avatar-small {
        width: 28px;
        height: 28px;
    }

    .btn-post-primary {
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 2rem;
        box-shadow: 0 4px 15px rgba(255, 180, 0, 0.4);
        margin: 0;
        z-index: 1001;
    }

    .btn-post-primary span {
        display: none !important;
    }

    .btn-post-primary::before {
        content: "＋";
        font-weight: 300;
    }

    .main-content {
        width: 100% !important;
        border-right: none;
        padding-bottom: 80px; /* Space for fixed bottom bar */
    }

    .right-sidebar {
        display: block;
        width: 100% !important;
        border-left: none;
        border-top: 1px solid var(--border-color);
        padding: 40px 20px 100px 20px; /* Extra bottom padding for the fixed nav */
        position: relative;
        top: auto;
        background: var(--bg-dark);
    }

    /* Modal adjustments for mobile */
    .modal-card {
        max-width: 100%;
        height: 100%;
        border-radius: 0;
    }
    
    .modal-overlay {
        padding-top: 0;
    }

    /* Listing detail mobile tweaks */
    .listing-detail-image {
        height: 300px;
        border-radius: 0;
        margin: 0 -20px; /* Pull to edges */
    }
    
    .main-header {
        width: 100%;
    }
}
