/* Chat Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Noto Sans Arabic', 'Arial Unicode MS', sans-serif;
}

/* Chat Toggle Button */
.chat-toggle {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 50%, #2563eb 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(30, 64, 175, 0.25), 0 4px 12px rgba(30, 64, 175, 0.15);
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    color: white;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.chat-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.1) 100%);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.chat-toggle:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 15px 40px rgba(30, 64, 175, 0.35), 0 8px 20px rgba(30, 64, 175, 0.2);
}

.chat-toggle:hover::before {
    opacity: 1;
}

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

/* Chat Container */
.chat-container {
    position: absolute;
    bottom: 84px;
    right: 0;
    width: 400px;
    height: 620px;
    background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    border-radius: 24px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.12), 0 16px 32px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.92) rotateX(10deg);
    }

    50% {
        opacity: 0.8;
        transform: translateY(8px) scale(0.98) rotateX(2deg);
    }

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #1e40af 0%, #1d4ed8 50%, #2563eb 100%);
    color: white;
    padding: 24px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(30, 64, 175, 0.15), 0 4px 12px rgba(30, 64, 175, 0.1);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 100%);
    pointer-events: none;
}

.chat-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    margin: 0;
    position: relative;
    z-index: 1;
    flex: 1;
    letter-spacing: -0.025em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.minimize-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    background: linear-gradient(145deg, #fafbfc 0%, #f1f5f9 100%);
    display: flex;
    flex-direction: column;
    gap: 18px;
    scroll-behavior: smooth;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #1e40af, #2563eb);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #1d4ed8, #3b82f6);
}

/* Message Styles */
.message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.03);
    line-height: 1.6;
    font-size: 14.5px;
    word-wrap: break-word;
    animation: fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    font-weight: 450;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }

    60% {
        opacity: 0.8;
        transform: translateY(-2px) scale(1.01);
    }

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

.message.bot {
    align-self: flex-start;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    color: #1e293b;
    border-bottom-left-radius: 8px;
    border-left: 4px solid #1e40af;
    margin-right: 24px;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.08), 0 2px 6px rgba(30, 64, 175, 0.04);
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    color: white;
    border-bottom-right-radius: 8px;
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.25), 0 3px 8px rgba(30, 64, 175, 0.15);
    margin-left: 24px;
}

.message strong {
    font-weight: 700;
    color: inherit;
    letter-spacing: -0.01em;
}

.message em {
    font-style: italic;
    opacity: 0.92;
    font-weight: 500;
}

.message code {
    background: rgba(30, 64, 175, 0.08);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid rgba(30, 64, 175, 0.1);
}

.message-time {
    font-size: 11px;
    opacity: 0.65;
    margin-top: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Loading Animation */
.message.loading {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
    color: #1e293b;
    align-self: flex-start;
    margin-right: 24px;
    border-left: 4px solid #1e40af;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.08), 0 2px 6px rgba(30, 64, 175, 0.04);
}

.message.loading::after {
    content: '';
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid #1e40af;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 12px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Typewriter Cursor */
.cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #1e40af;
    margin-left: 3px;
    animation: blink 1.2s infinite;
    border-radius: 1px;
}

@keyframes blink {

    0%,
    50% {
        opacity: 1;
    }

    51%,
    100% {
        opacity: 0;
    }
}

/* Chat Options */
.chat-options {
    padding: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-top: 1px solid rgba(30, 64, 175, 0.08);
    box-shadow: 0 -6px 24px rgba(30, 64, 175, 0.06);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 220px;
    overflow-y: auto;
    justify-content: center;
}

.chat-options::-webkit-scrollbar {
    width: 4px;
}

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

.chat-options::-webkit-scrollbar-thumb {
    background-color: #19459d;
    border-radius: 2px;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* Navigation Buttons Section */
.chat-navigation {
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.08) 0%, rgba(59, 130, 246, 0.06) 100%);
    border-top: 1px solid rgba(30, 64, 175, 0.12);
    display: none;
    /* Hidden by default */
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 2px rgba(30, 64, 175, 0.08);
}

.chat-navigation.show {
    display: flex !important;
}

.nav-btn {
    height: 38px !important;
    font-size: 13px !important;
    border-radius: 12px !important;
    display: inline-flex;
    align-items: center;
    letter-spacing: -0.01em;
    color: #ffffff;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    text-align: center;
    position: relative;
    overflow: hidden;
    justify-content: center;
    padding: 0 18px;
    margin: 3px;
    min-width: 85px;
    box-shadow: 0 3px 8px rgba(30, 64, 175, 0.12), 0 1px 4px rgba(30, 64, 175, 0.08);
}

.nav-btn:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
    border-color: transparent;
    color: #ffffff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 18px rgba(30, 64, 175, 0.2), 0 3px 9px rgba(30, 64, 175, 0.12);
}

.nav-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(25, 69, 157, 0.15);
}

.nav-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.15), 0 6px 18px rgba(30, 64, 175, 0.2);
    transform: translateY(-2px) scale(1.02);
}

/* Option Buttons */
.option-btn {
    font-size: 15px !important;
    border-radius: 16px !important;
    display: inline-flex;
    align-items: center;
    letter-spacing: -0.02em;
    color: #ffffff;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 100%);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    text-align: center;
    position: relative;
    overflow: hidden;
    justify-content: center;
    padding: 12px 18px;
    margin: 4px;
    min-height: 44px;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.15), 0 2px 6px rgba(30, 64, 175, 0.1);
}

.option-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s ease;
}

.option-btn:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
    border-color: transparent;
    color: #ffffff;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 32px rgba(30, 64, 175, 0.25), 0 6px 16px rgba(30, 64, 175, 0.15);
}

.option-btn:hover::before {
    left: 100%;
}

.option-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(25, 69, 157, 0.15);
}

.option-btn:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(30, 64, 175, 0.15), 0 12px 32px rgba(30, 64, 175, 0.25);
    transform: translateY(-3px) scale(1.02);
}


/* Mobile Responsiveness */
@media (max-width: 768px) {
    .chat-widget {
        bottom: 15px;
        right: 15px;
    }

    .chat-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
        z-index: 9999 !important;
    }

    /* Hide chat toggle when chat is open */
    .chat-widget.chat-open .chat-toggle {
        display: none !important;
    }

    .demo-section h1 {
        font-size: 2rem;
    }

    .demo-section p {
        font-size: 1rem;
    }

    .demo-cards {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .demo-card {
        padding: 30px 20px;
    }

    .page-content {
        padding: 40px 15px;
    }
}

@media (max-width: 480px) {
    .chat-toggle {
        width: 55px;
        height: 55px;
    }

    .chat-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        border-radius: 0 !important;
        z-index: 9999 !important;
    }

    /* Hide chat toggle when chat is open */
    .chat-widget.chat-open .chat-toggle {
        display: none !important;
    }

    .chat-messages {
        padding: 15px;
        gap: 12px;
    }

    .chat-options {
        padding: 12px;
        gap: 4px;
    }

    .chat-navigation {
        padding: 8px 12px;
        gap: 6px;
    }

    .nav-btn {
        height: 32px !important;
        font-size: 12px !important;
        padding: 0 12px;
        min-width: 70px;
    }

    .message {
        padding: 12px 16px;
        font-size: 13px;
        max-width: 90%;
    }

    .option-btn {
        height: 40px !important;
        font-size: 14px !important;
        padding: 0 14px;
    }

    .demo-section h1 {
        font-size: 1.8rem;
    }

    .demo-card h3 {
        font-size: 1.3rem;
    }
}

/* RTL Support */
.message[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

.message[dir="rtl"].bot {
    border-left: none;
    border-right: 4px solid #1e40af;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 8px;
    margin-left: 24px;
    margin-right: 0;
}

.message[dir="rtl"].user {
    border-bottom-right-radius: 20px;
    border-bottom-left-radius: 8px;
    margin-right: 24px;
    margin-left: 0;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Professional Message Content Styling */
.message h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: inherit;
    line-height: 1.4;
}

.message h4 {
    font-size: 14.5px;
    font-weight: 650;
    margin: 16px 0 8px 0;
    color: inherit;
    line-height: 1.4;
}

.message p {
    margin: 8px 0;
    line-height: 1.65;
}

.message ol,
.message ul {
    margin: 12px 0;
    padding-left: 24px;
}

.message li {
    margin: 6px 0;
    line-height: 1.6;
}

.message .guide-container {
    display: block;
}

.message .section {
    margin: 16px 0;
    padding: 12px;
    background: rgba(30, 64, 175, 0.04);
    border-radius: 12px;
    border-left: 3px solid #1e40af;
}

.message .alert-section {
    margin: 16px 0;
    padding: 12px;
    background: rgba(239, 68, 68, 0.06);
    border-radius: 12px;
    border-left: 3px solid #ef4444;
}

.message .info-box {
    padding: 12px;
    background: rgba(59, 130, 246, 0.08);
    border-radius: 12px;
    border: 1px solid rgba(59, 130, 246, 0.15);
}

.message .question-container h3 {
    margin-bottom: 8px;
}

.message .welcome-container {
    text-align: center;
}

.message .delivery-container .info-box {
    margin-top: 12px;
}

/* RTL Support for new elements */
.message[dir="rtl"] ol,
.message[dir="rtl"] ul {
    padding-right: 24px;
    padding-left: 0;
}

.message[dir="rtl"] .section {
    border-left: none;
    border-right: 3px solid #1e40af;
}

.message[dir="rtl"] .alert-section {
    border-left: none;
    border-right: 3px solid #ef4444;
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .chat-container {
        border: 2px solid #000;
    }

    .option-btn {
        border-width: 2px;
    }

    .message {
        border-width: 2px;
    }

    .message .section {
        border-left-width: 4px;
    }

    .message .alert-section {
        border-left-width: 4px;
    }
}