/* Smooth scrolling for entire app */
html {
    scroll-behavior: smooth;
}

/* Prevent layout shifts with aspect ratio boxes */
.media-container {
    position: relative;
    width: 100%;
}

.media-container::before {
    content: '';
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.media-container img,
.media-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading states */
.media-loading {
    background: #f5f5f5;
    background: linear-gradient(90deg, #f5f5f5 25%, #e0e0e0 50%, #f5f5f5 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@media (prefers-color-scheme: dark) {
    .media-loading {
        background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    }
}


/* Create Post Page Styles */
.create-post-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    z-index: 1000;
    overflow-y: auto;
}

@media (prefers-color-scheme: dark) {
    .create-post-page {
        background-color: #101010;
    }
}

/* Desktop centering */
@media (min-width: 768px) {
    .create-post-page {
        max-width: 600px;
        margin: 0 auto;
        position: relative;
        border-left: 1px solid #dbdbdb;
        border-right: 1px solid #dbdbdb;
    }
    
    @media (prefers-color-scheme: dark) {
        .create-post-page {
            border-left: 1px solid #333;
            border-right: 1px solid #333;
        }
    }
}

/* Header Styles */
.create-post-header {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 100;
    border-bottom: 1px solid #dbdbdb;
}

@media (prefers-color-scheme: dark) {
    .create-post-header {
        background: rgba(16, 16, 16, 0.9);
        border-bottom: 1px solid #333;
    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-button {
    background: none;
    border: none;
    color: #2d3748;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .back-button {
        color: #ffffff;
    }
    
    .back-button:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

@media (prefers-color-scheme: dark) {
    .header-title {
        color: #ffffff;
    }
}

.header-right {
    display: flex;
    align-items: center;
}

.post-button {
    background-color: #1877F2;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.post-button:hover:not(:disabled) {
    background-color: #1666d9;
}

.post-button:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

/* Content Styles */
.create-post-content {
    position: relative;
    padding: 20px;
    padding-bottom: 80px; /* Ensure space for bottom navigation */
    min-height: calc(100vh - 50px); /* Account for header height */
    box-sizing: border-box;
}

.user-info-section {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
}

.create-post-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #a0aec0;
    font-size: 18px;
    flex-shrink: 0;
}

@media (prefers-color-scheme: dark) {
    .create-post-user-avatar {
        background-color: #333;
        color: #a0aec0;
    }
}

.user-details {
    flex: 1;
}

.create-post-username-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    margin-top: 6px; /* Move username and badges down slightly */
}

.create-post-username {
    font-weight: 600;
    color: #2d3748;
    font-size: 16px;
}

@media (prefers-color-scheme: dark) {
    .create-post-username {
        color: #ffffff;
    }
}

.create-post-verified-badge, .create-post-red-verified-badge {
    color: transparent;
    margin-top: 3px;
}

.create-post-verified-badge svg {
    fill: #1DA1F2 !important;
    margin-top: 3px;
}

.create-post-red-verified-badge svg {
    fill: #FE2C55 !important;
    margin-top: 3px;
}

/* Skeleton Loader Styles */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

.create-post-user-avatar.skeleton {
    background-color: #e2e8f0;
    background-image: none;
}

.create-post-username.skeleton {
    width: 100px;
    height: 16px;
    border-radius: 4px;
    background-color: #e2e8f0;
}

@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
    }
    
    .create-post-user-avatar.skeleton {
        background-color: #333;
    }
    
    .create-post-username.skeleton {
        background-color: #333;
    }
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Post Input Section */
.post-input-section {
    position: relative;
    margin-bottom: 20px;
}

#create-post-text-input {
    width: 100%;
    min-height: 120px;
    border: none;
    resize: none;
    font-size: 18px;
    line-height: 1.4;
    color: #2d3748;
    background: transparent;
    outline: none;
    font-family: inherit;
    position: relative;
    z-index: 1;
}

#create-post-text-input::placeholder {
    color: #a0aec0;
}

@media (prefers-color-scheme: dark) {
    #create-post-text-input {
        color: #ffffff;
    }
    
    #create-post-text-input::placeholder {
        color: #718096;
    }
}

.character-counter {
    text-align: right;
    font-size: 14px;
    color: #718096;
    margin-top: 8px;
}

/* Coming Soon Message Styles */
.feature-coming-soon {
    margin: 15px 0;
    display: none;
}

.coming-soon-message {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #2d3748;
    font-weight: 500;
    font-size: 14px;
}

@media (prefers-color-scheme: dark) {
    .coming-soon-message {
        background: rgba(16, 16, 16, 0.9);
        border-color: #333;
        color: #ffffff;
    }
}

/* Action Buttons - Updated to match notifications style */
.create-post-action-buttons {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.create-post-action-btn {
    flex: 1;
    min-width: 60px;
    background: none;
    border: 1px solid #1877F2; /* Blue border */
    border-radius: 20px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    color: #718096;
}

.create-post-action-btn:hover {
    background-color: rgba(24, 119, 242, 0.05); /* Light blue background on hover */
}

.create-post-action-btn.active {
    background-color: rgba(24, 119, 242, 0.1); /* Light blue background for active state */
    border-color: #1877F2;
    color: #1877F2; /* Blue text for active state */
}

@media (prefers-color-scheme: dark) {
    .create-post-action-btn {
        border-color: #1877F2; /* Blue border in dark mode */
        color: #a0aec0;
    }
    
    .create-post-action-btn:hover {
        background-color: rgba(24, 119, 242, 0.1); /* Light blue background on hover in dark mode */
    }
    
    .create-post-action-btn.active {
        background-color: rgba(24, 119, 242, 0.15); /* Slightly darker blue background for active state in dark mode */
        border-color: #1877F2;
        color: #1877F2; /* Blue text for active state */
    }
}

.create-post-action-btn i {
    font-size: 18px;
}

.create-post-action-btn span {
    font-size: 12px;
    font-weight: 500;
}

/* Desktop adjustments */
@media (min-width: 768px) {
    .create-post-page {
        height: 100vh;
    }
    
    .create-post-content {
        padding-bottom: 80px; /* Ensure space for bottom navigation */
    }
}

/* Mention Suggestions Styles - Added to existing CSS */
.mention-suggestions-container {
    position: absolute;
    top: 100%; /* Positions it directly below the textarea */
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid #dbdbdb;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 4px;
    animation: fadeInUp 0.2s ease-out;
}

@media (prefers-color-scheme: dark) {
    .mention-suggestions-container {
        background: rgba(16, 16, 16, 0.95);
        border: 1px solid #333;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
}

.mention-suggestion-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f7f7f7;
    transition: background-color 0.2s;
}

.mention-suggestion-item:hover {
    background-color: rgba(247, 247, 247, 0.8);
}

.mention-suggestion-item:last-child {
    border-bottom: none;
}

@media (prefers-color-scheme: dark) {
    .mention-suggestion-item {
        border-bottom: 1px solid #333;
    }
    
    .mention-suggestion-item:hover {
        background-color: rgba(255, 255, 255, 0.1);
    }
}

.mention-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
    flex-shrink: 0;
    color: #a0aec0;
    font-size: 16px;
}

.mention-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (prefers-color-scheme: dark) {
    .mention-avatar {
        background-color: #333;
        color: #a0aec0;
    }
}

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

.mention-name {
    display: flex;
    align-items: center;
    font-weight: 600;
    font-size: 14px;
    color: #2d3748;
    margin-bottom: 2px;
}

.mention-handle {
    color: #718096;
    font-size: 13px;
    font-weight: 400;
}

@media (prefers-color-scheme: dark) {
    .mention-name {
        color: #ffffff;
    }
    
    .mention-handle {
        color: #a0aec0;
    }
}

/* Verified badges in mentions - matching existing styles */
.mention-name .verified-badge {
    margin-left: 4px;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.mention-name .verified-badge svg {
    width: 100%;
    height: 100%;
}

/* Scrollbar styling for mention suggestions */
.mention-suggestions-container::-webkit-scrollbar {
    width: 6px;
}

.mention-suggestions-container::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.mention-suggestions-container::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.mention-suggestions-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

@media (prefers-color-scheme: dark) {
    .mention-suggestions-container::-webkit-scrollbar-thumb {
        background: #4a5568;
    }
    
    .mention-suggestions-container::-webkit-scrollbar-thumb:hover {
        background: #718096;
    }
}

/* Animation for smooth appearance */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Ensure proper text truncation for long names */
.mention-name strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.mention-handle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile responsiveness for mention suggestions */
@media (max-width: 480px) {
    .mention-suggestions-container {
        margin-top: 6px;
        border-radius: 10px;
        max-height: 200px;
    }
    
    .mention-suggestion-item {
        padding: 10px 14px;
    }
    
    .mention-avatar {
        width: 32px;
        height: 32px;
        margin-right: 10px;
    }
    
    .mention-name strong {
        max-width: 100px;
    }
}

/* Desktop adjustments for mention suggestions */
@media (min-width: 768px) {
    .mention-suggestions-container {
        border-radius: 12px;
        max-height: 240px;
    }
    
    .mention-name strong {
        max-width: 150px;
    }
}

/* Focus states for accessibility */
.mention-suggestion-item:focus {
    outline: 2px solid #1877F2;
    outline-offset: -2px;
}

/* Active state for mention items */
.mention-suggestion-item:active {
    background-color: rgba(24, 119, 242, 0.1);
    transform: scale(0.98);
    transition: transform 0.1s;
}

@media (prefers-color-scheme: dark) {
    .mention-suggestion-item:active {
        background-color: rgba(24, 119, 242, 0.2);
    }
}

/* Ensure the suggestions appear above other content in desktop mode */
@media (min-width: 768px) {
    .mention-suggestions-container {
        left: 20px;
        right: 20px;
    }
}

/* Fix for when textarea grows - ensure suggestions stay attached */
.post-input-section:has(#create-post-text-input:focus) {
    z-index: 1001;
}


/* Media Preview Styles */
.media-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 10px;
    background: rgba(0, 0, 0, 0.02);
    border-radius: 12px;
}

.media-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.media-preview-item img,
.media-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-media {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Media loading states */
img[data-media-src]:not(.loaded) {
    opacity: 0.5;
    background: #f0f0f0;
}

img.loaded {
    opacity: 1;
    transition: opacity 0.3s ease;
}

img.optimal-quality {
    filter: none;
}


/* Media Upload Progress */
.upload-progress-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.upload-progress-bar {
    width: 200px;
    height: 4px;
    background: #e1e8ed;
    border-radius: 2px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: #1877F2;
    border-radius: 2px;
    animation: progressPulse 1.5s ease-in-out infinite;
}

.upload-progress-text {
    font-size: 14px;
    color: #2d3748;
    font-weight: 500;
}

@keyframes progressPulse {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

@media (prefers-color-scheme: dark) {
    .upload-progress-bar {
        background: #333;
    }
    
    .upload-progress-text {
        color: #ffffff;
    }
}

/* Professional Media Preview Styles */
.media-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: rgba(247, 247, 247, 0.5);
    border-radius: 16px;
    border: 1px solid #e1e8ed;
}

@media (prefers-color-scheme: dark) {
    .media-preview-container {
        background: rgba(255, 255, 255, 0.05);
        border-color: #333;
    }
}

.media-preview-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.media-preview-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

@media (prefers-color-scheme: dark) {
    .media-preview-item {
        background: #1a1a1a;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

.media-preview-content {
    position: relative;
    width: 100%;
    height: 120px;
}

.image-preview,
.video-preview {
    width: 100%;
    height: 100%;
    position: relative;
}

.image-preview img,
.video-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}

.play-button {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.play-button svg {
    color: #1877F2;
    margin-left: 2px;
}

.video-duration {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

.media-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.media-type-badge {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    backdrop-filter: blur(10px);
}

.media-size {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 500;
    backdrop-filter: blur(10px);
}

.remove-media {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.remove-media:hover {
    background: rgba(237, 95, 95, 0.9);
    transform: scale(1.1);
}

.remove-media svg {
    width: 14px;
    height: 14px;
}

/* Animation for new media previews */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.upload-notification {
    animation: slideInRight 0.3s ease-out;
}
