:root {
    --ai-accent: #2563eb; /* restrained blue */
    --ai-accent-2: #0ea5e9;
    --ai-bg: #ffffff;
    --ai-panel: #ffffff;
    --ai-muted: #f6f7f9;
    --ai-text: #0b1220;
    --ai-text-2: #475569;
    --ai-text-3: #94a3b8;
    --ai-border: rgba(15, 23, 42, 0.12);
    --ai-border-2: rgba(15, 23, 42, 0.06);
    --ai-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
    --ai-shadow-2: 0 8px 24px rgba(15, 23, 42, 0.12);
    --ai-shadow-3: 0 18px 60px rgba(15, 23, 42, 0.16);
    --ai-radius: 16px;
    --ai-radius-sm: 12px;
    --ai-radius-xs: 10px;
}

/* زر العائم - Orb & Creature Style */
.chat-toggle-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    
    /* Beautiful Gradient Orb */
    background: linear-gradient(135deg, #0ea5e9, #2dd4bf);
    color: white;
    border: none;
    
    /* Deep Glow */
    box-shadow: 
        0 4px 12px rgba(14, 165, 233, 0.3),
        0 8px 24px rgba(45, 212, 191, 0.25),
        inset 0 2px 4px rgba(255, 255, 255, 0.3),
        inset 0 -2px 4px rgba(0, 0, 0, 0.1);

    cursor: pointer;
    z-index: 9999;
    pointer-events: auto;
    
    display: flex;
    align-items: center;
    justify-content: center;
    
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    animation: orb-idle 3s ease-in-out infinite;
}

.chat-toggle-btn:hover {
    transform: scale(1.1) translateY(-2px);
    box-shadow: 
        0 6px 16px rgba(14, 165, 233, 0.4),
        0 12px 32px rgba(45, 212, 191, 0.3);
}

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

.chat-toggle-btn .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: white;
    transition: opacity 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.chat-toggle-btn .text {
    display: none;
}

/* --- Creature Transformation --- */
.chat-toggle-btn.creature {
    border-radius: 40% 40% 45% 45%; 
    animation: creature-bounce 4s infinite;
}

.chat-toggle-btn.creature .icon {
    opacity: 0;
    width: 0;
}

.chat-toggle-btn.creature::before,
.chat-toggle-btn.creature::after {
    content: '';
    position: absolute;
    top: 35%;
    width: 8px;
    height: 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    animation: creature-blink 4s infinite;
}

.chat-toggle-btn.creature::before {
    left: 30%;
}

.chat-toggle-btn.creature::after {
    right: 30%;
}

/* Animations */
@keyframes orb-idle {
    0%, 100% {
        transform: translateY(0);
        box-shadow: 
            0 4px 12px rgba(14, 165, 233, 0.3),
            0 8px 24px rgba(45, 212, 191, 0.25);
    }
    50% {
        transform: translateY(-5px);
        box-shadow: 
            0 8px 20px rgba(14, 165, 233, 0.4),
            0 12px 30px rgba(45, 212, 191, 0.3);
    }
}

@keyframes creature-bounce {
    0%, 100% { 
        transform: translateY(0) scale(1); 
    }
    5% {
        transform: translateY(0) scale(1.1, 0.9);
    }
    10% {
        transform: translateY(-8px) scale(0.9, 1.1);
    }
    15% {
        transform: translateY(0) scale(1);
    }
    40% { transform: rotate(-5deg); }
    45% { transform: rotate(5deg); }
    50% { transform: rotate(0); }
}

@keyframes creature-blink {
    0%, 48%, 52%, 100% {
        height: 12px;
        top: 35%;
    }
    50% {
        height: 1px;
        top: 40%;
    }
}

/* حاوية التطبيق - Enterprise Minimal */
.app-container {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 390px;
    height: 640px;
    max-height: calc(100vh - 130px);
    background: var(--ai-panel);
    display: flex;
    flex-direction: column;
    border-radius: var(--ai-radius);
    border: 1px solid var(--ai-border);
    box-shadow: var(--ai-shadow-3);
    
    clip-path: circle(30px at calc(100% - 30px) calc(100% + 46px));
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    
    transition: 
        clip-path 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease,
        visibility 0ms linear 0.5s;
    
    z-index: 9998;
    pointer-events: auto;
    overflow: hidden;
    font-family: 'Tajawal', sans-serif;
}

.app-container.active {
    clip-path: circle(150% at calc(100% - 30px) calc(100% + 46px));
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
    transition: 
        clip-path 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
        transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
        opacity 0.4s ease,
        visibility 0ms;
}

@media (max-width: 480px) {
    .app-container {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .chat-toggle-btn {
        bottom: 20px;
        right: 20px;
    }
}

/* Header - Modern Light */
.app-header {
    padding: 20px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(246, 247, 249, 0.9));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    position: relative;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-text h1 {
    font-size: 16px;
    font-weight: 700;
    color: var(--ai-text);
    letter-spacing: -0.2px;
    background: linear-gradient(135deg, #0ea5e9, #2dd4bf);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text p {
    font-size: 12px;
    color: var(--ai-text-3);
    font-weight: 500;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-text p::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.logo-container {
    background: linear-gradient(135deg, #0ea5e9, #2dd4bf);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.icon-btn {
    color: var(--ai-text-2);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--ai-border-2);
    border-radius: 12px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: white;
    color: var(--ai-accent-2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scroll-behavior: smooth;
    background: #f8fafc;
    background-image: radial-gradient(rgba(14, 165, 233, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

.welcome-state {
    text-align: center;
    margin-top: 40px;
    color: var(--ai-text-2);
    padding: 0 20px;
    animation: fadeUp 0.6s ease-out 0.2s both;
}

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

.welcome-icon {
    font-size: 0;
    margin-bottom: 20px;
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(45, 212, 191, 0.1));
    width: 90px;
    height: 90px;
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    border: 1px solid rgba(14, 165, 233, 0.2);
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.1);
    color: var(--ai-accent-2);
    transform: rotate(-5deg);
    transition: transform 0.3s ease;
}

.welcome-icon:hover {
    transform: rotate(0deg) scale(1.05);
}

.welcome-icon svg {
    width: 40px;
    height: 40px;
    color: var(--ai-accent-2);
}

.welcome-state h3 {
    font-size: 20px;
    color: var(--ai-text);
    font-weight: 700;
    margin-bottom: 10px;
}

.welcome-state p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ai-text-2);
}

.suggestions {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 30px;
}

.suggestions span {
    background: white;
    padding: 12px 20px;
    border-radius: 999px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--ai-border-2);
    color: var(--ai-text-2);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.suggestions span:hover {
    border-color: var(--ai-accent-2);
    color: var(--ai-accent-2);
    background: rgba(14, 165, 233, 0.05);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.1);
}

/* Messages */
.message {
    display: flex;
    gap: 14px;
    max-width: 88%;
    animation: messageIn 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes messageIn {
    from { 
        opacity: 0; 
        transform: translateY(20px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #0ea5e9, #2dd4bf);
    color: white;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
    border: none;
}

.message.user .avatar {
    background: var(--ai-text);
    color: white;
    box-shadow: 0 4px 12px rgba(11, 18, 32, 0.15);
}

.bubble {
    padding: 16px 20px;
    border-radius: 20px;
    font-size: 14.5px;
    line-height: 1.7;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.message.bot .bubble {
    background: white;
    color: var(--ai-text);
    border-radius: 6px 20px 20px 20px;
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--ai-text), #1e293b);
    color: white;
    border-radius: 20px 6px 20px 20px;
}

.message.error .bubble {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Input Area - Premium Bottom */
.input-area {
    padding: 20px 24px 24px;
    background: linear-gradient(to top, rgba(255,255,255,1) 80%, rgba(255,255,255,0.9));
    border-top: 1px solid rgba(15, 23, 42, 0.05);
    position: relative;
    z-index: 10;
}

.input-container {
    display: flex;
    gap: 12px;
    background: white;
    padding: 8px 8px 8px 20px;
    border-radius: 24px;
    align-items: flex-end;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.input-container:focus-within {
    border-color: var(--ai-accent-2);
    box-shadow: 0 8px 24px rgba(14, 165, 233, 0.12), 0 0 0 4px rgba(14, 165, 233, 0.1);
    transform: translateY(-2px);
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 15px;
    max-height: 120px;
    padding: 12px 0;
    color: var(--ai-text);
    line-height: 1.6;
}

textarea::placeholder {
    color: var(--ai-text-3);
    font-weight: 500;
}

.send-btn {
    background: linear-gradient(135deg, #0ea5e9, #2dd4bf);
    color: white;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

.send-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.3);
}

.send-btn:active {
    transform: translateY(0) scale(0.95);
}

.send-btn:disabled {
    background: var(--ai-muted);
    color: var(--ai-text-3);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.copyright {
    text-align: center;
    font-size: 11px;
    color: var(--ai-text-3);
    margin-top: 14px;
}

.copyright a {
    color: var(--ai-text);
    text-decoration: none;
    font-weight: 500;
}

.copyright a:hover {
    text-decoration: underline;
}



/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    z-index: 100;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: white;
    width: 90%;
    max-width: 400px;
    border-radius: 16px;
    padding: 24px;
    transform: translateY(20px);
    transition: 0.3s;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--ai-text-light);
}

.modal-body input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--ai-border);
    border-radius: 8px;
    margin-top: 8px;
    font-family: inherit;
}

.hint {
    font-size: 12px;
    color: var(--ai-text-light);
    margin-top: 8px;
}

.primary-btn {
    width: 100%;
    padding: 12px;
    background: var(--ai-accent);
    color: white;
    border: none;
    border-radius: 8px;
    margin-top: 20px;
    cursor: pointer;
    font-weight: 500;
}

/* Loading Animation */
.loading-bubble {
    display: flex;
    gap: 4px;
    padding: 16px !important;
}

.dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    animation: slideUp 0.3s ease;
    z-index: 200;
}

@keyframes slideUp {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Custom Scrollbar - شريط التمرير */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

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

.chat-area::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2);
}

/* Action Button */
.action-btn {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: var(--ai-accent);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.action-btn:hover {
    background: var(--ai-accent-2);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
}

.action-btn:active {
    transform: translateY(0);
}
