/* JohnAI Chatbot Styles */
/* Pulse animation */
@keyframes pulseAnimation {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 6px 20px rgba(0, 123, 255, 0.5);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    }
}

/* Apply pulse animation class */
#chatbotToggle.pulse-twice {
    animation: pulseAnimation 0.6s ease-in-out 2;
}

/* Ensure smooth transition after animation */
#chatbotToggle {
    animation-fill-mode: forwards;
}

#chatbotToggle {
    position: fixed;
    bottom: 120px;
    right: 20px;
    width: 60px;
    height: 60px;
	padding: 6px;
    background: #3498db;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
}

.popup-container {
    position: fixed;
    width: 400px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    display: none;
    overflow: hidden;
    border: 1px solid #ddd;
    font-family: "Arial", sans-serif;
	font-weight: 500;
}

.popup-header {
    background: linear-gradient(135deg, #3a3a3a, #2c2c2c);
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.popup-header:active {
    cursor: grabbing;
}

.popup-title {
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
}

.popup-controls {
    display: flex;
    gap: 8px;
}

.close-btn:hover {
    background: #ff4757 !important;
    color: white !important;
}

.popup-content {
    height: calc(100% - 57px);
    display: flex;
    flex-direction: column;
    background: #2c2c2c;
    border-radius: 0 0 12px 12px;
}

.chatbot-interface {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #2c2c2c;
    border-radius: 0 0 12px 12px;
    border-top: 1px solid #444;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #1a1a1a;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.message {
    margin-bottom: 15px;
    display: flex;
    animation: fadeInUp 0.3s ease;
}

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

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

.user-message .message-text {
    background: linear-gradient(135deg, #0084ff, #0066cc);
    color: white;
    border: 1px solid #0066cc;
}

.message-text {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.4;
    word-wrap: break-word;
}

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

.bot-message .message-text {
    background: linear-gradient(135deg, #444444, #3a3a3a);
    color: #e0e0e0;
    border: 1px solid #555;
}

.chat-input-container {
    padding: 15px 20px;
    border-top: 1px solid #444;
    background: #2c2c2c;
    display: flex;
	align-items: center;
    gap: 8px;
}

/* Action buttons */
.input-action-btn {
	background: rgba(255, 255, 255, 0.05);
	border: 1px solid rgba(255, 255, 255, 0.15);
	color: #888;
	width: 36px;
	height: 36px;
    min-width: 36px;
    min-height: 36px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.input-action-btn:hover {
	background: rgba(255, 255, 255, 0.1);
	transform: scale(1.05);
}

/* Specific hover colors */
.clear-chat-btn:hover {
	background: rgba(255, 152, 0, 0.2) !important;
	border-color: rgba(255, 152, 0, 0.4) !important;
	color: #FF9800 !important;
}

.download-btn:hover {
	background: rgba(76, 175, 80, 0.2) !important;
	border-color: rgba(76, 175, 80, 0.4) !important;
	color: #4CAF50 !important;
}

/* Input field */
.chat-input {
	flex: 1;
	padding: 10px 16px;
	border: 1px solid #555;
	border-radius: 25px;
	background: #1a1a1a;
	color: #e0e0e0;
	font-size: 14px;
	outline: none;
	transition: all 0.2s ease;
}

.chat-input::placeholder {
	color: #888;
}

.chat-input:focus {
	border-color: #0084ff;
	box-shadow: 0 0 0 2px rgba(0, 132, 255, 0.1);
	background: #222;
}

.resize-handle::before {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
	margin: 0 5px 5px 0;
	padding: 10px;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg viewBox='0 0 527 527' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23888' stroke='%23888' stroke-miterlimit='10' stroke-width='15'%3E%3Cpath d='m519.5 519.5v-512h-32v480h-480v32z'/%3E%3Cpath d='m7.5 421.5h414v-414h-34.5v379.5h-379.5z'/%3E%3C/g%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: bottom right;
    cursor: grab;
	opacity: 0.2;
	transition: all 0.2s ease;
}

.resize-handle:hover::before {
	opacity: 1;
}

#chatbotPopup {
    position: fixed;
    width: 400px;
	min-width: 375px;
    height: 500px;
	min-height: 375px;
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10000;
    display: none;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.2s ease;
    touch-action: none;
    right: 20px;
    bottom: 80px;
    color: #e0e0e0;
    font-family: "Arial", sans-serif;
	font-weight: 500;
	letter-spacing: .5px;
}

#chatbotPopup.collapsed {
	min-height: inherit;
}


#popupHeader {
    cursor: grab;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

#chatbotPopup.dragging {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

#popupHeader:active {
    cursor: grabbing !important;
}

#resizeHandle:active {
    background-color: rgba(100, 100, 100, 0.3);
    border-color: #666;
}

#chatbotPopup.dragging iframe,
#chatbotPopup.resizing iframe {
    pointer-events: none;
}

#resizeHandle {
    width: 20px;
    height: 20px;
    touch-action: none;
}

.collapse-btn, .close-btn {
	font-family: Roboto;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
	padding: 10px;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s ease;
}

.collapse-btn:hover, .close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    #chatbotPopup {
        right: auto !important;
        bottom: auto !important;
        left: 50% !important;
        top: 100px !important;
        transform: translateX(-50%) !important;
        width: calc(100vw - 20px) !important;
        max-width: 370px !important;
        min-width: 280px;
    }
    
    /* When collapsed on mobile, move to top */
    #chatbotPopup.collapsed {
        top: 70px !important;
    }
    
    .resize-handle {
        width: 24px;
        height: 24px;
    }
    
    .popup-header {
        padding: 12px 16px;
    }
    
    .popup-title {
        font-size: 14px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-input-container {
        padding: 15px;
    }
    
    .message-text {
        font-size: 13px;
        max-width: 85%;
    }
}

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

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #666;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

.typing-dots .dot:nth-child(3) {
    animation-delay: 0s;
}

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

/* Chat message links */
.chat-link {
    color: #3498db;
    text-decoration-color: inherit !important;
    transition: all 0.2s ease;
    font-weight: 500;
}

.chat-link:hover {
    color: #2980b9;
    border-bottom-color: #2980b9;
}

/* Different link colors for bot vs user messages */
.bot-message .chat-link {
    color: #5dade2;
}

.bot-message .chat-link:hover {
    color: #3498db;
    border-bottom-color: #3498db;
}

.user-message .chat-link {
    color: #85c1ff;
}

.user-message .chat-link:hover {
    color: #b3d9ff;
    border-bottom-color: #b3d9ff;
}
        
/* Send button as icon */
.send-btn {
	background: linear-gradient(135deg, #0084ff, #0066cc);
	border: none;
	color: white;
	width: 36px;
	height: 36px;
    min-width: 36px;
    min-height: 36px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.send-btn:hover {
	background: linear-gradient(135deg, #0066cc, #0052a3);
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

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

/* Icons */
.icon {
	width: 24px;
	height: 24px;
	stroke: currentColor;
	stroke-width: 2;
	fill: none;
}

.send-icon {
	width: 20px;
	height: 20px;
	stroke: white;
	stroke-width: 2;
	fill: none;
    min-width: 20px;
    min-height: 20px;
    flex-shrink: 0;
}

/* Tooltips */
.input-action-btn, .send-btn {
	position: relative;
}

.input-action-btn::before,
.send-btn::before {
	content: attr(title);
	position: absolute;
	bottom: 45px;
	left: 50%;
	transform: translateX(-50%) scale(0);
	background: rgba(0, 0, 0, 0.9);
	color: white;
	padding: 5px 10px;
	border-radius: 4px;
	font-size: 12px;
	white-space: nowrap;
	opacity: 0;
	transition: all 0.2s ease;
	pointer-events: none;
	z-index: 10;
}

.input-action-btn:hover::before,
.send-btn:hover::before {
	transform: translateX(-50%) scale(1);
	opacity: 1;
}

.input-action-btn svg,
.send-btn svg {
    width: 100%;
    height: 100%;
    max-width: 24px;
    max-height: 24px;
    display: block;
}

/* Force minimum size for download button specifically */
.download-btn {
    position: relative;
    overflow: visible;
}

.download-btn svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px !important;
    height: 24px !important;
    min-width: 24px !important;
    min-height: 24px !important;
}

/* Ensure all button SVGs maintain size on Safari */
.input-action-btn svg {
    flex-shrink: 0;
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
}

/* Safari-specific fix using -webkit prefix */
@supports (-webkit-appearance: none) {
    .input-action-btn svg {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
    }
    
    .input-action-btn {
        position: relative;
    }
}

/* Custom Dialog Styles */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    display: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dialog-overlay.show {
    display: block;
    opacity: 1;
}

.dialog-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: #2c2c2c;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    z-index: 10002;
    display: none;
    opacity: 0;
    transition: all 0.2s ease;
    min-width: 300px;
    max-width: 360px;
}

.dialog-modal.show {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.dialog-content {
    padding: 24px;
}

.dialog-title {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.dialog-message {
    margin: 0 0 24px 0;
    font-size: 14px;
    line-height: 1.5;
    color: #e0e0e0;
}

.dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.dialog-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.dialog-btn-primary {
    background: linear-gradient(135deg, #0084ff, #0066cc);
    color: white;
}

.dialog-btn-primary:hover {
    background: linear-gradient(135deg, #0066cc, #0052a3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 132, 255, 0.3);
}

.dialog-btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dialog-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* Mobile responsiveness for dialogs */
@media (max-width: 480px) {
    /*.dialog-modal {
        width: calc(100vw - 40px);
        max-width: none;
    }*/
    
    .dialog-buttons {
        flex-direction: column;
    }
    
    .dialog-btn {
        width: 100%;
    }
}

/* Download dialog specific - wider for three buttons */
#downloadDialog .dialog-buttons {
    justify-content: center;
}

#downloadDialog {
    max-width: 360px;
}

/* Microphone button styles */
.mic-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%) !important;
	transform-origin: center center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #888;
    width: 34px;
    height: 34px;
    min-width: 34px;
    min-height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

/* When mic button is hidden, adjust input field width */
#micBtn[style*="display: none"] + #chatInput {
	width: calc(100% - 45px);
}

.mic-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.05);
}

.mic-btn.recording {
    background: rgba(239, 68, 68, 0.2) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #EF4444 !important;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.mic-btn svg {
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Adjust input container for mic button */
.chat-input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

/* Adjust chat input padding to make room for mic */
.chat-input.has-mic {
    padding-right: 48px;
}

/* Add a subtle background change when recording */
.chat-input-wrapper:has(.mic-btn.recording) .chat-input {
    border-color: rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.05);
}

/* Tooltip for mic button */
.mic-btn::before {
    content: attr(title);
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    transition: all 0.2s ease;
    pointer-events: none;
    z-index: 10;
}

.mic-btn:hover::before {
    transform: translateX(-50%) scale(1);
    opacity: 1;
}

/* Mobile adjustments for mic button */
@media (max-width: 768px) {
    .mic-btn {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
        right: 6px;
    }
    
    .mic-btn svg {
        width: 16px;
        height: 16px;
        min-width: 16px;
        min-height: 16px;
    }
    
    .chat-input.has-mic {
        padding-right: 42px;
    }
}

/* Professional document-style formatting for chat messages */

/* Strong emphasis - darker for better contrast */
.message-text strong,
.message-text b {
    font-weight: 600;
    color: #000000;
}

/* Italics - slightly darker than regular text */
.message-text em,
.message-text i {
    font-style: italic;
    color: #2d2d2d;
}

/* Headings - clear hierarchy with good contrast */
.message-text h1 {
    font-size: 1.5em;
    color: #000000;
    font-weight: 700;
}

.message-text h2 {
    font-size: 1.3em;
    color: #1a1a1a;
    font-weight: 600;
}

.message-text h3 {
    font-size: 1.1em;
    color: #2d2d2d;
    font-weight: 600;
}

/* Links - keep them visible but distinct */
.message-text a {
    color: #0066cc;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.message-text a:hover {
    color: #0052a3;
    border-bottom-color: #0066cc;
}

/* Links in user messages need to be visible against blue background */
.user-message .message-text a {
    color: #a6d8ff;
    font-weight: 500;
}

.user-message .message-text a:hover {
    color: #ffffff;
    border-bottom-color: #ffffff;
}

/* Code blocks with better contrast */
.message-text code {
    background: #e8e8e8;
    color: #d73a49;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875em;
    font-weight: 500;
}

/* Code in user messages */
.user-message .message-text code {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Lists - ensure good readability */
.message-text li {
    color: inherit; /* Use parent color */
}

/* Additional improvements for readability */
@media (max-width: 768px) {
    .message-text {
        font-size: 14px;
    }
    
    /* Slightly larger on mobile for better readability */
    .user-message .message-text,
    .bot-message .message-text {
        font-size: 14px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bot-message .message-text {
        color: #000000;
        background-color: #ffffff;
    }
    
    .user-message .message-text {
        color: #ffffff;
        background-color: #0052a3;
    }
}

/* Dark mode support (if you implement it) */
@media (prefers-color-scheme: dark) {
    
    .message-text strong,
    .message-text b {
        color: #ffffff;
    }
    
    .message-text em,
    .message-text i {
        color: #f0f0f0;
    }
    
    .message-text h1,
    .message-text h2,
    .message-text h3 {
        color: #ffffff;
    }
    
    .message-text code {
        background: #3d3d3d;
        color: #ff6b6b;
    }
    
    .message-text a {
        color: #66b3ff;
    }
}
.message-text ol,
.message-text ul {
  padding-left: 1rem;
}

/* File upload button styling */
.file-upload-btn {
    cursor: pointer;
}

.file-upload-btn:hover {
    background: rgba(52, 152, 219, 0.2) !important;
    border-color: rgba(52, 152, 219, 0.4) !important;
    color: #3498db !important;
}

/* Drag and drop styling */
.chat-messages.drag-over {
    background: rgba(52, 152, 219, 0.1);
    border: 2px dashed #3498db;
}

.chat-messages.drag-over::after {
    content: 'Drop job description here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.2em;
    color: #3498db;
    pointer-events: none;
}