/* ========== تصميم متجاوب للهواتف ========== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Cairo', 'Segoe UI', system-ui, sans-serif;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    color: #f1f5f9;
    direction: rtl;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: #1e293b;
}
::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 4px;
}

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 600px;
    margin: 0 auto;
    background: rgba(15, 23, 42, 0.3);
}

.app-header {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    padding: 12px 16px;
    border-bottom: 1px solid rgba(59, 130, 246, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.logo-text h1 {
    font-size: 1.2rem;
    margin: 0;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.logo-text p {
    font-size: 0.7rem;
    color: #64748b;
    margin: 0;
}

.language-selector {
    display: flex;
    gap: 5px;
    background: rgba(30, 41, 59, 0.5);
    padding: 3px;
    border-radius: 30px;
}

.lang-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: 25px;
    color: #94a3b8;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s;
}

.lang-btn.active {
    background: #3b82f6;
    color: white;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: #94a3b8;
}

.online-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.stats {
    display: flex;
    gap: 12px;
    font-size: 0.7rem;
    color: #94a3b8;
}

.stats span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 0;
}

.message {
    display: flex;
    gap: 8px;
    animation: slideIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #10b981, #3b82f6);
}

.message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    background: #1e293b;
    border: 1px solid #334155;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
}

.message-text {
    line-height: 1.4;
    font-size: 0.9rem;
    word-wrap: break-word;
}

.message-time {
    font-size: 0.55rem;
    color: #64748b;
    margin-top: 5px;
    text-align: left;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

.input-area {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 12px;
    margin-top: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.input-actions {
    margin-bottom: 8px;
}

.action-btn {
    background: rgba(59, 130, 246, 0.2);
    border: none;
    padding: 8px 12px;
    border-radius: 25px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.input-wrapper textarea {
    flex: 1;
    padding: 12px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 20px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    resize: none;
    outline: none;
    min-height: 44px;
    max-height: 100px;
}

.input-wrapper textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.send-btn {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 25px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.send-btn:disabled {
    opacity: 0.5;
    transform: none;
}

.context-area {
    margin-top: 10px;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 16px;
    border: 1px solid #334155;
    overflow: hidden;
}

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: rgba(15, 23, 42, 0.8);
    border-bottom: 1px solid #334155;
    font-size: 0.7rem;
    color: #94a3b8;
}

.close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
}

.close-btn:active {
    color: #ef4444;
}

.context-area textarea {
    width: 100%;
    padding: 10px 12px;
    background: #0f172a;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 0.8rem;
    resize: vertical;
    outline: none;
}

.input-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 0.6rem;
    color: #64748b;
}

.examples-panel {
    margin: 8px 12px;
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.examples-header {
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 500;
    user-select: none;
}

.examples-header:active {
    background: rgba(59, 130, 246, 0.2);
}

.examples-content {
    padding: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-top: 1px solid rgba(59, 130, 246, 0.2);
}

.example-btn {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 8px 14px;
    border-radius: 25px;
    color: #f1f5f9;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    flex: 0 0 auto;
}

.example-btn:active {
    background: rgba(59, 130, 246, 0.4);
    transform: scale(0.96);
}

.app-footer {
    text-align: center;
    padding: 12px;
    color: #475569;
    font-size: 0.65rem;
    border-top: 1px solid rgba(59, 130, 246, 0.1);
    margin-top: 8px;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 16px;
    right: 16px;
    background: #1e293b;
    border-right: 3px solid #3b82f6;
    padding: 10px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    animation: slideUp 0.3s ease;
    display: none;
    font-size: 0.8rem;
}

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

.loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(139, 92, 246, 0.3);
    border-radius: 50%;
    border-top-color: #8b5cf6;
    animation: spin 0.8s linear infinite;
}

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

@media (max-width: 480px) {
    .message-bubble {
        max-width: 85%;
        padding: 8px 12px;
    }
    .message-text {
        font-size: 0.85rem;
    }
    .examples-content {
        gap: 6px;
    }
    .example-btn {
        padding: 6px 12px;
        font-size: 0.7rem;
    }
}