@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazir-font@v30.1.0/dist/font-face.css');

* {
    box-sizing: border-box;
    font-family: Vazir, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

#chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: Vazir, sans-serif;
    direction: rtl;
}

.chat-widget-toggle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    background-image: url('https://chat.bayanenab.ir/assets/img/icon-widget.png');
    background-size: 100%;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4),
    0 4px 8px rgba(0, 0, 0, 0.1);
    animation: slideInFromRight 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.5s backwards,
    pulse 2s ease-in-out 1.3s infinite;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInFromRight {
    0% {
        transform: translateX(150px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4),
        0 4px 8px rgba(0, 0, 0, 0.1);
    }
    50% {
        box-shadow: 0 8px 32px rgba(102, 126, 234, 0.6),
        0 4px 12px rgba(0, 0, 0, 0.15);
    }
}

.chat-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5),
    0 6px 12px rgba(0, 0, 0, 0.15);
}

.chat-widget-toggle:active {
    transform: scale(0.95);
}

.chat-widget-toggle.hidden {
    animation: fadeOut 0.3s ease forwards;
    pointer-events: none;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.8);
    }
}

.chat-widget-toggle.show {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.chat-widget-window {
    position: absolute;
    bottom: 88px;
    right: 0;
    width: 400px;
    height: 600px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12),
    0 8px 24px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: expandWindow 0.5s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

@keyframes expandWindow {
    0% {
        opacity: 0;
        transform: scale(0.85) translateY(30px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chat-widget-window.closing {
    animation: collapseWindow 0.4s cubic-bezier(0.4, 0, 1, 1) forwards;
}

@keyframes collapseWindow {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.85) translateY(30px);
    }
}

.chat-widget-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-direction: row-reverse;
    position: relative;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.2);
}

.chat-widget-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,0.1), transparent);
    pointer-events: none;
}

.chat-widget-header h3 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.3px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.chat-widget-status {
    margin: 6px 0 0 0;
    font-size: 13px;
    opacity: 0.95;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-widget-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.chat-widget-close-btn {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-widget-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
}

.chat-start-form {
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    direction: rtl;
}

.chat-start-form h4 {
    margin: 0 0 4px 0;
    font-size: 22px;
    font-weight: 700;
    color: #1f2937;
    text-align: center;
    letter-spacing: -0.5px;
}

.chat-start-form p {
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.chat-start-form input {
    width: 100%;
    padding: 16px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 14px;
    font-size: 15px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: Vazir, sans-serif;
    direction: rtl;
    text-align: right;
    background: #fafafa;
}

.chat-start-form input::placeholder {
    text-align: right;
    direction: rtl;
    color: #9ca3af;
    font-family: Vazir, sans-serif;
}

.chat-start-form input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: white;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1),
    0 4px 12px rgba(139, 92, 246, 0.08);
    transform: translateY(-2px);
}

.chat-start-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);
    color: white;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: Vazir, sans-serif;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
    position: relative;
    overflow: hidden;
}

.chat-start-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity 0.3s;
}

.chat-start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

.chat-start-btn:hover::before {
    opacity: 1;
}

.chat-start-btn:active {
    transform: translateY(-1px);
}

.chat-start-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

#chat-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: linear-gradient(180deg, #f9fafb 0%, #f3f4f6 100%);
    direction: rtl;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #cbd5e1, #94a3b8);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #94a3b8, #64748b);
    background-clip: padding-box;
}

.chat-message {
    display: flex;
    margin-bottom: 6px;
    animation: messageSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message-visitor {
    justify-content: flex-end;
}

.chat-message-operator {
    justify-content: flex-start;
}

.chat-message-content {
    max-width: 78%;
    padding: 14px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    direction: rtl;
    text-align: right;
    position: relative;
}

.chat-message-visitor .chat-message-content {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25),
    0 2px 8px rgba(139, 92, 246, 0.15);
}

.chat-message-operator .chat-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04),
    0 1px 4px rgba(0, 0, 0, 0.02);
}

.chat-message-content strong {
    display: block;
    font-size: 12px;
    margin-bottom: 6px;
    opacity: 0.85;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.chat-message-content p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    font-weight: 500;
}

.chat-message-time {
    display: block;
    font-size: 11px;
    margin-top: 8px;
    opacity: 0.65;
    font-weight: 500;
}

.chat-message-system {
    text-align: center;
    font-size: 13px;
    color: #6b7280;
    padding: 10px 16px;
    background: rgba(139, 92, 246, 0.08);
    border-radius: 12px;
    margin: 6px 0;
    border: 1px solid rgba(139, 92, 246, 0.12);
    font-weight: 500;
}

.chat-input-wrapper {
    display: flex;
    padding: 18px 24px;
    background: white;
    border-top: 1px solid #e5e7eb;
    gap: 12px;
    direction: rtl;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.03);
}

#chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 2px solid #e5e7eb;
    border-radius: 24px;
    font-size: 15px;
    font-family: Vazir, sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl;
    text-align: right;
    background: #fafafa;
}

#chat-input::placeholder {
    text-align: right;
    direction: rtl;
    color: #9ca3af;
}

#chat-input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: white;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.1);
}

.chat-send-btn {
    padding: 14px 28px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: Vazir, sans-serif;
    box-shadow: 0 4px 16px rgba(139, 92, 246, 0.3);
}

.chat-send-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.4);
}

.chat-send-btn:active {
    transform: translateY(-1px);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

#sms-code-input {
    font-family: 'Courier New', monospace;
    font-size: 24px;
    letter-spacing: 8px;
    text-align: center;
}

#code-timer {
    animation: timerPulse 2s infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.hidden {
    display: none !important;
}

@media (max-width: 768px) {

    #chat-widget-container {
        bottom: 20px;
        right: 20px;
    }

    .chat-widget-toggle {
        width: 56px;
        height: 56px;
    }

    .chat-widget-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        max-width: 400px;
        max-height: 600px;
        bottom: 88px;
        right: 0;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-wrapper {
        padding: 14px 16px;
    }

    .chat-message-content {
        max-width: 85%;
    }

    .chat-start-form {
        padding: 24px 16px;
    }
}

@media (max-width: 360px) {
    .chat-message-content {
        max-width: 90%;
    }

    .chat-widget-window {
        width: calc(100vw - 24px);
    }
}
