/* ----------------------------------------------------
   BASIC CHAT AND ARCHIVE RULES
------------------------------------------------------- */
#simple_chat strong, 
#simple_chat b:not(.icon), 
.sc-msg-content strong, 
.sc-msg-content b:not(.icon) {
    color: inherit !important;
    font-weight: bold !important;
}

#simple_chat em, 
#simple_chat i:not(.icon), 
.sc-msg-content em, .sc-msg-content i:not(.icon) {
    color: inherit !important;
    font-style: italic !important;
} 

/* Resize images in chat and archive */
#simple_chat img, .sc-msg-content img {
    max-width: 100%; 
    max-height: 200px; 
    height: auto; 
    object-fit: contain;
    border-radius: 4px; 
    vertical-align: middle;
}

/* Limit smilies size (SVG support) */
#simple_chat img.smilies, .sc-msg-content img.smilies {
    max-height: 24px !important;
    width: auto !important;
    border-radius: 0;
    vertical-align: middle;
}

/* ----------------------------------------------------
    STRUCTURAL STYLES
------------------------------------------------------- */
.sc-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 6px;
    box-sizing: border-box;
}

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

.sc-audio-icon {
    color: white;
    cursor: pointer;
    font-size: 1.2em;
}

.sc-title {
    font-weight: bold;
    font-size: 1.1em;
}

.sc-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sc-icon {
    cursor: pointer;
    font-size: 1.1em;
}

.sc-action-btn,
.sc-audio-icon {
    transition: opacity .2s ease;
}

.sc-action-btn:hover,
.sc-audio-icon:hover {
    opacity: .75;
}

.sc-icon.fa-fw, 
#chat_audio_icon.fa-fw,
.sc-buttons-wrapper .fa-fw {
    display: inline-block !important;
    text-align: center !important;
    width: 1.25em !important;
}

#simple_chat .fa-spin.fa-fw { width: 2em !important; }

.sc-forums-list {
    margin: 0;
    padding: 4px;
    background: inherit;
}

.sc-row-main {
    padding: 0;
    border-bottom: none;
    background: transparent !important;
}

.sc-popup-panel {
    display: none;
    padding: 5px;
    background: inherit;
    border: 1px solid currentColor;
    margin-bottom: 4px;
    text-align: center;
}

.sc-popup-scrollable {
    max-height: 120px;
    overflow-y: auto;
}

.sc-custom-btn {
    height: 24px;
    line-height: 20px;
    font-size: 0.85em;
    padding: 0 5px;
    margin: 2px;
}

.sc-input-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.sc-input-wrapper {
    flex-grow: 1;
    padding-right: 5px;
}

.sc-input-box {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    margin: 5px 0 0 2px;
    border: 1px solid currentColor;
    border-radius: 3px;
    background: inherit;
    color: inherit;
    font-family: inherit;
    font-size: 1em;
    outline: none;
    transition: all .2s ease;
}

.sc-input-box:focus { box-shadow: 0 0 4px rgba(0,0,0,.18); }

.sc-buttons-wrapper {
    white-space: nowrap;
    display: flex;
    gap: 2px;
}

.sc-font-select {
    height: 24px;
    cursor: pointer;
    font-size: .9em;
    border: 1px solid currentColor;
    border-radius: 3px;
    background: inherit;
    color: inherit;
}

.sc-submit-btn {
    font-weight: bold;
    cursor: pointer;
    margin-left: 2px;
}

.sc-error-guest,
.sc-error-login {
    text-align: center;
    font-weight: bold;
    margin-bottom: 4px;
}

.sc-error-guest { color: red; }
.sc-error-login { color: #bc2a4d; margin-top: 4px; }

#simple_chat {
    overflow: auto;
    background: inherit;
}

.sc-loading {
    text-align: center;
    margin-top: 20px;
}

/* ----------------------------------------------------
    CHAT AND MESSAGE STYLES
------------------------------------------------------- */
.sc-msg-row {
    border-bottom: 1px solid #fff;
    padding: 4px;
    font-size: 1.1em;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.sc-forums-list li.row.sc-row-main {
    border-top: none !important;
    border-bottom: none !important;
}

.sc-avatar-container {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    margin-right: 8px;
    border-radius: 50%;
    background: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

.sc-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.sc-avatar-default { font-size: 18px; }

.sc-msg-body { word-break: break-word; width: 100%; }
.sc-msg-date {
    opacity: .75;
    font-size: .85em;
}

.sc-msg-content:has(img:not(.smilies):not(.emoji)),
.sc-msg-content:has(iframe),
.sc-msg-content:has(video) {
    display: block;
    margin-top: 6px;
}

.sc-online { color: #228B22; }
.sc-offline { color: #bc2a4d; }
.sc-status-dot { font-size: 0.7em; vertical-align: middle; margin-right: 2px; }

.sc-msg-actions {
    white-space: nowrap;
    margin-left: 10px;
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 5px;
}

.sc-action-btn { text-decoration: none; font-size: 1.1em; }
.sc-btn-quote { color: #222; }
.sc-btn-edit { color: #009900; }
.sc-btn-delete { color: #bc2a4d; }

.sc-msg-empty,
.sc-msg-error { text-align: center; margin-top: 10px; font-weight: bold; }
.sc-msg-empty { color: red; }
.sc-msg-error { color: #bc2a4d; }

.sc-smiley-img { 
    cursor: pointer; 
    margin: 4px; 
    max-height: 24px !important; 
    width: auto !important; 
    vertical-align: middle;
}

.sc-smilies-more-container { text-align: center; margin-top: 8px; padding-top: 5px; border-top: 1px solid #ccc; }
.sc-smilies-more-link { font-weight: bold; color: #105289; font-size: 0.9em; }

/* --- KILL ALL BORDERS AND BACKGROUNDS ON QUOTES --- */
.sc-quote-header, 
.sc-quote-body,
.sc-quote-header *, 
.sc-quote-body * {
    border: none !important;
    border-style: none !important;
    background-image: none !important;
    background-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Re-apply only the colors we want */
.sc-quote-header {
    background-color: #e9e9e9 !important;
    padding: 5px !important;
    font-weight: bold !important;
    font-size: 0.8em !important;
}

.sc-quote-body {
    background-color: #fcfcfc !important;
    padding: 10px !important;
    font-style: italic !important;
    margin-bottom: 5px !important;
}

/* ----------------------------------------------------
   MOBILE DEVICE RULES (Responsive Design)
------------------------------------------------------- */
@media (max-width: 768px) {
    /* Unlock chat visibility */
    .sc-mobile-hide {
        display: block !important;
    }

    /* Stack input area and buttons vertically */
    .sc-input-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .sc-input-wrapper {
        padding-right: 0;
        margin-bottom: 5px;
        width: 100%;
    }
    
    /* Wrap buttons and tighten spacing */
    .sc-buttons-wrapper {
        flex-wrap: wrap;
        justify-content: center;
        gap: 2px;
    }
    
    /* Force smaller sizes for buttons */
    .sc-buttons-wrapper .button {
        padding: 2px 6px !important;
        font-size: 0.85em !important;
        margin: 0 !important;
        transition: opacity .2s ease;
    }

    .sc-buttons-wrapper .button:hover {
        opacity: .8;
    }
    
    /* Resize font select dropdown */
    .sc-font-select {
        height: 22px !important;
        padding: 0 2px !important;
        font-size: 0.85em !important;
    }

    /* Limit max height on mobile */
    #simple_chat {
        max-height: 250px !important; 
    }

    #simple_chat a { text-decoration: underline; }
    #simple_chat a:hover,
    .sc-history-list a:hover {
        text-decoration: none;
    }

    /* Reorganize message structure */
    .sc-msg-row {
        flex-direction: column;
        position: relative;
        padding-bottom: 5px;
    }
    
    /* Align action buttons to bottom right */
    .sc-msg-actions {
        margin-left: 0;
        margin-top: 5px;
        align-self: flex-end;
    }
}
