// Chat Widget Container
.acb-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

// Floating Chat Button
.acb-widget-button {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;

    &:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
    }

    &.hidden {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.8);
    }

    i {
        color: white;
        font-size: 24px;
    }
}

// Unread Badge
.acb-widget-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
}

// Main Widget
.acb-widget {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 540px;
    height: 620px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;

    &.minimized {
        height: 60px;

        .acb-widget-content {
            display: none;
        }
    }
}

// Widget Header
.acb-widget-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.acb-widget-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 600;

    i {
        font-size: 18px;
    }
}

.acb-widget-controls {
    display: flex;
    gap: 8px;
}

.acb-widget-minimize,
.acb-widget-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;

    &:hover {
        background: rgba(255, 255, 255, 0.1);
    }

    i {
        font-size: 14px;
    }
}

// Widget Content
.acb-widget-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

// Authentication Section
.acb-widget-auth {
    padding: 24px;
    text-align: center;
    overflow-y: scroll;

    h3 {
        margin: 0 0 8px 0;
        font-size: 20px;
        font-weight: 600;
        color: #2c3e50;
    }

    p {
        margin: 0 0 24px 0;
        color: #7f8c8d;
        font-size: 14px;
    }
}

.acb-widget-google-btn {
    width: 100%;
    padding: 12px;
    background: #4285f4;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 16px;
    transition: background-color 0.2s;

    &:hover {
        background: #3367d6;
    }

    i {
        font-size: 16px;
    }
}

.acb-widget-divider {
    position: relative;
    margin: 16px 0;
    text-align: center;

    &::before {
        content: '';
        position: absolute;
        top: 50%;
        left: 0;
        right: 0;
        height: 1px;
        background: #e0e0e0;
    }

    span {
        background: white;
        padding: 0 12px;
        color: #7f8c8d;
        font-size: 12px;
    }
}

.acb-widget-email-btn {
    width: 100%;
    padding: 12px;
    background: #34495e;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;

    &:hover {
        background: #2c3e50;
    }
}

// Email Form
.acb-widget-email-form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;

    input[type="email"],
    input[type="password"],
    input[type="text"] {
        padding: 12px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        font-size: 14px;
        outline: none;
        transition: border-color 0.2s;

        &:focus {
            border-color: #667eea;
        }

        &::placeholder {
            color: #bdc3c7;
        }
    }
}

.acb-widget-profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.acb-widget-upload-btn {
    width: 80px;
    height: 80px;
    border: 2px dashed #e0e0e0;
    border-radius: 50%;
    background: #f8f9fa;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #7f8c8d;
    transition: all 0.2s;

    &:hover {
        border-color: #667eea;
        background: #f0f2ff;
    }

    i {
        font-size: 20px;
        margin-bottom: 4px;
    }
}

.acb-widget-profile-preview {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
}

.acb-widget-form-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;

    button {
        padding: 12px;
        border: none;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;

        &:first-child {
            background: #667eea;
            color: white;

            &:hover {
                background: #5a67d8;
            }
        }

        &:last-child {
            background: none;
            color: #667eea;

            &:hover {
                background: #f0f2ff;
            }
        }
    }
}

// Chat Interface
.acb-widget-chat {
    flex: 1;
    display: flex;
    overflow: hidden;
}

// Users Section
.acb-widget-users {
    width: 210px;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.acb-widget-user-header {
    padding: 12px;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
}

.acb-widget-current-user {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;

    span {
        font-size: 12px;
        font-weight: 500;
        color: #2c3e50;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

.acb-widget-signout {
    background: none;
    border: none;
    color: #7f8c8d;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;

    &:hover {
        color: #e74c3c;
    }
}

.acb-widget-search {
    margin: 12px;
    padding: 8px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
    outline: none;

    &:focus {
        border-color: #667eea;
    }

    &::placeholder {
        color: #bdc3c7;
    }
}

.acb-widget-users-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.acb-widget-user-item {
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    margin-bottom: 2px;

    &:hover {
        background: #e9ecef;
    }

    &.active {
        background: #667eea;
        color: white;

        .acb-widget-user-name {
            color: white;
        }

        .acb-widget-user-status {
            color: rgba(255, 255, 255, 0.8);
        }
    }

    &.has-new-message {
        background: #fff3cd;
        border-left: 3px solid #ffc107;
    }
}

.acb-widget-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.acb-widget-user-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.acb-widget-user-name {
    font-size: 11px;
    font-weight: 500;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.acb-widget-user-status {
    font-size: 10px;
    color: #7f8c8d;

    &.online {
        color: #27ae60;
    }

    &.offline {
        color: #95a5a6;
    }
}

.acb-widget-new-indicator {
    position: absolute;
    top: 4px;
    right: 4px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
}

// Chat Area
.acb-widget-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.acb-widget-chat-header {
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 12px;

    span {
        font-size: 14px;
        font-weight: 500;
        color: #2c3e50;
    }
}

.acb-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.acb-widget-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;

    &.own {
        align-self: flex-end;
        align-items: flex-end;

        .acb-widget-message-content {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
    }

    &.other {
        align-self: flex-start;
        align-items: flex-start;

        .acb-widget-message-content {
            background: white;
            color: #2c3e50;
            border: 1px solid #e9ecef;
        }
    }
}

.acb-widget-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;

    p {
        margin: 0;
        font-size: 14px;
        line-height: 1.4;
    }
}

.acb-widget-message-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    object-fit: cover;
}

.acb-widget-message-file {
    display: flex;
    align-items: center;
    gap: 8px;

    i {
        font-size: 16px;
        color: #7f8c8d;
    }

    a {
        color: inherit;
        text-decoration: none;
        font-size: 14px;

        &:hover {
            text-decoration: underline;
        }
    }
}

.acb-widget-message-time {
    font-size: 11px;
    color: #7f8c8d;
    margin-top: 4px;
}

.acb-widget-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;

    input[type="text"] {
        flex: 1;
        padding: 10px 12px;
        border: 1px solid #e0e0e0;
        border-radius: 20px;
        font-size: 14px;
        outline: none;
        transition: border-color 0.2s;

        &:focus {
            border-color: #667eea;
        }

        &::placeholder {
            color: #bdc3c7;
        }
    }

    button {
        width: 40px;
        height: 40px;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;

        &:disabled {
            opacity: 0.5;
            cursor: not-allowed;
        }

        i {
            font-size: 14px;
        }
    }
}

.acb-widget-attach {
    background: #f8f9fa;
    color: #7f8c8d;

    &:hover:not(:disabled) {
        background: #e9ecef;
    }
}

.acb-widget-input button:last-of-type {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;

    &:hover:not(:disabled) {
        transform: scale(1.05);
    }
}

// No Chat State
.acb-widget-no-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #7f8c8d;

    i {
        font-size: 48px;
        margin-bottom: 16px;
        opacity: 0.5;
    }

    p {
        margin: 0;
        font-size: 14px;
    }
}

// Responsive Design
@media (max-width: 480px) {
    .acb-widget-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }

    .acb-widget {
        width: 100%;
        height: 100vh;
        border-radius: 0;
        bottom: 0;
        right: 0;
        left: 0;
    }

    .acb-widget-users {
        width: 120px;
    }

    .acb-widget-user-name {
        font-size: 10px;
    }

    .acb-widget-user-status {
        font-size: 9px;
    }
}

// Scrollbar Styling
.acb-widget-users-list::-webkit-scrollbar,
.acb-widget-messages::-webkit-scrollbar {
    width: 4px;
}

.acb-widget-users-list::-webkit-scrollbar-track,
.acb-widget-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.acb-widget-users-list::-webkit-scrollbar-thumb,
.acb-widget-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.acb-widget-users-list::-webkit-scrollbar-thumb:hover,
.acb-widget-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

// Loading and Error States
.acb-widget-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #7f8c8d;
}

.acb-widget-error {
    padding: 16px;
    background: #f8d7da;
    color: #721c24;
    border-radius: 8px;
    margin: 16px;
    font-size: 14px;
}

// Animations
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.acb-widget-message {
    animation: fadeIn 0.3s ease-out;
}

.acb-widget {
    animation: fadeIn 0.3s ease-out;
}

// Focus States
.acb-widget input:focus,
.acb-widget button:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

// High Contrast Mode Support
@media (prefers-contrast: high) {
    .acb-widget {
        border: 2px solid #000;
    }

    .acb-widget-message-content {
        border-width: 2px;
    }
}

// Reduced Motion Support
@media (prefers-reduced-motion: reduce) {

    .acb-widget-button,
    .acb-widget-message,
    .acb-widget,
    * {
        animation: none !important;
        transition: none !important;
    }
}