/* Mobile Specific Styles for The Red */
@media (max-width: 768px) {
    :root {
        --spacing-sm: 8px;
        --spacing-md: 12px;
        --spacing-lg: 16px;
        --spacing-xl: 24px;
        --radius-md: 16px;
    }

    /* Layout Adjustments */
    .app-container {
        flex-direction: column;
    }

    .main-content {
        padding: 12px;
        padding-bottom: 90px;
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    .feed-container {
        width: 100%;
        max-width: 100%;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    /* Top Bar - More compact and elegant */
    .top-bar {
        padding: 10px 16px;
        position: sticky;
        top: 0;
        background: rgba(15, 5, 20, 0.98);
        z-index: 1002;
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }

    .top-bar .logo img {
        height: 28px !important;
    }

    .top-bar .avatar {
        width: 28px !important;
        height: 28px !important;
    }

    /* Profile Card Refinement */
    .glass-panel.profile-card-container {
        border-radius: var(--radius-md) !important;
    }

    .profile-header {
        margin-bottom: 0;
    }

    .cover-photo {
        height: 130px;
        margin-bottom: -50px;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }

    /* Stack avatar above actions — centered column layout */
    .profile-info {
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 0 16px;
        gap: 10px;
    }

    .profile-avatar-container {
        width: 90px !important;
        height: 90px !important;
        border-width: 3px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }

    .profile-actions {
        margin-bottom: 0 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100%;
    }

    .profile-actions .btn {
        padding: 8px 14px !important;
        font-size: 0.8rem !important;
        flex: 1;
        max-width: 160px;
        text-align: center;
    }

    /* Profile details — centered text on mobile */
    .profile-details {
        margin-top: 10px;
        padding: 0 16px;
        text-align: center;
    }

    .dynamic-name {
        font-size: 1.4rem !important;
        margin-bottom: 2px;
    }

    .dynamic-handle {
        font-size: 0.85rem !important;
    }

    /* Profile sections (interests, photos, music, links, contact) */
    .profile-section {
        padding: 12px 0 !important;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
    }

    .profile-section h4 {
        font-size: 0.95rem !important;
        margin-bottom: 10px;
    }

    /* Tags (interests/disciplines) — better wrapping on mobile */
    .tags-container {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        justify-content: center;
    }

    .tags-container .tag {
        font-size: 0.75rem !important;
        padding: 4px 10px !important;
    }

    /* Photos grid — 3 columns on mobile */
    .photos-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 4px !important;
    }

    /* Stats bar */
    .stats-bar {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
        margin: 12px 0;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 12px;
    }

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

    .stat-value {
        font-size: 1rem !important;
    }

    .stat-label {
        font-size: 0.75rem !important;
    }


    /* Edit Modal — full-screen on mobile */
    .modal-overlay {
        align-items: flex-start !important;
        padding: 0 !important;
    }

    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal-body {
        padding: 12px !important;
    }

    .modal-body .form-group {
        margin-bottom: 12px !important;
    }

    .modal-body .form-input,
    .modal-body textarea {
        font-size: 16px !important; /* Prevent iOS zoom */
    }

    /* Social icons on contact section */
    .social-icons {
        justify-content: center !important;
    }

    /* Members grid on mobile */
    #members-visitor-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    /* Bottom Navigation - Sleeker */
    .bottom-nav {
        height: 65px;
        background: rgba(15, 5, 20, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        padding-bottom: env(safe-area-inset-bottom);
        display: flex;
        justify-content: space-around;
        align-items: center;
    }

    .nav-item {
        flex: 1;
        padding: 4px;
        gap: 2px;
        font-size: 0.6rem;
        opacity: 0.7;
    }

    .nav-item i {
        font-size: 1.2rem;
    }

    .nav-item.active {
        opacity: 1;
        background: rgba(255, 59, 48, 0.15) !important;
        color: var(--primary-color) !important;
        box-shadow: none !important;
        border-radius: 12px !important;
        position: relative;
    }

    .nav-item.active i {
        transform: translateY(-2px);
        color: var(--primary-color);
        filter: drop-shadow(0 0 6px rgba(255, 59, 48, 0.5));
    }

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

    /* Post Cards */
    .post-card {
        margin-left: -12px;
        margin-right: -12px;
        border-radius: 0;
        padding: 16px;
        background: rgba(255, 255, 255, 0.02);
    }

    /* Constrain post images on mobile — exclude avatars */
    .post-card img:not(.avatar):not(.profile-avatar-large),
    .post-content img:not(.avatar) {
        max-height: 350px;
        width: 100%;
        object-fit: cover;
        border-radius: 8px;
    }

    .post-actions {
        gap: 12px !important;
        padding-top: 10px !important;
        font-size: 0.8rem;
    }

    .action-btn {
        font-size: 0.8rem !important;
        gap: 4px !important;
    }

    /* Posts grid on profile — single column, edge-to-edge */
    #user-posts-grid {
        grid-template-columns: 1fr !important;
        gap: 0 !important;
    }
    .glass-panel {
        padding: 16px;
    }

    /* Buttons */
    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }

    /* Typography */
    h2 {
        font-size: 1.3rem !important;
        margin-bottom: 15px !important;
    }

    p {
        font-size: 0.9rem !important;
        line-height: 1.5;
    }

    /* Messages Mobile Redesign */
    .messages-layout {
        display: block !important;
        height: calc(100vh - 140px); /* Leave space for top bar and bottom nav */
        margin-top: 0;
    }

    .contacts-list {
        width: 100% !important;
        height: 100% !important;
        border: none !important;
        background: transparent !important;
        backdrop-filter: none !important;
    }

    .chat-area {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 2001; /* Above almost everything */
        background-color: #0f0514; /* Solid background to hide what's behind */
        display: none; /* Controlled by JS class 'active' */
        flex-direction: column;
        border: none !important;
        border-radius: 0 !important;
    }

    .chat-area.active {
        display: flex !important;
    }

    /* Message Bubbles for Mobile */
    .message {
        max-width: 85% !important;
        font-size: 1rem !important;
        padding: 12px 16px !important;
        margin-bottom: 8px !important;
    }

    .chat-messages {
        padding: 15px !important;
        background: rgba(0,0,0,0.2) !important;
    }

    .chat-input-area {
        padding: 15px !important;
        padding-bottom: calc(15px + env(safe-area-inset-bottom)) !important;
        background: rgba(15, 5, 20, 0.9);
        backdrop-filter: blur(10px);
        border-top: 1px solid rgba(255,255,255,0.05) !important;
    }

    .chat-header {
        padding: 15px !important;
        background: rgba(15, 5, 20, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(255,255,255,0.1) !important;
        height: 70px;
        display: flex;
        align-items: center;
    }

    #empty-state {
        display: none !important; /* Never show empty state placeholder on mobile */
    }
}

/* Landscape and slightly larger mobile */
@media (min-width: 481px) and (max-width: 768px) {
    .main-content {
        padding: 20px;
    }
}
