/* Rich Text Editor Styles - Modern & Robust */
/* Compatible with Inside Talk, Flock Feed, and future sections */

/* Rich Text Toolbar - Modern Gen-Z Styling */
.rich-text-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(139, 92, 246, 0.08));
    border: 1.5px solid rgba(59, 130, 246, 0.15);
    border-radius: 12px 12px 0 0;
    gap: 10px;
    flex-wrap: wrap;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rich-text-toolbar:hover {
    border-color: rgba(59, 130, 246, 0.25);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.1);
}

.toolbar-group {
    display: flex;
    gap: 6px;
    align-items: center;
}

.toolbar-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid rgba(59, 130, 246, 0.25);
    border-radius: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 15px;
    font-weight: 700;
    color: #3b82f6;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.toolbar-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.15);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.toolbar-btn:hover {
    background: rgba(59, 130, 246, 0.12);
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    color: #2563eb;
}

.toolbar-btn:hover::before {
    width: 100%;
    height: 100%;
}

.toolbar-btn:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.15);
}

.toolbar-btn.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(139, 92, 246, 0.2));
    border-color: rgba(59, 130, 246, 0.5);
    color: #1d4ed8;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25), inset 0 2px 4px rgba(59, 130, 246, 0.1);
}

.emoji-toggle-btn {
    font-size: 18px;
    padding: 6px 10px;
}

/* Emoji Picker - Modern Design */
.emoji-picker {
    background: #ffffff;
    border: 1.5px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.08);
    max-height: 280px;
    overflow-y: auto;
    animation: slideDown 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 6px;
    padding: 4px;
}

.emoji-item {
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 8px;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
}

.emoji-item:hover {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.15);
}

.emoji-item:active {
    transform: scale(1.1);
}

/* Rich Text Editor Container */
.rich-text-editor {
    min-height: 120px;
    max-height: 300px;
    padding: 16px;
    border: 1.5px solid rgba(59, 130, 246, 0.15);
    border-radius: 0 0 12px 12px;
    font-size: 16px;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
    background: var(--bg-color, #ffffff);
    color: var(--text-color, #14171a);
    resize: vertical;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

.rich-text-editor:focus {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15), inset 0 2px 4px rgba(0, 0, 0, 0.03);
}

/* Rich text formatting */
.rich-text-editor strong,
.rich-text-editor b {
    font-weight: 700;
    color: #14171a;
}

.rich-text-editor em,
.rich-text-editor i {
    font-style: italic;
    color: #14171a;
}

.rich-text-editor u {
    text-decoration: underline;
    color: #14171a;
}

/* Media Upload Area */
.media-upload-area {
    margin-top: 12px;
    border: 1px solid rgba(29, 161, 242, 0.1);
    border-radius: 12px;
    background: rgba(29, 161, 242, 0.02);
    overflow: hidden;
}

.media-upload-zone {
    padding: 24px;
    text-align: center;
    border: 2px dashed rgba(29, 161, 242, 0.2);
    border-radius: 12px;
    margin: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.media-upload-zone:hover {
    border-color: rgba(29, 161, 242, 0.4);
    background: rgba(29, 161, 242, 0.05);
}

.media-upload-zone.drag-over {
    border-color: rgba(29, 161, 242, 0.6);
    background: rgba(29, 161, 242, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    font-size: 2rem;
    margin-bottom: 8px;
    opacity: 0.7;
}

.media-upload-zone p {
    margin: 8px 0;
    color: #14171a;
    font-weight: 500;
}

.media-upload-zone small {
    color: #657786;
    font-size: 0.85rem;
}

.upload-link {
    background: none;
    border: none;
    color: #1da1f2;
    text-decoration: underline;
    cursor: pointer;
    font-weight: 600;
}

.upload-link:hover {
    color: #0d8bd9;
}

/* Media Preview Container */
.media-preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    padding: 12px;
    background: rgba(247, 249, 250, 0.5);
}

.media-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.media-preview-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.media-preview-img,
.media-preview-video {
    width: 100%;
    height: 120px;
    object-fit: cover;
    display: block;
}

.remove-media-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(224, 36, 94, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.remove-media-btn:hover {
    background: rgba(224, 36, 94, 1);
    transform: scale(1.1);
}

.media-info {
    padding: 8px;
    background: white;
}

.media-name {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #14171a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.media-size {
    font-size: 0.75rem;
    color: #657786;
}

/* Post Actions Enhancement */
.create-post-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(29, 161, 242, 0.1);
}

.post-info {
    display: flex;
    gap: 16px;
    align-items: center;
}

.character-count {
    font-size: 0.9rem;
    color: #657786;
    font-weight: 500;
}

.character-count.warning {
    color: #ff9500;
}

.character-count.danger {
    color: #e0245e;
    font-weight: 600;
}

.media-count {
    font-size: 0.85rem;
    color: #1da1f2;
    font-weight: 500;
    background: rgba(29, 161, 242, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
}

.create-post-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: #14171a;
    cursor: pointer;
}

.admin-toggle input[type="checkbox"] {
    margin: 0;
}

.create-post-btn {
    background: #1da1f2;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.create-post-btn:hover:not(:disabled) {
    background: #0d8bd9;
    transform: translateY(-1px);
}

.create-post-btn:disabled {
    background: #aab8c2;
    cursor: not-allowed;
    transform: none;
}

.create-post-btn.admin {
    background: linear-gradient(135deg, #ffd700, #ffa500);
    color: #000;
}

.create-post-btn.admin:hover:not(:disabled) {
    background: linear-gradient(135deg, #ffa500, #ffd700);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .rich-text-toolbar {
        padding: 6px 8px;
        gap: 6px;
    }
    
    .toolbar-btn {
        padding: 6px 8px;
        min-width: 32px;
        min-height: 32px;
        font-size: 12px;
    }
    
    .rich-text-editor {
        min-height: 100px;
        padding: 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .media-upload-zone {
        padding: 16px;
        margin: 8px;
    }
    
    .upload-icon {
        font-size: 1.5rem;
    }
    
    .media-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
        padding: 8px;
    }
    
    .media-preview-img,
    .media-preview-video {
        height: 100px;
    }
    
    .create-post-actions {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .post-info {
        justify-content: center;
    }
    
    .create-post-buttons {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .toolbar-group {
        gap: 2px;
    }
    
    .toolbar-btn {
        padding: 4px 6px;
        min-width: 28px;
        min-height: 28px;
        font-size: 11px;
    }
    
    .rich-text-editor {
        min-height: 80px;
        padding: 10px;
    }
    
    .media-preview-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .media-preview-img,
    .media-preview-video {
        height: 80px;
    }
}

/* Dark Theme Support - Modern & Cohesive */
.dark-theme .rich-text-toolbar {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(139, 92, 246, 0.12));
    border-color: rgba(139, 92, 246, 0.25);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dark-theme .rich-text-toolbar:hover {
    border-color: rgba(139, 92, 246, 0.35);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.dark-theme .toolbar-btn {
    background: rgba(30, 30, 30, 0.8);
    color: #a78bfa;
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.dark-theme .toolbar-btn::before {
    background: rgba(139, 92, 246, 0.2);
}

.dark-theme .toolbar-btn:hover {
    background: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.5);
    color: #c4b5fd;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

.dark-theme .toolbar-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25), rgba(59, 130, 246, 0.25));
    border-color: rgba(139, 92, 246, 0.6);
    color: #ddd6fe;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35), inset 0 2px 4px rgba(139, 92, 246, 0.15);
}

.dark-theme .emoji-picker {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(139, 92, 246, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
}

.dark-theme .emoji-item:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.4);
    box-shadow: 0 4px 8px rgba(139, 92, 246, 0.25);
}

.dark-theme .rich-text-editor-container {
    border-color: rgba(255, 255, 255, 0.1);
    background: #1a1a1a;
}

.dark-theme .rich-text-editor {
    color: #ffffff;
    background: #1a1a1a;
}

.dark-theme .rich-text-editor.empty::before {
    color: #8899a6;
}

.dark-theme .media-upload-area {
    background: rgba(255, 255, 255, 0.02);
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .media-upload-zone {
    border-color: rgba(255, 255, 255, 0.2);
}

.dark-theme .media-upload-zone:hover {
    border-color: rgba(29, 161, 242, 0.4);
    background: rgba(29, 161, 242, 0.05);
}

.dark-theme .media-upload-zone p {
    color: #ffffff;
}

.dark-theme .media-upload-zone small {
    color: #8899a6;
}

.dark-theme .media-preview-container {
    background: rgba(0, 0, 0, 0.2);
}

.dark-theme .media-preview-item {
    background: #2a2a2a;
}

.dark-theme .media-info {
    background: #2a2a2a;
}

.dark-theme .media-name {
    color: #ffffff;
}

.dark-theme .create-post-actions {
    border-color: rgba(255, 255, 255, 0.1);
}

.dark-theme .character-count {
    color: #8899a6;
}

.dark-theme .admin-toggle {
    color: #ffffff;
}

/* Loading Spinner */
.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Accessibility Improvements */
.toolbar-btn:focus {
    outline: 2px solid #1da1f2;
    outline-offset: 2px;
}

.rich-text-editor:focus {
    outline: none;
}

.media-upload-zone:focus {
    outline: 2px solid #1da1f2;
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .toolbar-btn {
        border-width: 2px;
    }
    
    .rich-text-editor {
        border-width: 2px;
    }
    
    .media-upload-zone {
        border-width: 3px;
    }
}

/* Tweet Media Styling */
.tweet-media {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    max-width: 100%;
}

.tweet-media-item {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 12px;
    margin-bottom: 8px;
}

.tweet-media-item:last-child {
    margin-bottom: 0;
}

.tweet-media video.tweet-media-item {
    max-height: 400px;
    object-fit: cover;
}

/* Multiple media items grid */
.tweet-media:has(.tweet-media-item:nth-child(2)) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.tweet-media:has(.tweet-media-item:nth-child(3)) {
    grid-template-columns: repeat(2, 1fr);
}

.tweet-media:has(.tweet-media-item:nth-child(4)) {
    grid-template-columns: repeat(2, 1fr);
}

/* Mobile media responsiveness */
@media (max-width: 768px) {
    .tweet-media:has(.tweet-media-item:nth-child(2)) {
        grid-template-columns: 1fr;
    }
    
    .tweet-media-item {
        border-radius: 8px;
    }
    
    .tweet-media video.tweet-media-item {
        max-height: 250px;
    }
}

/* Loading and Error Messages */
.loading-message,
.error-message {
    text-align: center;
    padding: 40px 20px;
    background: rgba(247, 249, 250, 0.8);
    border-radius: 16px;
    margin: 20px 0;
}

.loading-message h3,
.error-message h3 {
    margin: 16px 0 8px 0;
    color: #14171a;
    font-size: 1.2rem;
}

.loading-message p,
.error-message p {
    margin: 8px 0;
    color: #657786;
    font-size: 1rem;
}

.loading-message small,
.error-message small {
    display: block;
    margin-top: 16px;
    color: #8899a6;
    font-size: 0.85rem;
}

.error-icon {
    font-size: 2rem;
    margin-bottom: 16px;
}

.retry-btn {
    margin: 16px 0 8px 0;
    background: #1da1f2;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #0d8bd9;
    transform: translateY(-1px);
}

/* Dark Theme Support - Integrates with existing theme system */
.dark-theme .rich-text-toolbar {
    background: rgba(29, 161, 242, 0.1);
    border-color: rgba(29, 161, 242, 0.2);
}

.dark-theme .toolbar-btn {
    color: #1da1f2;
    border-color: rgba(29, 161, 242, 0.3);
    background: rgba(255, 255, 255, 0.05);
}

.dark-theme .toolbar-btn:hover {
    background: rgba(29, 161, 242, 0.2);
    color: #ffffff;
}

.dark-theme .rich-text-editor {
    background: #15202b;
    color: #ffffff;
    border-color: #38444d;
}

.dark-theme .rich-text-editor.empty::before {
    color: #8899a6;
}

.dark-theme .rich-text-editor strong,
.dark-theme .rich-text-editor b {
    color: #ffffff;
}

.dark-theme .rich-text-editor em,
.dark-theme .rich-text-editor i {
    color: #e1e8ed;
}

.dark-theme .rich-text-editor u {
    color: #e1e8ed;
}

.dark-theme .media-upload-area {
    background: rgba(255, 255, 255, 0.03);
    border-color: #38444d;
}

.dark-theme .media-upload-zone {
    background: #192734;
    border-color: #38444d;
    color: #8899a6;
}

.dark-theme .media-upload-zone:hover,
.dark-theme .media-upload-zone.drag-over {
    background: rgba(29, 161, 242, 0.1);
    border-color: #1da1f2;
}

.dark-theme .upload-link {
    color: #1da1f2;
}

.dark-theme .media-preview-item {
    background: #192734;
    border-color: #38444d;
}

/* Dark theme support for messages */
.dark-theme .loading-message,
.dark-theme .error-message {
    background: rgba(0, 0, 0, 0.3);
}

.dark-theme .loading-message h3,
.dark-theme .error-message h3 {
    color: #ffffff;
}

.dark-theme .loading-message p,
.dark-theme .error-message p {
    color: #8899a6;
}

.dark-theme .loading-message small,
.dark-theme .error-message small {
    color: #657786;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .toolbar-btn,
    .media-preview-item,
    .create-post-btn,
    .loading-spinner,
    .retry-btn {
        transition: none !important;
        animation: none !important;
        transform: none !important;
    }
}
