/* Chat Styles - تحسين تصميم الدردشة */

/* Variables for chat */
.chat-section {
    --chat-bg: linear-gradient(160deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    --chat-bubble-ai: linear-gradient(145deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.08));
    --chat-bubble-user: linear-gradient(145deg, rgba(99, 102, 241, 0.35), rgba(139, 92, 246, 0.25));
    --chat-border-glow: rgba(99, 102, 241, 0.25);
}

.chat-section {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
    background: var(--chat-bg);
    position: relative;
    overflow: hidden;
}

.chat-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--chat-border-glow), transparent);
    opacity: 0.6;
}

.chat-container {
    max-width: 920px;
    margin: 0 auto;
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    min-height: 600px;
    position: relative;
}

/* Chat Modal (floating) - enhanced */
.chat-modal .chat-modal-content {
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 820px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(24px);
    border-radius: 24px;
    border: 1px solid rgba(148, 163, 184, 0.15);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
}

.chat-modal .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: transparent;
}

.chat-modal .chat-input-container {
    padding: 1.25rem 2rem;
    background: rgba(15, 23, 42, 0.6);
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

/* Header */
.chat-header {
    padding: 1.25rem 2rem;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(139, 92, 246, 0.08));
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-avatar {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.35);
}

.chat-header-info h2 {
    font-size: 1.35rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    background: linear-gradient(135deg, #a5b4fc, #c4b5fd);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chat-header-info p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0;
    opacity: 0.9;
}

/* Messages area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: transparent;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(30, 41, 59, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #6366f1, #8b5cf6);
    border-radius: 3px;
}

/* Message bubbles */
.message {
    display: flex;
    gap: 0.875rem;
    animation: messageIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 88%;
}

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

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

.message.ai-message {
    align-self: flex-start;
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.message-content {
    background: var(--chat-bubble-ai);
    backdrop-filter: blur(8px);
    padding: 1rem 1.35rem;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.08);
    position: relative;
    line-height: 1.65;
}

.user-message .message-content {
    background: var(--chat-bubble-user);
    border-color: rgba(99, 102, 241, 0.25);
}

.message-content p {
    margin: 0.4rem 0;
    color: var(--text-primary);
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul {
    margin: 0.5rem 0;
    padding-right: 1.25rem;
    color: var(--text-secondary);
}

.message-content li {
    margin: 0.3rem 0;
}

.message-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    text-align: left;
    opacity: 0.8;
}

.user-message .message-time {
    text-align: right;
}

/* Input area */
.chat-input-container {
    padding: 1.25rem 2rem;
    background: rgba(15, 23, 42, 0.5);
    border-top: 1px solid rgba(148, 163, 184, 0.1);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid rgba(148, 163, 184, 0.15);
    border-radius: 16px;
    padding: 0.6rem 1rem;
    transition: all 0.25s ease;
}

.chat-input-wrapper:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    line-height: 1.5;
}

.chat-input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.chat-send-btn {
    width: 46px;
    height: 46px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    border-radius: 14px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.chat-send-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.5);
}

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

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

/* Suggestions */
.chat-suggestions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.suggestion-btn {
    padding: 0.5rem 1rem;
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: 24px;
    color: #a5b4fc;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
}

.suggestion-btn:hover {
    background: rgba(99, 102, 241, 0.18);
    border-color: rgba(99, 102, 241, 0.5);
    transform: translateY(-1px);
    color: #c4b5fd;
}

/* Options widget (checkboxes for project options) */
.chat-options-widget {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    padding: 1rem 1.25rem;
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.35);
    border-radius: 14px;
    align-self: flex-start;
    max-width: 88%;
    min-width: 280px;
    animation: messageIn 0.3s ease-out;
}

.chat-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chat-option-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.4rem 0;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: color 0.2s;
}

.chat-option-item:hover {
    color: #a5b4fc;
}

.chat-option-item input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.chat-option-item span {
    user-select: none;
}

.chat-options-actions {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(148, 163, 184, 0.15);
}

.chat-options-confirm {
    width: 100%;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 0.4rem;
    padding: 1rem 1.35rem;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

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

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

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Request summary card */
.request-summary {
    background: linear-gradient(145deg, rgba(16, 185, 129, 0.12), rgba(16, 185, 129, 0.05));
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 14px;
    padding: 1.1rem 1.35rem;
    margin-top: 0.75rem;
}

.request-summary h4 {
    color: #34d399;
    margin-bottom: 0.6rem;
    font-size: 1rem;
    font-weight: 600;
}

.request-summary p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0.3rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 200px);
        border-radius: 0;
        margin: 0 -1rem;
        max-width: none;
    }

    .chat-header {
        padding: 1rem;
    }

    .chat-messages {
        padding: 1rem;
    }

    .message {
        max-width: 95%;
    }

    .message-content {
        padding: 0.9rem 1.1rem;
    }

    .chat-input-container {
        padding: 1rem;
    }

    .chat-suggestions {
        margin-top: 0.75rem;
    }

    .suggestion-btn {
        font-size: 0.75rem;
        padding: 0.4rem 0.85rem;
    }
}
