.scdev-chat-widget {
    position: fixed;
    right: 74px !important;
    bottom: 5px !important;
    z-index: 9999;
    width: min(360px, calc(100vw - 24px));
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.scdev-chat-staff-launcher {
    position: fixed;
    right: 74px !important;
    bottom: 8px !important;
    z-index: 9999;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px !important;
    height: 44px !important;
    padding: 0;
    border-radius: 12px !important;
    background: transparent !important;
    color: #0f172a !important;
    text-decoration: none;
    box-shadow: none !important;
    border: none !important;
    box-sizing: border-box !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.scdev-chat-staff-launcher__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
}

.scdev-chat-staff-launcher__icon svg {
    display: block;
    width: 40px !important;
    height: 40px !important;
}

.scdev-chat-staff-launcher__count {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 10px;
    height: 14px;
    padding: 0 5px;
    border-radius: 999px;
    background: #d63638;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    border: 1.5px solid #ffffff;
}

.scdev-chat-toggle {
    width: 44px !important;
    height: 44px !important;
    border: none !important;
    border-radius: 12px !important;
    background: transparent !important;
    color: #0f172a !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: none !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
    box-sizing: border-box !important;
}

.scdev-chat-toggle:hover,
.scdev-chat-staff-launcher:hover {
    transform: scale(1.08);
}

.scdev-chat-toggle__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px !important;
    height: 40px !important;
    border-radius: 0;
    background: transparent;
}

.scdev-chat-toggle__icon svg {
    display: block;
    width: 40px !important;
    height: 40px !important;
}

.scdev-chat-panel {
    margin-top: 8px;
    background: #fff;
    border: 2px solid #3b82f6;
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 0 0 1px rgba(59, 130, 246, 0.2), 0 0 16px rgba(59, 130, 246, 0.12);
    overflow-y: auto;
    width: 100%;
    height: 340px;
    max-height: 340px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.scdev-chat-panel[hidden] {
    display: none !important;
}

.scdev-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 8px;
    background: linear-gradient(180deg, #eaf2ff 0%, #ffffff 100%);
    border-top-left-radius: 14px;
    border-top-right-radius: 14px;
    border-bottom: 1px solid #dbeafe;
}

.scdev-chat-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #132238;
}

.scdev-chat-close {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0 4px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s ease, background-color 0.15s ease;
}

.scdev-chat-close:hover {
    color: #0f172a;
    background-color: rgba(0, 0, 0, 0.06);
}

.scdev-chat-messages {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    max-height: 110px;
    min-height: 50px;
    overflow-y: auto;
    padding: 6px 12px;
    background: #f8fbff;
}

.scdev-chat-empty {
    margin: auto 0;
    text-align: center;
    color: #667085;
    font-size: 13px;
}

.scdev-chat-bubble {
    max-width: 82%;
    padding: 10px 12px;
    border-radius: 16px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.scdev-chat-bubble.is-visitor {
    align-self: flex-end;
    background: #2f6fdb;
    color: #fff;
    border-bottom-right-radius: 6px;
}

.scdev-chat-bubble.is-admin {
    align-self: flex-start;
    background: #fff;
    color: #17212f;
    border: 1px solid #d9e2f2;
    border-bottom-left-radius: 6px;
}

.scdev-chat-meta {
    display: block;
    margin-bottom: 6px;
    font-size: 11px;
    opacity: 0.8;
}

.scdev-chat-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 14px;
    line-height: 1.45;
}

.scdev-chat-attachment {
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    padding: 7px 11px;
    font-size: 12px;
    cursor: pointer;
}

.scdev-chat-bubble.is-admin .scdev-chat-attachment {
    border-color: #d9e2f2;
    background: #f8fbff;
    color: #1d2327;
}

.scdev-chat-form {
    display: grid;
    gap: 6px;
    padding: 10px 12px;
    flex: 0 0 auto;
    background: #fff;
}

.scdev-chat-identity {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

.scdev-chat-identity label {
    flex: 0 0 auto;
    white-space: nowrap;
}

.scdev-chat-identity input {
    flex: 1 1 auto;
}

.scdev-chat-form label {
    font-size: 12px;
    font-weight: 600;
    color: #344054;
}

.scdev-chat-form input,
.scdev-chat-form textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #c7d3e3;
    border-radius: 10px;
    padding: 6px 10px;
    font-size: 13px;
    line-height: 1.0;
    background: #fff;
}

#scdev-chat-attachment {
    padding: 5px 8px;
    font-size: 12px;
}

.scdev-chat-form textarea {
    min-height: 52px;
    resize: vertical;
}

.scdev-chat-form input:focus,
.scdev-chat-form textarea:focus {
    outline: none;
    border-color: #2f6fdb;
    box-shadow: 0 0 0 3px rgba(47, 111, 219, 0.12);
}

.scdev-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.scdev-chat-actions {
    display: grid;
    gap: 2px;
    margin-bottom: 2px;
}

.scdev-chat-submit {
    border: 0;
    border-radius: 10px;
    background: #131d2d;
    color: #fff;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.0;
    cursor: pointer;
}

.scdev-chat-submit[disabled] {
    opacity: 0.75;
    cursor: wait;
}

.scdev-chat-status {
    min-height: 18px;
    margin: 0;
    color: #516074;
    font-size: 13px;
}

.scdev-chat-status:empty {
    display: none;
}

.scdev-chat-status.is-error {
    color: #b42318;
}

.scdev-chat-status.is-success {
    color: #027a48;
}

.scdev-chat-identity.is-hidden {
    display: none;
}

.scdev-chat-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(15, 23, 42, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.scdev-chat-lightbox[hidden] {
    display: none !important;
}

.scdev-chat-lightbox__dialog {
    position: relative;
    width: min(880px, 100%);
    max-height: 86vh;
    overflow: auto;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.scdev-chat-lightbox__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #131d2d;
    color: #fff;
    cursor: pointer;
}

.scdev-chat-lightbox__body {
    padding: 24px;
}

.scdev-chat-lightbox__body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    border-radius: 16px;
}

.scdev-chat-lightbox__body pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: Consolas, monospace;
}

@media (max-width: 600px) {
    .scdev-chat-widget {
        width: auto !important;
    }

    .scdev-chat-panel {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: min(380px, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px) !important;
        bottom: 64px !important;
        height: auto !important;
        max-height: calc(100vh - 84px) !important;
        max-height: calc(100dvh - 84px) !important;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        box-sizing: border-box !important;
        z-index: 100210 !important;
    }

    .scdev-chat-staff-launcher {
        width: 44px !important;
        height: 44px !important;
    }

    .scdev-chat-staff-launcher__icon,
    .scdev-chat-staff-launcher__icon svg {
        width: 40px !important;
        height: 40px !important;
    }

    .scdev-chat-messages {
        max-height: 200px;
    }
}

@media (max-width: 480px) {
    .scdev-chat-widget {
        width: auto !important;
    }

    .scdev-chat-panel {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        width: min(360px, calc(100vw - 24px)) !important;
        max-width: calc(100vw - 24px) !important;
        bottom: 64px !important;
        height: auto !important;
        max-height: calc(100vh - 80px) !important;
        max-height: calc(100dvh - 80px) !important;
        overflow-x: hidden;
        overflow-y: auto;
        overscroll-behavior: contain;
        box-sizing: border-box !important;
        z-index: 100210 !important;
    }

    .scdev-chat-staff-launcher {
        width: 44px !important;
        height: 44px !important;
    }

    .scdev-chat-staff-launcher__icon,
    .scdev-chat-staff-launcher__icon svg {
        width: 40px !important;
        height: 40px !important;
    }

    .scdev-chat-messages {
        max-height: 180px;
    }
}

/* Night Mode Overrides */
body.night-mode .scdev-chat-panel,
html.night-mode .scdev-chat-panel,
body.dark-mode .scdev-chat-panel,
html.dark-mode .scdev-chat-panel {
    background: #1e1e2d;
    border: 2px solid #3b82f6 !important;
    border-color: #3b82f6 !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(59, 130, 246, 0.35), 0 0 20px rgba(59, 130, 246, 0.25) !important;
}

body.night-mode .scdev-chat-header,
html.night-mode .scdev-chat-header,
body.dark-mode .scdev-chat-header,
html.dark-mode .scdev-chat-header {
    background: linear-gradient(180deg, #1a1a27 0%, #1e1e2d 100%);
    border-bottom: 1px solid #2b2b40;
}

body.night-mode .scdev-chat-header h3,
html.night-mode .scdev-chat-header h3,
body.dark-mode .scdev-chat-header h3,
html.dark-mode .scdev-chat-header h3 {
    color: #e2e8f0;
}

body.night-mode .scdev-chat-close,
html.night-mode .scdev-chat-close,
body.dark-mode .scdev-chat-close,
html.dark-mode .scdev-chat-close {
    color: #94a3b8;
}

body.night-mode .scdev-chat-close:hover,
html.night-mode .scdev-chat-close:hover,
body.dark-mode .scdev-chat-close:hover,
html.dark-mode .scdev-chat-close:hover {
    color: #f1f5f9;
    background-color: rgba(255, 255, 255, 0.1);
}

body.night-mode .scdev-chat-messages {
    background: #1a1a27;
}

body.night-mode .scdev-chat-empty {
    color: #94a3b8;
}

body.night-mode .scdev-chat-bubble.is-admin {
    background: #252538;
    color: #e2e8f0;
    border-color: #3b3b54;
}

body.night-mode .scdev-chat-bubble.is-visitor {
    background: #2f6fdb;
}

body.night-mode .scdev-chat-bubble.is-admin .scdev-chat-attachment {
    border-color: #3b3b54;
    background: #1e1e2d;
    color: #e2e8f0;
}

body.night-mode .scdev-chat-form {
    background: #1e1e2d;
    border-top: 1px solid #2b2b40;
}

body.night-mode .scdev-chat-form label {
    color: #94a3b8;
}

body.night-mode .scdev-chat-form input,
body.night-mode .scdev-chat-form textarea {
    background: #151521;
    border-color: #3b3b54;
    color: #e2e8f0;
}

body.night-mode .scdev-chat-form textarea::placeholder,
body.night-mode .scdev-chat-form input::placeholder {
    color: #94a3b8;
}

body.night-mode .scdev-chat-submit {
    background: #2f6fdb;
    color: #ffffff;
}

body.night-mode .scdev-chat-submit:hover {
    background: #4a8cf8;
}

body.night-mode .scdev-chat-form input:focus,
body.night-mode .scdev-chat-form textarea:focus {
    border-color: #4a8cf8;
    box-shadow: 0 0 0 3px rgba(74, 140, 248, 0.2);
}

body.night-mode .scdev-chat-lightbox__dialog {
    background: #1e1e2d;
    color: #e2e8f0;
}

body.night-mode .scdev-chat-status {
    color: #94a3b8;
}