/* Chat & Activity Board */
.board-container {
    position: fixed;
    bottom: 0;
    right: 20px;
    width: 350px;
    height: 400px;
    background: #ffffff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px 8px 0 0;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: all 0.3s ease;
    border: 1px solid #dee2e6;
}

.board-container.minimized {
    height: 40px !important;
    overflow: hidden;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
}

.board-container.minimized .board-content,
.board-container.minimized .board-input {
    display: none;
}

.board-container.expanded {
    width: 100%;
    height: calc(100vh - 56px); /* Default height with menu */
    right: 0;
    border-radius: 0;
    top: 56px; /* Default top position at menu height */
    bottom: auto;
}

@media (min-width: 769px) {
    .board-container.expanded {
        top: 59.5px; /* Add gap on top */
        height: calc(100vh - 59.5px); /* Account for the gap */
    }
}

.board-header {
    padding: 10px 15px;
    background: #007bff;
    color: #ffffff;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    position: relative;
    z-index: 1051;
}

.board-header h3 {
    pointer-events: none; /* Let clicks pass through to header */
}

.board-header h3 {
    font-size: 1rem;
    margin: 0;
}

.board-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
    z-index: 1051; /* Higher than board-container */
    pointer-events: auto;
}

.control-btn {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    transition: opacity 0.3s ease;
    position: relative;
    z-index: 1052; /* Higher than board-controls */
    pointer-events: auto;
}

.control-btn:hover {
    opacity: 0.8;
}

.expand-btn {
    font-size: 1rem;
    margin-left: -4.5px; /* Shift 1px left on desktop */
}

@media (max-width: 768px) {
    .expand-btn {
        margin-left: 0; /* Reset for mobile */
    }
}

.hide-btn {
    font-size: 1.1rem;
}

/* Hidden state - consistent across all views */
.board-container.hidden {
    width: 40px !important;
    height: 45px !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    left: auto !important;
    border-radius: 8px 0 0 0;
    position: fixed !important;
    border: none;
    background: #007bff;
    transition: none;
}

.board-container.hidden .control-btn {
    padding: 2px;
}

.board-container.hidden .board-header {
    padding: 10px;
    border-radius: 8px 0 0 0;
}

.board-container.hidden h3,
.board-container.hidden .board-content,
.board-container.hidden .board-input {
    display: none;
}

.board-container.hidden .board-controls {
    justify-content: center;
}

.board-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px 10px 0 10px; /* Reduced horizontal padding from 15px to 10px */
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    height: 100%;
    z-index: 1;
    width: 100%;
    box-sizing: border-box;
}

.board-content::-webkit-scrollbar {
    width: 6px;
}

.board-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.board-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

/* Ensure scrollbar shows in expanded view */
.board-container.expanded .board-content {
    overflow-y: auto;
    overflow-x: hidden;
}

.board-container.expanded .board-content::-webkit-scrollbar {
    width: 6px;
}

.board-container.expanded .board-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.board-container.expanded .board-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.board-input {
    flex: 0 0 75px;
    display: flex;
    gap: 10px;
    padding: 13px;
    background: #ffffff;
    border-top: 1px solid #dee2e6;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.board-input .button-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.line-button {
    display: none;
}

.board-container.expanded .board-input {
    border-radius: 0;
}

.board-input textarea {
    flex: 1;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    resize: none;
    height: 48px;
    font-size: 0.9rem;
}

.board-input button#sendMessage {
    background: #007bff;
    color: #ffffff;
    border: none;
    padding: 0 15px;
    height: 32px;
    min-width: 80px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    margin: 8px 0 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.board-input button:hover {
    background: #0056b3;
}

.line-button:active {
    transform: translateY(1px);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

/* Message Styles */
.message-group {
    width: 100%;
    margin: 4px 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Default align to left */
}

.message-group:not(.own-message) {
    align-items: flex-end; /* Align other people's messages to right */
}

.message {
    margin: 1px 0;
    padding: 10px;
    border-radius: 18px;
    font-size: 0.9375rem;
    line-height: 1.3;
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: inline-block;
    max-width: 90%; /* Increased from 85% to 90% */
    box-sizing: border-box;
}

.message-group:not(.own-message) .message {
    background: #0084ff;
    color: #ffffff;
    border-top-right-radius: 4px;
    align-self: flex-end;
    margin-right: 5px; /* Reduced from 15px to 5px */
}

.message-group.own-message .message {
    background: #e9ecef;
    color: #000000;
    border-top-left-radius: 4px;
    align-self: flex-start;
    margin-left: 5px; /* Reduced from 15px to 5px */
}

.message-group .sender {
    font-size: 0.75rem;
    margin-bottom: 2px;
    padding: 0;
    color: #65676B;
    display: block;
    clear: both;
}

.message-group:not(.own-message) .sender {
    text-align: right;
    padding-right: 5px; /* Reduced from 15px to 5px */
    width: 100%;
}

.message-group.own-message .sender {
    text-align: left;
    padding-left: 5px; /* Reduced from 15px to 5px */
    width: 100%;
}

.message-group .user-link {
    color: #1565c0;
    text-decoration: none;
    font-weight: 500;
}

.message-group .user-link:hover {
    text-decoration: underline;
}

.message-group.own-message .user-link {
    color: #0084ff;
}

.message-group .timestamp {
    font-size: 0.6875rem;
    color: #65676B;
    margin-top: 2px;
    padding: 0;
    opacity: 0.7;
    display: block;
    width: 100%;
}

.message-group:not(.own-message) .timestamp {
    text-align: right;
    padding-right: 5px; /* Reduced from 15px to 5px */
}

.message-group.own-message .timestamp {
    text-align: left;
    padding-left: 5px; /* Reduced from 15px to 5px */
}

/* Mobile Input Adjustments */
@media (max-width: 768px) {
    .board-input {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 75px;
        padding: 13px;
        background: #fff;
        border-top: 1px solid #dee2e6;
        box-shadow: 0 -1px 4px rgba(0,0,0,0.05);
        z-index: 1051;
        display: flex;
        align-items: flex-start;
        gap: 10px;
    }

    .board-input textarea {
        font-size: 16px;
        padding: 6px;
        height: 48px;
        line-height: 20px;
    }

    .board-input .button-container {
        display: flex;
        flex-direction: column;
        width: 80px;
        height: 48px;
        position: relative;
        justify-content: space-between;
    }

    .board-input button#sendMessage {
        min-width: 80px;
        padding: 0;
        height: 41px;
        font-size: 0.875rem;
        line-height: 32.5px;
        border-radius: 2px;
        margin: 0 0 1.5px 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .line-button.mobile-only {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 80px;
        height: 14px;
        line-height: 12px;
        font-size: 0.75rem;
        background: #ffffff;
        color: #000000;
        border: 1px solid #dee2e6;
        padding: 0;
        padding-bottom: 1px;
        font-size: 0.75rem;
        border-radius: 2px;
        margin: 0;
        transition: none;
        user-select: none;
        -webkit-user-select: none;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        box-sizing: border-box;
        position: absolute;
        top: 47.5px;
        box-sizing: border-box;
    }

    .line-button.mobile-only:hover,
    .line-button.mobile-only:focus {
        background: #ffffff;
        outline: none;
        border-color: #dee2e6;
    }

    .line-button.mobile-only:active {
        transform: none;
        box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
        background: #f8f8f8;
        border-color: #d4d4d4;
    }

    /* Base mobile container */
    .board-container {
        position: fixed;
        left: 0;
        right: 0;
        width: 100%;
        background: #ffffff;
        z-index: 1050;
        border: none;
        margin: 0;
        border-radius: 0;
        bottom: 75px; /* Exactly above input */
        height: calc(50vh - 75px);
    }

    /* Mobile header - fixed height */
    .board-header {
        height: 40px;
        min-height: 40px;
        padding: 8px 12px;
        background: #007bff;
        color: #ffffff;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-radius: 0;
    }

    /* Mobile content area */
    .board-container .board-content {
        position: absolute;
        top: 40px; /* Below header */
        left: 0;
        right: 0;
        bottom: 0;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        padding: 15px 10px 30px 10px; /* Reduced horizontal padding from 15px to 10px */
        margin: 0;
        background: #ffffff;
        box-sizing: border-box;
        will-change: transform; /* Optimize scrolling */
        height: calc(100% - 40px); /* Full height minus header */
    }

    /* Mobile expanded container */
    .board-container.expanded {
        top: 57px !important; /* Below menu */
        bottom: 75px !important; /* Above input */
        width: 100% !important;
        height: unset !important; /* Let height be determined by top/bottom */
        max-height: unset !important;
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1050;
        background: #ffffff;
        display: flex;
        flex-direction: column;
    }

    /* Expanded view content area */
    .board-container.expanded .board-content {
        position: absolute;
        top: 40px;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 15px 10px 30px 10px; /* Reduced horizontal padding */
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        background: #ffffff;
        box-sizing: border-box;
        will-change: transform;
        height: calc(100% - 40px);
        -webkit-backface-visibility: hidden; /* Prevent scroll jank */
        transform: translateZ(0); /* Force GPU acceleration */
    }

    .board-container.expanded .board-header {
        flex: 0 0 40px;
        position: relative;
    }

    /* Minimized state */
    .board-container.minimized {
        height: 40px !important;
        max-height: 40px !important;
        overflow: hidden !important;
        border-bottom: none;
        bottom: 0 !important;
        top: auto !important;
    }

    .board-container.minimized .board-content,
    .board-container.minimized .board-input {
        display: none !important;
    }

    .board-container.minimized .board-header {
        height: 40px;
        padding: 0 12px;
        display: flex;
        align-items: center;
    }

    /* Message adjustments */
    .message-group {
        width: calc(100% - 10px); /* Reduced from calc(100% - 30px) */
        margin: 4px auto;
    }

    /* Mobile button spacing */
    .board-controls {
        gap: 16px !important; /* Double spacing only for mobile */
    }
}

/* Desktop & Tablet */
@media (min-width: 769px) {
    .board-container {
        width: 350px;
        height: 400px;
        right: 10px; /* Much closer to edge on desktop */
    }
}

/* Error message styling */
.error-message {
    background-color: #fff3f3;
    color: #d32f2f;
    padding: 10px;
    border-radius: 4px;
    margin: 10px auto;
    text-align: center;
    font-size: 0.9rem;
    border-left: 3px solid #d32f2f;
    max-width: 90%;
}

/* Replace the existing scrollbar styles with these */
.board-content::-webkit-scrollbar {
    display: none;
}

.board-content {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;     /* Firefox */
}

/* Also ensure expanded view has no scrollbars */
.board-container.expanded .board-content::-webkit-scrollbar {
    display: none;
}
