/**
 * ReconCom Public Styles - WhatsApp-style Interface
 */

/* Three-panel layout */
.reconcom-interface {
    display: flex;
    height: 100vh;
    background: var(--reconcom-bg);
    font-family: var(--reconcom-font);
    color: var(--reconcom-text);
}

/* Hide theme headers/footers in chat mode */
body.reconcom-chat-mode header,
body.reconcom-chat-mode footer,
body.reconcom-chat-mode .site-header,
body.reconcom-chat-mode .site-footer,
body.reconcom-chat-mode .main-navigation,
body.reconcom-chat-mode #masthead,
body.reconcom-chat-mode #colophon,
body.reconcom-chat-mode .recon-header,
body.reconcom-chat-mode .recon-footer {
    display: none !important;
}

body.reconcom-chat-mode {
    margin: 0 !important;
    padding: 0 !important;
}

body.reconcom-chat-mode .recon-main {
    padding: 0 !important;
    margin: 0 !important;
    height: 100vh !important;
}

body.reconcom-chat-mode .reconcom-interface {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999999;
}

/* Android-specific fixes */
@supports (-webkit-appearance: none) and (not (-webkit-touch-callout: none)) {
    body.reconcom-chat-mode {
        height: 100vh;
        overflow: hidden;
    }
    
    body.reconcom-chat-mode .reconcom-interface {
        height: 100vh !important;
        height: calc(100vh - env(safe-area-inset-top, 0px)) !important;
    }
}

/* iOS mobile-specific fixes */
@media (max-width: 768px) {
    @supports (-webkit-touch-callout: none) {
        .reconcom-interface {
            height: 100vh;
            height: -webkit-fill-available;
        }
        
        .reconcom-main {
            padding-bottom: 0 !important;
        }
        
        .chat-input {
            position: fixed !important;
            bottom: 0 !important;
            left: 0 !important;
            right: 0 !important;
            padding: 15px !important;
            padding-bottom: max(35px, calc(15px + env(safe-area-inset-bottom, 0))) !important;
            background: white !important;
            z-index: 1000 !important;
        }
        
        /* Force padding on all chat-messages containers */
        .chat-messages,
        .reconcom-main .chat-messages,
        #chat-messages {
            padding-bottom: 195px !important;
        }
    }
}

/* Additional mobile rules for all devices */
@media (max-width: 768px) {
    .chat-messages {
        padding-bottom: 195px !important;
    }
}

/* Mobile overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.mobile-overlay.active {
    display: block;
}

@media (min-width: 769px) {
    .mobile-overlay {
        display: none !important;
    }
}

/* Left Sidebar */
.reconcom-sidebar {
    width: 320px;
    background: #f0f0f0;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.sidebar-header {
    background: var(--reconcom-primary);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    opacity: 0.8;
}

.sidebar-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    color: white;
    text-decoration: none;
    font-size: 20px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.action-btn:hover {
    opacity: 1;
}

/* Search Box */
.search-box {
    padding: 10px;
    background: #fff;
    border-bottom: 1px solid #eee;
}

.search-form {
    display: flex;
    position: relative;
}

.search-form input {
    flex: 1;
    padding: 8px 35px 8px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    background: #f8f8f8;
}

.search-form button {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
}

/* Channels List */
.channels-list {
    flex: 1;
    overflow-y: auto;
    background: white;
}

.section-title {
    padding: 10px 15px;
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    background: #f8f8f8;
    font-weight: 600;
}

.channel-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    position: relative;
}

.channel-item:hover {
    background: #f5f5f5;
}

.channel-item.active {
    background: #e8f5e9;
}

.channel-icon {
    font-size: 24px;
    margin-right: 12px;
}

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

.channel-name {
    font-weight: 800;
    font-size: 15px;
    margin-bottom: 2px;
}

.channel-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background: var(--reconcom-primary);
    color: white;
    border-radius: 10px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 15px;
    border-top: 1px solid #ddd;
    background: #f8f8f8;
    display: flex;
    gap: 15px;
}

.footer-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-decoration: none;
    color: var(--reconcom-text);
    font-size: 14px;
    flex: 1;
    padding: 8px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}

.footer-link:hover {
    background: #e8e8e8;
}

.notification-count {
    background: #ff5252;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
}

/* Main Chat Area */
.reconcom-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e5ddd5;
    position: relative;
}

.reconcom-main::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48ZGVmcz48cGF0dGVybiBpZD0iYSIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIj48cGF0aCBkPSJNMCAxMGg0MHYyMEgweiIgZmlsbD0iI2Y1ZjVmNSIgZmlsbC1vcGFjaXR5PSIuMSIvPjwvcGF0dGVybj48L2RlZnM+PHJlY3Qgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgZmlsbD0idXJsKCNhKSIvPjwvc3ZnPg==');
    opacity: 0.05;
    pointer-events: none;
}

/* Chat Header */
.chat-header {
    background: var(--reconcom-primary);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    z-index: 1;
}

.header-info h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.channel-description {
    font-size: 13px;
    opacity: 0.9;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.pinned-files {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.2);
    padding: 5px 10px;
    border-radius: 15px;
}

.pinned-label {
    font-size: 13px;
}

.pinned-file {
    font-size: 16px;
    text-decoration: none;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.pinned-file:hover {
    opacity: 1;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    z-index: 1;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.date-separator {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.date-separator span {
    background: rgba(0,0,0,0.08);
    color: #666;
    padding: 5px 15px;
    border-radius: 15px;
    font-size: 12px;
    display: inline-block;
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-start;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.own {
    flex-direction: row-reverse;
}

.message-avatar {
    margin: 0 10px;
}

.message-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.message-content {
    width: 80%;
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    position: relative;
}

.message.own .message-content {
    background: #dcf8c6;
}

.message-header {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.message-author {
    font-weight: 600;
    color: var(--reconcom-primary);
}

.message.own .message-author {
    color: #075e54;
}

.message-time {
    color: #999;
}

.message-edited {
    color: #999;
    font-style: italic;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Message Reactions */
.message-reactions {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: wrap;
}

/* File links in messages */
.message-text .file-link {
    color: #0066cc;
    text-decoration: none;
    border-bottom: 1px dotted #0066cc;
    transition: all 0.2s ease;
}

.message-text .file-link:hover {
    color: #0052a3;
    border-bottom-style: solid;
}

.reaction-form {
    display: inline-block;
}

.reaction-btn {
    background: rgba(0,0,0,0.05);
    border: 1px solid transparent;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.reaction-btn:hover {
    background: rgba(0,0,0,0.1);
}

.reaction-btn.reacted {
    background: rgba(37, 211, 102, 0.2);
    border-color: #25d366;
}

.reaction-count {
    margin-left: 4px;
    font-size: 11px;
    color: #666;
}

/* Message Actions */
.message-actions {
    display: flex;
    gap: 10px;
    margin-top: 5px;
    font-size: 12px;
}

.action-link {
    color: #666;
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s;
}

.action-link:hover {
    color: var(--reconcom-primary);
}

.reaction-picker {
    position: relative;
    display: inline-block;
}

.emoji-list {
    position: absolute;
    bottom: 100%;
    left: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 5px;
    display: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
}

.emoji-list.show {
    display: flex;
    gap: 2px;
}

.emoji-form {
    display: inline-block;
}

.emoji-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.emoji-btn:hover {
    background: #f0f0f0;
}

/* Chat Input */
.chat-input {
    background: white;
    border-top: 1px solid #ddd;
    padding: 15px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0));
    z-index: 1;
    width: 100%;
}

.message-form {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-label {
    display: inline-block;
    cursor: pointer;
    font-size: 24px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.file-label:hover {
    opacity: 1;
}

.message-form textarea,
.input-row textarea {
    flex: 1;
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 120px;
    min-width: 0;
}

.send-btn {
    background: var(--reconcom-primary);
    color: var(--reconcom-text, white);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.2s;
}

.send-btn:hover {
    background: var(--reconcom-secondary);
}

/* Right Panel */
.reconcom-details {
    width: 350px;
    background: white;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: #f8f8f8;
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    font-size: 24px;
    color: #666;
    text-decoration: none;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

/* Thread Content */
.thread-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.thread-parent {
    padding: 15px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
}

.thread-separator {
    padding: 10px 15px;
    font-size: 13px;
    text-transform: uppercase;
    color: #666;
    background: #f8f8f8;
    font-weight: 600;
}

.thread-replies {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
}

.thread-reply-form {
    padding: 15px;
    border-top: 1px solid #ddd;
    background: #f8f8f8;
}

.thread-reply-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.thread-reply-form .send-btn {
    width: auto;
    padding: 8px 20px;
    border-radius: 20px;
}

/* Files Panel */
.files-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    height: 100%;
    min-height: 0;
}

.no-files {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.files-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: none !important;
    height: 100% !important;
}

.file-item {
    display: flex;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    padding: 10px 10px 10px 20px !important;
    background: #f8f8f8;
    border-radius: 8px;
    transition: background 0.2s;
    text-align: left !important;
}

.file-item:hover {
    background: #f0f0f0;
}

.file-icon {
    font-size: 24px;
    margin-right: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

/* Office file type icons with colored backgrounds */
.file-icon .file-type-pdf {
    background: #dc3545;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
}

.file-icon .file-type-doc {
    background: #0066cc;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
}

.file-icon .file-type-xls {
    background: #28a745;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
}

.file-icon .file-type-ppt {
    background: #ea4335;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
}

.file-icon .file-type-default {
    background: #6c757d;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 14px;
}

.file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start !important;
    text-align: left !important;
}

.file-name {
    line-height: 1.3;
}

.file-name a {
    color: var(--reconcom-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
    word-break: break-word;
}

.file-name a:hover {
    text-decoration: underline;
}

.file-user-size {
    font-size: 12px;
    color: #666;
}

.file-datetime {
    font-size: 12px;
    color: #999;
}

.file-actions {
    display: flex;
    gap: 5px;
}

.pin-form {
    display: inline-block;
}

.pin-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.pin-btn:hover {
    opacity: 1;
}

/* Search Results */
.search-results {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.no-results {
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.results-section {
    margin-bottom: 30px;
}

.results-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
}

.result-item {
    padding: 10px;
    background: #f8f8f8;
    border-radius: 8px;
    margin-bottom: 10px;
}

.result-header {
    font-size: 13px;
    margin-bottom: 5px;
}

.result-content {
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 5px;
}

.result-meta {
    font-size: 12px;
    color: #666;
}

.reconcom-highlight {
    background: #fff59d;
    padding: 1px 2px;
}

.file-result {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.file-result a {
    color: var(--reconcom-primary);
    text-decoration: none;
}

.file-result a:hover {
    text-decoration: underline;
}

/* No Channel Selected */
.no-channel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
    color: #666;
}

.no-channel h2 {
    margin-bottom: 10px;
    color: #333;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .reconcom-details {
        width: 300px;
    }
}

@media (max-width: 992px) {
    .reconcom-sidebar {
        width: 280px;
    }
    
    .reconcom-details {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        z-index: 10;
        box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    }
}

@media (max-width: 768px) {
    .reconcom-interface {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        height: 100vh;
        height: 100dvh;
    }
    
    .reconcom-sidebar {
        position: fixed !important;
        left: -320px;
        top: 0;
        height: 100vh;
        height: 100dvh;
        z-index: 1000;
        transition: left 0.3s;
    }
    
    .reconcom-sidebar.show,
    .reconcom-sidebar.active {
        left: 0;
    }
    
    .reconcom-main {
        width: 100%;
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .message-content {
        width: 85%;
    }
    
    /* Fix mobile chat header */
    .chat-header {
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }
    
    /* Ensure chat messages scroll */
    .chat-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Chat input is handled by iOS-specific rules above */
}

/* Scrollbar Styling */
.channels-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.thread-content::-webkit-scrollbar,
.files-content::-webkit-scrollbar,
.search-results::-webkit-scrollbar {
    width: 6px;
}

.channels-list::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track,
.thread-content::-webkit-scrollbar-track,
.files-content::-webkit-scrollbar-track,
.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.channels-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.thread-content::-webkit-scrollbar-thumb,
.files-content::-webkit-scrollbar-thumb,
.search-results::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.channels-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.thread-content::-webkit-scrollbar-thumb:hover,
.files-content::-webkit-scrollbar-thumb:hover,
.search-results::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.3);
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Adjust chat input area */
    .chat-input {
        padding: 10px;
    }
    
    .input-row {
        gap: 5px;
    }
    
    .file-label {
        padding: 8px;
    }
    
    .send-btn {
        padding: 8px 12px;
    }
    
    /* Adjust message display */
    .message {
        margin: 5px 10px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    /* Adjust header */
    .chat-header {
        padding: 10px 15px;
    }
    
    .chat-header h2 {
        font-size: 18px;
    }
    
    .channel-description {
        font-size: 12px;
    }
    
    /* Adjust sidebar header */
    .sidebar-header {
        padding: 10px;
    }
    
    .user-avatar img {
        width: 35px;
        height: 35px;
    }
    
    .user-name {
        font-size: 13px;
    }
    
    .user-role {
        font-size: 11px;
    }
    
    /* Adjust channel list */
    .channel-item {
        padding: 10px;
    }
    
    .channel-name {
        font-size: 14px;
        font-weight: 800;
    }
    
    .channel-preview {
        font-size: 12px;
    }
    
    /* Fix input on iOS */
    textarea[name="message"] {
        font-size: 16px; /* Prevents zoom on iOS */
        -webkit-appearance: none;
    }
}

/* Very small screens */
@media (max-width: 480px) {
    .chat-header h2 {
        font-size: 16px;
    }
    
    .header-actions {
        display: none;
    }
    
    .message-time {
        font-size: 11px;
    }
}

/* Mobile Thread View */
.mobile-thread-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #e5ddd5;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.mobile-thread-header {
    background: var(--reconcom-primary);
    color: white;
    padding: 15px;
    text-align: center;
}

.mobile-thread-header h3 {
    margin: 0;
    font-size: 18px;
}

.mobile-thread-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mobile-thread-parent {
    padding: 15px;
    background: #f0f0f0;
    border-bottom: 1px solid #ddd;
}

.mobile-thread-separator {
    padding: 10px 15px;
    font-size: 13px;
    text-transform: uppercase;
    color: #666;
    background: #f8f8f8;
    font-weight: 600;
}

.mobile-thread-replies {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    -webkit-overflow-scrolling: touch;
}

.mobile-thread-reply-form {
    background: white;
    border-top: 1px solid #ddd;
    padding: 15px;
    padding-bottom: max(35px, calc(15px + env(safe-area-inset-bottom, 0)));
}

.mobile-thread-reply-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 10px;
}

.mobile-thread-reply-form .send-btn {
    width: auto;
    padding: 8px 20px;
    border-radius: 20px;
}

.back-to-chat {
    position: fixed;
    bottom: 20px;
    bottom: max(20px, calc(20px + env(safe-area-inset-bottom, 0)));
    left: 50%;
    transform: translateX(-50%);
    background: var(--reconcom-primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    z-index: 1002;
}

.mobile-thread-view .loading,
.mobile-thread-view .error {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

/* Mobile Inline Replies */
.mobile-inline-replies {
    background: #f5f5f5;
    margin-left: 60px;
    margin-right: 30px;
    margin-bottom: 10px;
    margin-top: 10px;
    border-radius: 8px;
    padding: 10px;
    display: block;
}

.loading-replies {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

.inline-reply {
    background: #fff5f5;  /* Very pale light red */
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    width: 100%;  /* Full width of the container */
}

.inline-reply.own {
    background: #ffe8e8;  /* Slightly different pale red for own replies */
}

.reply-header {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.reply-author {
    font-weight: 600;
    color: var(--reconcom-primary);
}

.inline-reply.own .reply-author {
    color: #075e54;
}

.reply-time {
    color: #999;
}

.reply-text {
    font-size: 14px;
    line-height: 1.4;
}

/* Mobile Reply Form */
.mobile-inline-reply-form {
    background: white;
    padding: 10px;
    margin-top: 10px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mobile-inline-reply-form textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 8px;
}

.reply-form-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.send-reply-btn,
.cancel-reply-btn {
    padding: 6px 16px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.send-reply-btn {
    background: var(--reconcom-primary);
    color: white;
}

.cancel-reply-btn {
    background: #e0e0e0;
    color: #666;
}

/* Mobile Reply Button in actions */
button.mobile-show-reply-form {
    background: none;
    border: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
}

button.mobile-show-reply-form:hover {
    color: var(--reconcom-primary);
}

/* Mobile reply form placement */
.message + .mobile-inline-reply-form {
    margin-left: 40px;
    margin-right: 10px;
    margin-top: 8px;
    margin-bottom: 10px;
}

/* Hide inline replies on desktop, show regular links */
@media (min-width: 769px) {
    .mobile-inline-replies,
    .mobile-reply-button {
        display: none !important;
    }
    
    /* Hide mobile-specific classes, show regular links */
    .mobile-thread-toggle,
    .mobile-reply-btn {
        /* These classes are used for mobile handling but links should still show */
    }
}

/* On mobile, adjust action links appearance */
@media (max-width: 768px) {
    .mobile-thread-toggle,
    .mobile-reply-btn,
    .action-link[href*="thread="] {
        color: var(--reconcom-primary);
        font-weight: 500;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        user-select: none;
    }
    
    /* Prevent iOS link preview on long press */
    .action-link[href*="thread="] {
        -webkit-touch-callout: none !important;
    }
    
}

/* Notifications Panel Styles */
.notifications-content {
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.no-notifications {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.no-notifications p {
    margin-bottom: 15px;
}

.notification-hint {
    font-size: 14px;
    color: #999;
    margin-bottom: 20px;
}

.notification-types {
    list-style: none;
    padding: 0;
    margin: 0;
}

.notification-types li {
    padding: 8px 0;
    font-size: 14px;
    color: #666;
}

.notifications-list {
    padding: 0;
}

.notification-date-group {
    margin-bottom: 20px;
}

.notification-date {
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    padding: 12px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    position: relative;
    transition: background 0.2s;
}

.notification-item.unread {
    background: #e3f2fd;
}

.notification-item:hover {
    background: #e8e8e8;
}

.notification-item.unread:hover {
    background: #bbdefb;
}

.notification-icon {
    font-size: 20px;
    margin-right: 12px;
    flex-shrink: 0;
}

.notification-content {
    flex-grow: 1;
    min-width: 0;
}

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

.notification-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.notification-channel {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.mention-indicator {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.notification-preview {
    font-size: 13px;
    color: #555;
    line-height: 1.3;
    margin-left: 24px; /* Align with channel name */
}

.notification-message {
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
    word-wrap: break-word;
}

.notification-time {
    font-size: 12px;
    color: #999;
}

.notification-action {
    flex-shrink: 0;
    margin-left: 12px;
}

.view-message {
    display: inline-block;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.view-message:hover {
    opacity: 0.8;
    transform: translateX(2px);
    text-decoration: none;
}

.notifications-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    background: #f8f8f8;
    text-align: center;
}

.clear-notifications-btn {
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.clear-notifications-btn:hover {
    opacity: 0.8;
}

/* Mobile adjustments for notifications */
@media (max-width: 768px) {
    .notifications-content {
        max-height: calc(100vh - 150px);
        padding: 15px;
    }
    
    .notification-item {
        padding: 10px;
    }
    
    .notification-icon {
        font-size: 18px;
        margin-right: 10px;
    }
}

/* File Upload Styles */
.upload-btn {
    background: var(--reconcom-primary, #2196F3);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.upload-btn:hover {
    background: var(--reconcom-primary-dark, #1976D2);
}

.upload-progress {
    background: #e3f2fd;
    color: #1976d2;
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
    font-style: italic;
}

.file-message {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    margin: 5px 0;
    max-width: 300px;
}

.file-info {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.file-icon {
    font-size: 18px;
    margin-right: 8px;
}

.file-name {
    font-weight: bold;
    margin-right: 8px;
    word-break: break-word;
}

.file-size {
    color: #666;
    font-size: 12px;
}

.file-actions {
    text-align: right;
}

.download-btn {
    background: var(--reconcom-primary, #2196F3);
    color: white;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s;
}

.download-btn:hover {
    background: var(--reconcom-primary-dark, #1976D2);
    text-decoration: none;
}

/* File attachment styles for chat messages */
.file-attachment {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    margin: 8px 0;
    max-width: 400px;
    width: 100%;
    gap: 16px;
}

.file-attachment .file-icon {
    font-size: 32px;
    flex-shrink: 0;
    min-width: 40px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Office file type icons in file attachments */
.file-attachment .file-type-icon {
    font-size: 12px !important;
}

.file-attachment .file-type-pdf {
    background: #dc3545;
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.file-attachment .file-type-doc {
    background: #0066cc;
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.file-attachment .file-type-xls {
    background: #28a745;
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.file-attachment .file-type-ppt {
    background: #ea4335;
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.file-attachment .file-type-default {
    background: #6c757d;
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 12px;
}

.file-attachment .file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start !important;
    text-align: left !important;
}

.file-attachment .file-name {
    font-weight: 600;
    color: #1a1a1a;
    word-break: break-word;
    font-size: 15px;
    line-height: 1.3;
}

.file-attachment .file-size {
    font-size: 13px;
    color: #666;
}

.file-attachment .file-actions {
    flex-shrink: 0;
}

.file-attachment .download-btn {
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    background: var(--reconcom-primary, #2196F3);
    color: white;
    transition: background 0.2s;
    white-space: nowrap;
    display: inline-block;
}

.file-attachment .download-btn:hover {
    background: var(--reconcom-primary-dark, #1976D2);
    text-decoration: none;
}

/* Ensure file attachments in own messages align right */
.message.own .file-attachment {
    margin-left: auto;
}