/* Define variables for reusability */
:root {
    --chat-bg: #f1f1f1;
    --chat-card-bg: #ffffff;
    --chat-text: #333333;
    --chat-accent: #2233EE;
    --chat-user-bubble: #e1f5fe;
    --chat-suggestion-bg: #f1f1f1;
    --chat-input-border: #cccccc;
    --chat-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Dark mode variables */
@media (prefers-color-scheme: dark) {
    :root {
        --chat-bg: var(--bg-dark, #1f2937);
        --chat-card-bg: var(--card-dark, #374151);
        --chat-text: var(--text-dark, #e5e7eb);
        --chat-accent: #3b82f6; /* Lighter blue for dark mode */
        --chat-user-bubble: #4b5e8e; /* Darker, muted blue for user bubble */
        --chat-suggestion-bg: #4b5563;
        --chat-input-border: #6b7280;
        --chat-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    }
}

#chatbot-container body {
    font-family: Arial, sans-serif;
    direction: right;
    margin: 0;
    padding: 0;
    background-color: var(--chat-bg);
    overflow-x: hidden;
}

#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 0;
    z-index: 10000;
    font-family: 'Poppins', 'Noto Sans Hebrew', sans-serif;
    direction: rtl;
}

#chatbot-container #chat-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--chat-accent);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--chat-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    padding: 0;
    z-index: 10005;
}

#chatbot-container #loading-gif {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

#chatbot-container #chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 90vw; 
    max-width: 400px;
    max-height: 600px;
    margin-right: 10px;
    margin-left: 10px;
    border: 1px solid var(--chat-input-border);
    border-radius: 15px;
    box-shadow: var(--chat-shadow);
    background-color: var(--chat-card-bg) !important;
    display: none;
    flex-direction: column;
    direction: rtl;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateY(100%);
    opacity: 0;
    z-index: 10010;
}


#chatbot-container #chat-window.open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

#chatbot-container #chat-window.minimized {
    max-height: 60px;
}

#chatbot-container #chat-header {
    background-color: var(--chat-accent);
    color: var(--text-dark);
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    height: 100px;
    flex-shrink: 0;
}

#chatbot-container #header-animation {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

#chatbot-container #minimize-button {
    background: none;
    border: none;
    color: var(--text-dark);
    font-size: 18px;
    cursor: pointer;
    position: absolute;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    opacity: 0;
    transition: top 5s ease, opacity 5s ease;
}

#chatbot-container #chat-window.minimized #minimize-button {
    top: 0px;
    opacity: 1;
}

#chatbot-container #minimize-button i {
    font-size: 14px;
    transition: transform 0.3s ease;
}

#chatbot-container #chat-window.minimized #minimize-button i {
    transform: rotate(180deg);
}

#chatbot-container #chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    direction: rtl;
    padding: 10px;
    overflow-y: auto;
    background-color: var(--chat-card-bg);
}

#chatbot-container #messages {
    flex: 1;
    overflow-y: auto;
    direction: rtl;
    margin-bottom: 10px;
    padding-right: 10px;
    box-sizing: border-box;
}

.message {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 10px;
    position: relative;
    background-color: transparent !important;
}

.message.user {
    align-items: flex-end;
}

.message .message-bubble {
    display: inline-block;
    padding: 16px;
    border-radius: 10px;
    max-width: 80%;
    position: relative;
    font-size: 13px;
    color: var(--chat-text);
}

.message.user .message-bubble {
    background-color: var(--chat-user-bubble);
    border: 3px solid var(--chat-user-bubble);
    text-align: right;
    border-radius: 25px;
}

.message.assistant .message-bubble {
    background-color: transparent !important;
    border: none;
    text-align: left;
}

.message .message-label {
    display: block;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
    color: var(--chat-text);
}

.message .timestamp {
    display: block;
    font-size: 0.65em;
    color: var(--chat-input-border);
    margin-top: 5px;
    text-align: right;
}

.message.user .timestamp {
    text-align: left;
}

#chatbot-container #typing-indicator {
    display: none;
    align-items: center;
    padding: 10px 0;
    justify-content: flex-start;
    font-size: 13px;
    color: var(--chat-text);
}

#chatbot-container #typing-indicator.visible {
    display: flex;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--chat-accent);
    border-radius: 50%;
    animation: blink 1s infinite;
    margin-right: 5px;
}

.dot:nth-child(2) {
    animation-delay: 0.3s;
}

.dot:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes blink {
    0%, 80%, 100% {
        opacity: 0;
    }
    40% {
        opacity: 1;
    }
}

#chatbot-container #suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-bottom: 5px;
    background-color: var(--chat-card-bg);
    padding: 5px;
    box-sizing: border-box;
    opacity: 1;
}

.suggestion {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border: none;
    background-color: var(--chat-suggestion-bg);
    color: var(--chat-text);
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 20px;
    font-size: 12px;
    transition: background-color 0.3s ease, transform 0.3s ease;
    width: calc(50% - 10px);
    box-sizing: border-box;
    transform: translateY(100%);
    opacity: 0;
}

.suggestion.show {
    transform: translateY(0);
    opacity: 1;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.suggestion:hover {
    background-color: var(--chat-input-border);
}

#chatbot-container #input-container {
    display: flex;
    gap: 10px;
    padding: 5px;
    background-color: var(--chat-card-bg);
    box-sizing: border-box;
    overflow: visible;
    align-items: center;
}

#chatbot-container #chat-input {
    border: 1px solid var(--chat-input-border);
    padding: 15px 10px;
    flex: 1;
    direction: rtl;
    border-radius: 20px;
    font-size: 14px;
    background-color: var(--chat-card-bg);
    box-sizing: border-box;
    color: var(--chat-text);
}

@keyframes colorChange {
    0% {
        background-color: var(--chat-accent);
    }
    20% {
        background-color: #1a2bb8;
    }
    40% {
        background-color: #663399;
    }
    60% {
        background-color: #ff69b4;
    }
    80% {
        background-color: #FF4500;
    }
    100% {
        background-color: var(--chat-accent);
    }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 51, 238, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 20px rgba(34, 51, 238, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(34, 51, 238, 0);
    }
}

#chatbot-container #send-button {
    border: none;
    color: var(--text-dark);
    width: 40px;
    height: 40px;
    cursor: pointer;
    border-radius: 50%;
    font-size: 18px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
    background-color: var(--chat-accent);
    z-index: 9999;
}

#chatbot-container #send-button.color-change {
    animation: colorChange 10s infinite;
}

#chatbot-container #send-button i {
    transition: transform 0.3s ease;
}

#chatbot-container #send-button:active i {
    transform: scale(0.9);
}

#chatbot-container #powered-by {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
    background-color: var(--chat-card-bg);
    position: relative;
    overflow: visible;
}

#chatbot-container #powered-by-text {
    display: block;
    color: var(--chat-text);
    font-size: 10px;
    background-color: var(--chat-card-bg);
    padding: 5px 15px;
    border-radius: 20px;
    position: static;
    white-space: nowrap;
    z-index: 1;
    text-align: center;
    box-shadow: var(--chat-shadow);
}

.hidden {
    display: none;
}

.static-text {
    position: absolute;
    top: 0;
    right: 10px;
    white-space: nowrap;
    z-index: 1;
    background-color: transparent;
    padding: 0 5px;
    color: var(--chat-text);
}

.message.assistant .message-text,
.message.user .message-text {
    margin-top: 10px;
    display: block;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    text-align: start; 
    direction: unset; 
    line-height: 1.6;
    font-size: 14px;
}


#chatbot-container #chat-start-time {
    text-align: center;
    font-size: 0.65em;
    color: var(--chat-input-border);
    margin: 10px 0;
}

.cv-upload-label,
#cv-upload-button {
    display: inline-block;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    background-color: var(--chat-user-bubble);
    border-radius: 50%;
    border: 1px solid var(--chat-input-border);
    margin: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    animation: uploadColorChange 10s infinite alternate;
}

@keyframes uploadColorChange {
    0% {
        background-color: var(--chat-user-bubble);
    }
    20% {
        background-color: #b0e0e6;
    }
    40% {
        background-color: #add8e6;
    }
    60% {
        background-color: #87cefa;
    }
    80% {
        background-color: #4682b4;
    }
}

.upload-icon {
    width: 16px;
    height: 16px;
}

#chatbot-container #cv-upload-row {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none;
}

#chatbot-container #cv-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    margin-top: 10px;
    margin-bottom: 10px;
    background-color: var(--chat-suggestion-bg);
    border-radius: 10px;
    border: 1px solid var(--chat-input-border);
    width: 100%;
    box-sizing: border-box;
}

#chatbot-container #cv-file-name {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--chat-text);
    position: relative;
}

#chatbot-container #cv-file-name-text {
    margin-left: 10px;
}

.remove-cv {
    position: absolute;
    left: 0;
    color: #ef4444; /* Red for visibility in both modes */
    cursor: pointer;
    font-weight: bold;
}

#chatbot-container #error-container {
    border: 2px solid #ef4444;
}

body.chatbot-open {
    overflow: hidden;
}
