/**
 * AutoBot Frontend Chat Widget Styles
 *
 * Modern glassmorphism design with smooth animations
 *
 * @package AutoBot
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

:root {
    --autobot-widget-primary: #6366f1;
    --autobot-widget-secondary: #8b5cf6;
    --autobot-widget-gradient: linear-gradient(135deg, var(--autobot-widget-primary) 0%, var(--autobot-widget-secondary) 100%);

    --autobot-widget-bg: #ffffff;
    --autobot-widget-bg-secondary: #f8fafc;
    --autobot-widget-text: #0f172a;
    --autobot-widget-text-secondary: #64748b;
    --autobot-widget-text-muted: #94a3b8;
    --autobot-widget-border: #e2e8f0;

    --autobot-widget-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    --autobot-widget-shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);

    --autobot-widget-radius: 16px;
    --autobot-widget-radius-sm: 12px;
    --autobot-widget-radius-lg: 20px;

    --autobot-widget-z-index: 999999;
}

/* ==========================================================================
   Widget Container
   ========================================================================== */

.autobot-widget {
    position: fixed;
    bottom: 24px;
    z-index: var(--autobot-widget-z-index);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.autobot-widget--right {
    right: 24px;
}

.autobot-widget--left {
    left: 24px;
}

.autobot-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   Chat Window
   ========================================================================== */

.autobot-widget__window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-height: calc(100vh - 140px);
    background: var(--autobot-widget-bg);
    border-radius: var(--autobot-widget-radius-lg);
    box-shadow: var(--autobot-widget-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.autobot-widget--left .autobot-widget__window {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.autobot-widget--right .autobot-widget__window {
    right: 0;
}

.autobot-widget.is-open .autobot-widget__window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ==========================================================================
   Header
   ========================================================================== */

.autobot-widget__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--autobot-widget-gradient);
    color: #fff;
}

.autobot-widget__header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.autobot-widget__avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.autobot-widget__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.autobot-widget__avatar svg {
    width: 24px;
    height: 24px;
    stroke: #fff;
}

.autobot-widget__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.autobot-widget__status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.autobot-widget__status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.autobot-widget__status-dot.offline {
    background: #ef4444;
    animation: none;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Phone Input - Inline Country Code */
.autobot-widget__phone-input {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch;
    border: 1px solid var(--autobot-widget-border);
    border-radius: var(--autobot-widget-radius-sm);
    overflow: hidden;
    background: var(--autobot-widget-bg);
    width: 100%;
}

.autobot-widget__phone-input:focus-within {
    border-color: var(--autobot-widget-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.autobot-widget__country-select {
    flex-shrink: 0;
    border: none;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--autobot-widget-text);
    cursor: pointer;
    border-right: 1px solid var(--autobot-widget-border);
    min-width: 80px;
    max-width: 90px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding-right: 24px;
}

.autobot-widget__country-select:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: var(--autobot-widget-bg-secondary);
}

.autobot-widget__phone-number {
    flex: 1 1 auto;
    min-width: 0;
    border: none !important;
    border-radius: 0 !important;
    padding: 12px 14px !important;
    background: transparent !important;
    font-size: 14px;
}

.autobot-widget__phone-number:focus {
    box-shadow: none !important;
    outline: none;
}

/* Custom Icon for Launcher */
.autobot-widget__custom-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 4px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.autobot-widget__close {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.autobot-widget__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.autobot-widget__close svg {
    width: 18px;
    height: 18px;
    stroke: #fff;
}

/* ==========================================================================
   Messages
   ========================================================================== */

.autobot-widget__messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
    max-height: 400px;
    background: var(--autobot-widget-bg-secondary);
}

.autobot-widget__messages::-webkit-scrollbar {
    width: 6px;
}

.autobot-widget__messages::-webkit-scrollbar-track {
    background: transparent;
}

.autobot-widget__messages::-webkit-scrollbar-thumb {
    background: var(--autobot-widget-border);
    border-radius: 3px;
}

.autobot-widget__message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.autobot-widget__message--bot {
    align-self: flex-start;
}

.autobot-widget__message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.autobot-widget__message-avatar {
    width: 32px;
    height: 32px;
    background: var(--autobot-widget-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.autobot-widget__message-avatar svg {
    width: 16px;
    height: 16px;
    stroke: #fff;
}

.autobot-widget__message--user .autobot-widget__message-avatar {
    background: var(--autobot-widget-text-secondary);
}

.autobot-widget__message-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.autobot-widget__message--user .autobot-widget__message-content {
    align-items: flex-end;
}

.autobot-widget__message-name {
    font-size: 12px;
    font-weight: 500;
    color: var(--autobot-widget-text-secondary);
}

.autobot-widget__message-bubble {
    padding: 12px 16px;
    border-radius: var(--autobot-widget-radius-sm);
    line-height: 1.5;
    word-wrap: break-word;
}

.autobot-widget__message--bot .autobot-widget__message-bubble {
    background: var(--autobot-widget-bg);
    color: var(--autobot-widget-text);
    border: 1px solid var(--autobot-widget-border);
    border-bottom-left-radius: 4px;
}

.autobot-widget__message--user .autobot-widget__message-bubble {
    background: var(--autobot-widget-gradient);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.autobot-widget__message-time {
    font-size: 11px;
    color: var(--autobot-widget-text-muted);
}

/* Typing Indicator */
.autobot-widget__typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: var(--autobot-widget-bg);
    border: 1px solid var(--autobot-widget-border);
    border-radius: var(--autobot-widget-radius-sm);
    border-bottom-left-radius: 4px;
}

.autobot-widget__typing-dot {
    width: 8px;
    height: 8px;
    background: var(--autobot-widget-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.autobot-widget__typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.autobot-widget__typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   Footer / Input
   ========================================================================== */

.autobot-widget__footer {
    padding: 16px 20px;
    background: var(--autobot-widget-bg);
    border-top: 1px solid var(--autobot-widget-border);
}

.autobot-widget__form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.autobot-widget__input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--autobot-widget-bg-secondary);
    border: 1px solid var(--autobot-widget-border);
    border-radius: var(--autobot-widget-radius-sm);
    padding: 8px 12px;
    transition: all 0.2s ease;
}

.autobot-widget__input-wrapper:focus-within {
    border-color: var(--autobot-widget-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.autobot-widget__input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--autobot-widget-text);
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    font-family: inherit;
}

.autobot-widget__input:focus {
    outline: none;
}

.autobot-widget__input::placeholder {
    color: var(--autobot-widget-text-muted);
}

.autobot-widget__send {
    width: 36px;
    height: 36px;
    background: var(--autobot-widget-gradient);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.autobot-widget__send:hover {
    transform: scale(1.05);
    box-shadow: var(--autobot-widget-shadow-sm);
}

.autobot-widget__send:active {
    transform: scale(0.95);
}

.autobot-widget__send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.autobot-widget__send svg {
    width: 18px;
    height: 18px;
    stroke: #fff;
}

.autobot-widget__powered {
    text-align: center;
    font-size: 11px;
    color: var(--autobot-widget-text-muted);
}

.autobot-widget__powered strong {
    color: var(--autobot-widget-primary);
}

/* ==========================================================================
   Launcher Button
   ========================================================================== */

.autobot-widget__launcher {
    width: 60px;
    height: 60px;
    background: var(--autobot-widget-gradient);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.autobot-widget__launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
}

.autobot-widget__launcher:active {
    transform: scale(1.05);
}

.autobot-widget__launcher-icon {
    position: absolute;
    transition: all 0.3s ease;
}

.autobot-widget__launcher-icon svg {
    width: 28px;
    height: 28px;
    stroke: #fff;
    fill: none;
}

.autobot-widget__launcher-icon--chat {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

.autobot-widget__launcher-icon--close {
    opacity: 0;
    transform: scale(0.5) rotate(-90deg);
}

.autobot-widget.is-open .autobot-widget__launcher-icon--chat {
    opacity: 0;
    transform: scale(0.5) rotate(90deg);
}

.autobot-widget.is-open .autobot-widget__launcher-icon--close {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

/* Notification Badge */
.autobot-widget__notification {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.autobot-widget__notification.show {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   Error Message
   ========================================================================== */

.autobot-widget__message--error .autobot-widget__message-bubble {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablets */
@media screen and (max-width: 768px) {
    .autobot-widget {
        bottom: 16px;
    }

    .autobot-widget--right {
        right: 16px;
    }

    .autobot-widget--left {
        left: 16px;
    }

    .autobot-widget__window {
        width: 340px;
    }

    .autobot-widget__launcher {
        width: 54px;
        height: 54px;
    }

    .autobot-widget__launcher-icon svg {
        width: 24px;
        height: 24px;
    }

    .autobot-widget__header {
        padding: 14px 16px;
    }

    .autobot-widget__avatar {
        width: 38px;
        height: 38px;
    }

    .autobot-widget__title {
        font-size: 15px;
    }

    .autobot-widget__messages {
        padding: 16px;
        min-height: 250px;
        max-height: 350px;
    }

    .autobot-widget__message {
        max-width: 88%;
    }

    .autobot-widget__message-bubble {
        padding: 10px 14px;
        font-size: 13px;
    }

    .autobot-widget__footer {
        padding: 12px 16px;
    }

    .autobot-widget__prechat {
        padding: 20px;
    }

    .autobot-widget__phone-input {
        flex-direction: row;
    }

    .autobot-widget__country-select {
        min-width: 65px;
        padding: 8px 6px;
        font-size: 12px;
    }
}

/* Mobile Phones */
@media screen and (max-width: 480px) {
    .autobot-widget {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .autobot-widget__window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 100%;
        border-radius: 0;
        transform: translateY(100%);
    }

    .autobot-widget.is-open .autobot-widget__window {
        transform: translateY(0);
    }

    .autobot-widget__messages {
        max-height: none;
        flex: 1;
        min-height: auto;
    }

    .autobot-widget__launcher {
        position: fixed;
        bottom: 12px;
        right: 12px;
        width: 50px;
        height: 50px;
    }

    .autobot-widget--left .autobot-widget__launcher {
        right: auto;
        left: 12px;
    }

    .autobot-widget__launcher-icon svg {
        width: 22px;
        height: 22px;
    }

    .autobot-widget__header {
        padding: 12px 14px;
        border-radius: 0;
    }

    .autobot-widget__avatar {
        width: 36px;
        height: 36px;
    }

    .autobot-widget__title {
        font-size: 14px;
    }

    .autobot-widget__status {
        font-size: 11px;
    }

    .autobot-widget__close {
        width: 32px;
        height: 32px;
    }

    .autobot-widget__close svg {
        width: 16px;
        height: 16px;
    }

    .autobot-widget__message {
        max-width: 90%;
    }

    .autobot-widget__message-bubble {
        padding: 10px 12px;
        font-size: 13px;
        border-radius: 10px;
    }

    .autobot-widget__message-name {
        font-size: 11px;
    }

    .autobot-widget__message-time {
        font-size: 10px;
    }

    .autobot-widget__footer {
        padding: 10px 14px;
    }

    .autobot-widget__input-wrapper {
        padding: 6px 10px;
    }

    .autobot-widget__input {
        font-size: 14px;
    }

    .autobot-widget__send {
        width: 32px;
        height: 32px;
    }

    .autobot-widget__send svg {
        width: 16px;
        height: 16px;
    }

    .autobot-widget__powered {
        font-size: 10px;
    }

    .autobot-widget__prechat {
        padding: 16px;
    }

    .autobot-widget__prechat-message {
        font-size: 13px;
    }

    .autobot-widget__form-group {
        margin-bottom: 10px;
    }

    .autobot-widget__form-group input {
        padding: 10px 12px;
        font-size: 14px;
    }

    .autobot-widget__btn {
        padding: 10px 20px;
        font-size: 13px;
    }

    .autobot-widget__phone-input {
        border-radius: 10px;
    }

    .autobot-widget__country-select {
        min-width: 60px;
        padding: 8px 6px;
        font-size: 12px;
    }

    .autobot-widget__phone-number {
        padding: 10px !important;
        font-size: 14px;
    }
}

/* Extra Small Phones */
@media screen and (max-width: 360px) {
    .autobot-widget__launcher {
        width: 46px;
        height: 46px;
    }

    .autobot-widget__launcher-icon svg {
        width: 20px;
        height: 20px;
    }

    .autobot-widget__header {
        padding: 10px 12px;
    }

    .autobot-widget__avatar {
        width: 32px;
        height: 32px;
    }

    .autobot-widget__title {
        font-size: 13px;
    }

    .autobot-widget__messages {
        padding: 10px;
        gap: 10px;
    }

    .autobot-widget__message-bubble {
        padding: 8px 10px;
        font-size: 12px;
    }

    .autobot-widget__country-select {
        min-width: 55px;
        font-size: 11px;
    }
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {

    .autobot-widget__window,
    .autobot-widget__launcher,
    .autobot-widget__message,
    .autobot-widget__launcher-icon {
        transition: opacity 0.2s ease;
        transform: none !important;
    }

    .autobot-widget__status-dot,
    .autobot-widget__typing-dot {
        animation: none;
    }
}