/* Mobile App Styles - 100% Perfect */

@media (max-width: 768px) {
    /* Better viewport handling */
    html {
        -webkit-text-size-adjust: 100%;
        -ms-text-size-adjust: 100%;
        height: 100%;
    }

    body {
        padding: 0;
        margin: 0;
        overflow-x: hidden;
        overscroll-behavior-y: contain;
        min-height: 100vh;
        min-height: -webkit-fill-available;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Header - Perfect minimal design */
    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        padding: 6px 10px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
        height: 56px;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
    }

    .header-container {
        padding: 0;
        max-width: 100%;
        gap: 12px;
        height: 100%;
        display: flex;
        align-items: center;
    }

    /* Logo - Icon only */
    .logo span {
        display: none;
    }

    .logo {
        font-size: 0;
        gap: 0;
        padding: 0;
        cursor: pointer;
    }

    .logo-img {
        width: 36px;
        height: 36px;
        border-radius: 8px;
        transition: transform 0.2s;
    }

    .logo:active .logo-img {
        transform: scale(0.9);
    }

    .logo::after,
    .logo::before {
        display: none;
    }

    /* Hide search - can add floating search button later */
    .header-center {
        display: none;
    }

    /* Header buttons - Perfect sizing */
    .header-left {
        flex-shrink: 0;
    }

    .header-right {
        gap: 10px;
        margin-left: auto;
        display: flex;
        align-items: center;
    }

    .btn-primary {
        padding: 0;
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s, box-shadow 0.2s;
        box-shadow: 0 2px 8px rgba(96, 47, 247, 0.2);
    }

    .btn-primary:active {
        transform: scale(0.88);
        box-shadow: 0 1px 4px rgba(96, 47, 247, 0.3);
    }

    .btn-primary span {
        display: none;
    }

    .btn-primary svg {
        margin: 0;
        width: 22px;
        height: 22px;
    }

    .icon-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s, background 0.2s;
    }

    .icon-btn:active {
        transform: scale(0.88);
    }

    .icon-btn svg {
        width: 22px;
        height: 22px;
    }

    .user-avatar {
        width: 44px;
        height: 44px;
        min-width: 44px;
        font-size: 19px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 0.2s;
        box-shadow: 0 2px 6px rgba(96, 47, 247, 0.15);
    }

    .user-avatar:active {
        transform: scale(0.88);
    }

    /* Hide filter bar */
    .filter-bar-container {
        display: none;
    }

    /* Main container - Perfect fit */
    .container {
        flex-direction: column;
        padding: 0;
        max-width: 100vw;
        margin: 0;
        gap: 0;
        margin-top: 56px;
        min-height: calc(100vh - 56px);
        display: block;
    }

    /* Main feed - Optimized spacing */
    .main-feed {
        width: 100%;
        max-width: 100vw;
        padding: 0 0 24px 0;
        background: var(--bg);
        min-height: calc(100vh - 56px);
    }

    /* Hide sidebar */
    .sidebar-right {
        display: none;
    }

    /* Create post card - Refined */
    .create-post-card {
        margin: 12px;
        border-radius: 20px;
        padding: 18px;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
        border: 1px solid var(--border);
        background: var(--surface);
    }

    .create-post-header {
        margin-bottom: 16px;
        padding-bottom: 14px;
        border-bottom: 1px solid var(--border);
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .user-avatar-sm {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .username {
        font-size: 15px;
        font-weight: 700;
    }

    .create-form {
        gap: 12px;
    }

    .create-form input,
    .create-form textarea {
        font-size: 16px;
        padding: 14px 16px;
        border-radius: 14px;
        border: 1px solid var(--border);
        width: 100%;
        transition: all 0.2s ease;
        background: var(--bg);
    }

    .create-form input:focus,
    .create-form textarea:focus {
        border-color: var(--accent);
        background: var(--surface);
        outline: none;
        box-shadow: 0 0 0 3px rgba(96, 47, 247, 0.1);
    }

    .create-form textarea {
        min-height: 140px;
        resize: vertical;
        line-height: 1.6;
    }

    .terms-section {
        padding: 12px 14px;
        border-radius: 12px;
        background: var(--bg);
    }

    .terms-label {
        font-size: 13px;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .terms-label input[type="checkbox"] {
        width: 18px;
        height: 18px;
        cursor: pointer;
    }

    .preview-toggle {
        margin: 8px 0;
        text-align: center;
    }

    .btn-text {
        font-size: 14px;
        padding: 0 24px;
        height: 42px;
        border-radius: 21px;
    }

    .create-post-footer {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
        margin-top: 8px;
        padding-top: 16px;
        border-top: 1px solid var(--border);
    }

    .hint {
        font-size: 13px;
        text-align: center;
        color: var(--text-tertiary);
    }

    .button-group {
        width: 100%;
        gap: 12px;
        display: flex;
    }

    .button-group .btn-text {
        flex: 1;
        height: 50px;
        font-size: 16px;
        font-weight: 600;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        transition: all 0.2s ease;
    }

    .button-group .btn-text:active {
        transform: scale(0.96);
    }

    .button-group .btn-primary {
        flex: 1;
        width: auto;
        height: 50px;
        font-size: 16px;
        font-weight: 700;
        border-radius: 16px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        transition: all 0.2s ease;
        box-shadow: 0 4px 12px rgba(96, 47, 247, 0.25);
    }

    .button-group .btn-primary:active {
        transform: scale(0.96);
        box-shadow: 0 2px 8px rgba(96, 47, 247, 0.3);
    }

    /* Posts - Beautiful cards */
    .post {
        background: var(--surface);
        border-radius: 20px;
        border: 1px solid var(--border);
        margin: 0 12px 12px 12px;
        padding: 18px;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease;
    }

    .post:active {
        transform: scale(0.99);
        box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    }

    .post:first-child {
        margin-top: 12px;
    }

    .post-header {
        margin-bottom: 14px;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .post-user-avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .post-meta {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    .post-author {
        font-size: 15px;
        font-weight: 700;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .post-timestamp {
        font-size: 12px;
        color: var(--text-tertiary);
        font-weight: 500;
    }

    .post-menu {
        flex-shrink: 0;
        margin-left: auto;
    }

    .post-menu-btn {
        width: 34px;
        height: 34px;
        min-width: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.2s ease;
    }

    .post-menu-btn:active {
        transform: scale(0.82);
        background: var(--bg);
    }

    .post-menu-btn svg {
        width: 20px;
        height: 20px;
    }

    .post-title {
        font-size: 18px;
        font-weight: 700;
        margin-bottom: 10px;
        line-height: 1.4;
        color: var(--text);
    }

    .post-content-wrapper {
        margin-bottom: 0;
    }

    .post-text {
        font-size: 15px;
        line-height: 1.65;
        margin-bottom: 14px;
        color: var(--text-secondary);
        word-wrap: break-word;
    }

    /* Post tags - Smooth scroll */
    .post-tags {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-wrap: nowrap;
        gap: 8px;
        margin-top: 14px;
        padding: 2px 0 6px 0;
        display: flex;
        width: 100%;
    }

    .post-tags::-webkit-scrollbar {
        display: none;
    }

    .post-tag {
        white-space: nowrap;
        padding: 7px 14px;
        font-size: 12px;
        font-weight: 700;
        flex-shrink: 0;
        border-radius: 14px;
        transition: all 0.2s ease;
    }

    .post-tag:active {
        transform: scale(0.92);
    }

    /* Post footer - Perfected layout */
    .post-footer {
        flex-direction: column;
        gap: 14px;
        margin-top: 14px;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }

    .post-actions-left {
        width: 100%;
        display: grid;
        grid-template-columns: auto 1fr 1fr 1fr;
        gap: 10px;
        align-items: center;
    }

    .vote-group {
        gap: 8px;
        padding: 8px 12px;
        border-radius: 24px;
        background: var(--bg);
        display: flex;
        align-items: center;
        justify-content: center;
        border: 1px solid var(--border);
    }

    .vote-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: transparent;
        border: none;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .vote-btn:active {
        transform: scale(0.8);
        background: var(--surface);
    }

    .vote-btn svg {
        width: 18px;
        height: 18px;
    }

    .vote-count {
        font-size: 15px;
        font-weight: 800;
        min-width: 28px;
        text-align: center;
        padding: 0 4px;
    }

    .post-action {
        padding: 10px 6px;
        font-size: 11px;
        gap: 6px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        border-radius: 14px;
        background: transparent;
        border: none;
        transition: all 0.2s ease;
        -webkit-tap-highlight-color: transparent;
        min-height: 56px;
    }

    .post-action:active {
        transform: scale(0.92);
        background: var(--bg);
    }

    .post-action svg {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .post-action span {
        font-size: 11px;
        font-weight: 700;
        line-height: 1.2;
        text-align: center;
        white-space: nowrap;
    }

    .share-menu {
        position: relative;
    }

    .share-menu .post-action {
        width: 100%;
    }

    /* Activity section - Refined */
    .post-activity {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px 0 0;
        border-top: 1px solid var(--border);
    }

    .activity-avatars {
        display: flex;
        margin-right: 10px;
    }

    .activity-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
        border-width: 2px;
        border-color: var(--surface);
        margin-left: -10px;
        transition: transform 0.2s;
    }

    .activity-avatar:first-child {
        margin-left: 0;
    }

    .activity-avatar:active {
        transform: scale(1.15);
        z-index: 2;
    }

    .activity-more {
        font-size: 13px;
        font-weight: 700;
        color: var(--text-tertiary);
    }

    /* Comments section - Perfect */
    .comments-section {
        margin-top: 16px;
        padding-top: 0;
        border-top: none;
    }

    .comment-input-container {
        display: flex;
        padding: 16px;
        position: sticky;
        bottom: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        gap: 12px;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
        z-index: 10;
    }

    .comment-input {
        font-size: 15px;
        padding: 14px 18px;
        border-radius: 24px;
        background: var(--bg);
        border: 1px solid var(--border);
        flex: 1;
        width: 100%;
        transition: all 0.2s ease;
    }

    .comment-input:focus {
        border-color: var(--accent);
        background: var(--surface);
        outline: none;
        box-shadow: 0 0 0 3px rgba(96, 47, 247, 0.1);
    }

    .comment-btn {
        padding: 14px 26px;
        min-width: 90px;
        height: 48px;
        font-size: 15px;
        font-weight: 700;
        border-radius: 24px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(96, 47, 247, 0.2);
    }

    .comment-btn:active {
        transform: scale(0.94);
        box-shadow: 0 1px 4px rgba(96, 47, 247, 0.3);
    }

    .comments-list {
        display: flex;
        flex-direction: column;
        gap: 0;
        padding: 0 4px;
    }

    .comment {
        padding: 16px 0;
        gap: 12px;
        border-bottom: 1px solid var(--border);
    }

    .comment:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

    .comment-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
        flex-shrink: 0;
    }

    .comment-content {
        flex: 1;
        min-width: 0;
    }

    .comment-header {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 8px;
    }

    .comment-author {
        font-size: 14px;
        font-weight: 700;
        color: var(--text);
    }

    .comment-time {
        font-size: 12px;
        color: var(--text-tertiary);
        font-weight: 500;
    }

    .comment-menu {
        margin-left: auto;
    }

    .comment-menu-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.2s ease;
    }

    .comment-menu-btn:active {
        transform: scale(0.82);
        background: var(--bg);
    }

    .comment-menu-btn svg {
        width: 18px;
        height: 18px;
    }

    .comment-text {
        font-size: 14px;
        line-height: 1.65;
        color: var(--text-secondary);
        word-wrap: break-word;
    }

    .no-comments {
        text-align: center;
        padding: 32px 20px;
        color: var(--text-tertiary);
        font-size: 14px;
    }

    /* Profile modal - Bottom sheet */
    .modal-content {
        max-width: 100%;
        max-height: 85vh;
        border-radius: 20px 20px 0 0;
        margin: auto 0 0;
    }

    .modal-header {
        padding: 20px;
        border-bottom: 1px solid var(--border);
    }

    .modal-user-avatar {
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-username {
        font-size: 13px;
    }

    .modal-close {
        width: 36px;
        height: 36px;
        min-width: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        transition: all 0.15s ease;
    }

    .modal-close:active {
        transform: scale(0.85);
        background: var(--bg);
    }

    .modal-close svg {
        width: 18px;
        height: 18px;
    }

    .modal-body {
        padding: 20px;
    }

    .modal-section {
        margin-bottom: 24px;
    }

    .modal-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 12px;
        border-radius: 10px;
    }

    .modal-icon svg {
        width: 20px;
        height: 20px;
    }

    .modal-section-title {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .modal-text {
        font-size: 13px;
        line-height: 1.6;
    }

    .modal-note {
        padding: 14px;
        font-size: 12px;
        border-radius: 10px;
    }

    /* Confirm modal - Bottom sheet */
    .confirm-modal {
        max-width: 100%;
        margin: auto 0 0;
        border-radius: 20px 20px 0 0;
        padding: 24px;
    }

    .confirm-icon {
        width: 56px;
        height: 56px;
        margin-bottom: 20px;
    }

    .confirm-icon svg {
        width: 28px;
        height: 28px;
    }

    .confirm-title {
        font-size: 18px;
        margin-bottom: 10px;
    }

    .confirm-message {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .confirm-buttons {
        gap: 10px;
        flex-direction: row;
        width: 100%;
    }

    .btn-secondary,
    .btn-danger {
        flex: 1;
        padding: 0;
        height: 50px;
        font-size: 16px;
        font-weight: 700;
        border-radius: 14px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.15s ease;
    }

    .btn-secondary:active,
    .btn-danger:active {
        transform: scale(0.95);
    }

    /* Notifications - Full width */
    .notification-container {
        bottom: 12px;
        left: 12px;
        right: 12px;
        transform: none;
        align-items: stretch;
    }

    .notification {
        min-width: auto;
        width: 100%;
        padding: 14px 16px;
        border-radius: 12px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    }

    .notification-title {
        font-size: 13px;
    }

    .notification-message {
        font-size: 12px;
    }

    /* Notification close button - refined */
    .notification-close {
        width: 28px;
        height: 28px;
        min-width: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .notification-close:active {
        transform: scale(0.82);
        background: rgba(255, 255, 255, 0.2);
    }

    .notification-close svg {
        width: 16px;
        height: 16px;
    }

    /* Better notification styling */
    .notification-icon {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .notification-icon svg {
        width: 24px;
        height: 24px;
    }

    .notification-content {
        flex: 1;
        min-width: 0;
    }

    /* Live updates banner - bottom on mobile */
    .live-updates-banner {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        padding: 10px 12px;
        z-index: 9998;
        box-shadow: 0 -2px 8px rgba(239, 68, 68, 0.3);
        animation: slideUpBanner 0.4s ease-out;
    }

    .live-updates-banner.hidden {
        transform: translateY(100%);
        opacity: 0;
    }

    .live-updates-content {
        gap: 8px;
    }

    .live-updates-icon {
        width: 18px;
        height: 18px;
        padding: 3px;
    }

    .live-updates-icon svg {
        width: 12px;
        height: 12px;
    }

    .live-updates-text {
        gap: 1px;
        flex: 1;
        min-width: 0;
    }

    .live-updates-text strong {
        font-size: 12px;
    }

    .live-updates-text span {
        font-size: 11px;
        line-height: 1.3;
    }

    .live-updates-close {
        width: 24px;
        height: 24px;
        min-width: 24px;
    }

    .live-updates-close svg {
        width: 14px;
        height: 14px;
    }

    /* Header - Back to original mobile position */
    .header {
        position: fixed;
        top: 0;
        z-index: 1000;
        height: 56px;
        padding: 6px 10px;
    }

    /* Container - Original mobile spacing */
    .container {
        margin-top: 56px;
        min-height: calc(100vh - 56px);
        padding: 0;
    }

    .main-feed {
        min-height: calc(100vh - 56px);
        padding: 0 0 70px 0;
    }

    /* Notifications - Account for banner */
    .notification-container {
        bottom: calc(12px + 50px);
    }

    /* iOS safe area for bottom banner */
    @supports (padding-bottom: env(safe-area-inset-bottom)) {
        .live-updates-banner {
            padding-bottom: calc(10px + env(safe-area-inset-bottom));
        }

        .notification-container {
            bottom: calc(12px + 50px + env(safe-area-inset-bottom));
        }

        .main-feed {
            padding-bottom: calc(70px + env(safe-area-inset-bottom));
        }
    }

    /* ...existing code... */
}

/* Extra small devices */
@media (max-width: 375px) {
    .live-updates-banner {
        padding: 8px 10px;
    }

    .live-updates-text strong {
        font-size: 12px;
    }

    .live-updates-text span {
        font-size: 11px;
    }

    .header {
        height: 50px;
    }

    .container {
        margin-top: 50px;
    }

    .main-feed {
        padding-bottom: 65px;
    }
}