/* Chat message container for centering */
#chatWindow > div {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

/* Chat message styles */
.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

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

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

/* Message bubble styles */
.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    position: relative;
    display: inline-block;
    width: fit-content;
}

.user-message .message-bubble {
    background-color: #e3f2fd; /* Light blue background for user messages */
    color: #333;
    border-bottom-right-radius: 4px;
    margin-left: auto; /* Ensures right alignment for user messages */
    text-align: left; /* Ensure text within bubble is left-aligned */
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    width: auto;
    min-width: 60px; /* Ensure minimum width to prevent character wrapping */
    max-width: 500px; /* Limit max width for readability */
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal; /* Ensure normal text wrapping */
}

.ai-message .message-bubble,
div.ai-message .message-bubble,
.chat-container .ai-message .message-bubble,
.message.bot .message-content,
.bot .message-content,
#chatWindow .bot .message-bubble {
    background-color: #ffffff !important; /* White background */
    color: #333 !important;
    border-bottom-left-radius: 4px !important;
    margin-right: auto !important; /* Ensures left alignment for AI messages */
    border: none !important; /* Removed border */
    box-shadow: none !important; /* Removed shadow */
    max-width: 500px !important; /* Limit max width for readability */
}

#chatWindow .ai-message .message-bubble,
#chatWindow div.ai-message .message-bubble,
.ai-message .message-content,
.ai-message .message-bubble .message-content,
.bot .message-content {
    background-color: #ffffff !important; /* White background */
    color: #333 !important;
    border-bottom-left-radius: 4px !important;
    text-align: left !important; /* Left-align text in AI messages */
    border: none !important; /* Removed border */
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.user-message .message-header {
    color: rgba(255, 255, 255, 0.9);
}

.ai-message .message-header {
    color: #6c757d;
}

.timestamp {
    font-size: 0.75rem;
    opacity: 0.8;
}

.message-content {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.chat-history-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 20px;
    background-color: #ffffff;
}

/* Ensure the modal content has proper padding */
#chatHistoryContent {
    padding: 15px;
}

/* New styles for inline quote form */
.quote-form-container {
    margin: 20px 0;
    margin-bottom: 80px;
    padding: 0;
    border-radius: 8px;
    background: transparent;
}

.quote-form-container .card {
    border: none;
    border-radius: 8px;
    box-shadow: none;
}

.quote-form-container .card-title {
    color: #0d6efd;
    font-weight: 600;
    margin-bottom: 1rem;
}

.quote-details {
    background-color: #ffffff; /* Changed to white */
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

/* Styling for active chat container */
.chat-container-wrapper.active {
    border: none;
    border-radius: 0;
    padding: 30px 20px;
    margin-bottom: 0 !important;
    background-color: white !important;
    position: relative;
    z-index: 1000; /* Increased z-index */
    width: 100%;
    max-width: 100%; /* Full width */
    margin-left: auto;
    margin-right: auto;
    min-height: calc(100vh - 100px);
}

/* Chat background - full white */
body {
    background-color: #ffffff !important;
}

/* Full-screen background for chat */
.chat-full-background {
    position: relative !important;
    width: 100%;
    min-height: 500px;
    background-color: white;
    z-index: 10;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Ensure navbar stays visible */
nav.bg-white {
    position: relative;
    z-index: 1000;
}

/* Hide headline when chat is active */
.headline {
    position: relative;
    z-index: 5;
}

.chat-container-wrapper {
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    position: relative !important;
    z-index: 10;
}

/* Fix the wrapper height when chat is active */
#chatContainerWrapper.chat-open {
    position: relative !important;
    height: calc(100vh - 100px);
    max-height: calc(100vh - 100px);
    display: flex !important;
    flex-direction: column !important;
    margin: 0 auto !important;
    margin-bottom: 40px !important;
    padding: 20px 0 !important;
    z-index: 20 !important;
    background: white !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Ensure proper spacing between chat and following sections */
#chatContainerWrapper.chat-open + section {
    margin-top: 30px !important;
}

.chat-container-wrapper.active ~ .headline,
.chat-container-wrapper.active + .headline,
.chat-container-wrapper.active .headline,
.headline.hidden {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    z-index: -1 !important;
}

.quote-details p {
    margin-bottom: 0.5rem;
}

.quote-details strong {
    color: #495057;
}

#serviceTypeSelector {
    display: block;
}

#serviceTypeSelector.hidden {
    display: none;
}

.selected-service {
    background-color: #ffffff; /* Changed to white */
    padding: 10px 15px;
    margin: 10px auto;
    font-weight: 500;
    color: #495057;
    display: none;
    text-align: center;
    max-width: 400px;
    border-radius: 8px;
}

.selected-service.visible {
    display: block;
}

#chatWindow {
    display: none;
    background-color: #ffffff !important; /* Changed to white with !important */
    padding: 30px 40px;
    padding-bottom: 120px; /* Increased space for input at bottom */
    flex: 1 1 auto;
    height: 100%;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    overflow-x: hidden;
    transition: all 0.3s ease;
    margin: 0 auto;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    position: relative;
    z-index: 50;
    width: 100%;
    max-width: 1200px;
}

#chatWindow.visible {
    display: block;
}

#chatWindow.expanded {
    margin-top: 20px;
    flex: 1 1 auto;
}

/* When chat is expanded and input is fixed, extend chat window to fill available space */
#chatWindow.expanded.with-fixed-input {
    margin-top: 20px;
    padding: 20px 30px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    background-color: #ffffff !important; /* Changed to white with !important */
    border: none;
    max-width: 1200px; /* Increased width for better layout */
    margin: 0 auto;
    position: relative;
    z-index: 50;
    padding: 20px 30px;
    width: 100%;
}

#serviceTypeSelector {
    background-color: #ffffff; /* Changed to white */
}

/* Make service type options bold */
#serviceType option {
    font-weight: bold !important;
}

.container {
    background-color: #ffffff; /* Changed to white */
}

.chat-container.expanded {
    position: relative;
    z-index: 60;
    width: 100%;
    max-width: 1200px; /* Increased width for better layout */
    margin: 0 auto;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    height: 100%;
    max-height: 100%;
}

.chat-container.expanded.with-fixed-input {
    flex: 1 1 auto;
}

/* Additional bot message styling */
.message.bot,
div.message.bot,
.chat-container .message.bot {
    align-self: flex-start !important;
}

.message.bot .message-content,
div.message.bot .message-content,
.chat-container .message.bot .message-content {
    background-color: #ffffff !important;
    color: #333 !important;
    border-bottom-left-radius: 4px !important;
    text-align: left !important;
    border: none !important;
    box-shadow: none !important;
    max-width: 85% !important;
}

/* Override any existing bot styling */
.bot * {
    background-color: #ffffff !important;
    color: #333 !important;
}

/* Chat input container - positioned at bottom with no gaps */
.chat-input-container {
    position: sticky;
    bottom: 40px;
    margin: 0;
    margin-top: auto;
    padding: 0;
    border-top: none;
    background: transparent;
    box-shadow: none;
    flex-shrink: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 2000 !important;
}

/* Ensure the input wrapper maintains position relative for button positioning */
.chat-input-container > div {
    position: relative !important;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: block !important;
    z-index: 2001 !important;
}

/* Input container styling */
.input-container {
    position: relative;
    width: 100%;
    max-width: 900px; /* Match message container width */
    padding: 0 20px;
    background-color: transparent;
    z-index: 9999; /* Increased to ensure visibility */
    border: none;
    outline: none;
    box-shadow: none;
    margin: 0 auto;
}

/* Fixed input container when chat is active */
.input-container.fixed-bottom {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 900px; /* Match message container width */
    padding: 0;
    background-color: transparent;
    border-top: none;
    z-index: 9999; /* Increased z-index to ensure it's on top */
    box-shadow: none;
    box-sizing: border-box;
}

@media (min-width: 768px) {
    .input-container.fixed-bottom {
        max-width: 900px; /* Match message container width */
        padding: 0 20px;
    }
}

/* Add bottom padding to chat when input is fixed */
#chatWindow.with-fixed-input {
    padding-bottom: 140px !important;
}

/* Adjust chat container when input is fixed */
.chat-container.with-fixed-input {
    padding-bottom: 0;
}

.auto-resize {
    min-height: 38px;
    max-height: 200px;
    resize: none;
    overflow-y: hidden;
}

#chatUserInput, .message-input {
    width: 100%;
    resize: none;
    overflow-y: hidden;
    min-height: 44px;
    padding: 10px 50px 10px 16px;
    font-size: 16px;
    border-radius: 20px;
    border: none;
    background-color: #f8f9fa;
    box-sizing: border-box;
    margin: 0;
    max-width: 100%;
    outline: none;
    position: relative;
    z-index: 2002 !important;
}

/* Mobile-specific input styling */
@media (max-width: 768px) {
    .message-input {
        /* Use 16px font size to prevent zoom on iOS */
        font-size: 16px;
        /* Ensure proper touch target size */
        min-height: 44px;
    }

    /* Prevent viewport jumping when keyboard appears/disappears */
    .chat-container.with-fixed-input {
        position: relative;
        height: calc(100vh - 140px);
    }

    /* Ensure chat window scrolls properly on mobile */
    #chatWindow.with-fixed-input {
        height: calc(100vh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }

    /* Fix iOS Safari keyboard issues */
    .input-container.fixed-bottom {
        position: fixed;
        bottom: 0;
        /* Prevent iOS Safari from moving the input when keyboard appears */
        transform: translateX(-50%) translateZ(0);
        -webkit-transform: translateX(-50%) translateZ(0);
        width: calc(100% - 32px);
        max-width: 1024px;
        padding: 15px 16px;
    }
}

.send-button {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #2196f3;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    z-index: 2003 !important;
}

.send-button:hover {
    transform: translateY(-50%);
    color: #1976d2;
}

.send-button .send-icon {
    font-size: 22px;
}

.send-button:disabled {
    opacity: 0.5;
}

.typing-indicator {
    background-color: transparent;
    padding: 8px 12px;
    border-radius: 12px;
    display: none;
    margin: 5px 0;
    position: relative;
    width: fit-content;
    border: none;
}

/* Align typing indicator with message container */
#chatWindow .typing-indicator {
    width: 100% !important;
    max-width: 900px !important;
    margin: 6px auto !important;
    padding: 0 !important;
    display: flex !important;
    justify-content: flex-start !important;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    position: relative;
}

.typing-indicator.active {
    display: inline-block;
}

.typing-indicator span {
    height: 6px;
    width: 6px;
    float: left;
    margin: 0 2px;
    background-color: #757575;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
    animation: typing 1s infinite;
}

.typing-indicator span:nth-of-type(2) {
    animation: typing 1s infinite 0.2s;
}

.typing-indicator span:nth-of-type(3) {
    animation: typing 1s infinite 0.4s;
}

.typed-text {
    min-height: 1.5em;
    position: relative;
}

@keyframes typing {
    0% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0.4;
        transform: scale(1);
    }
}

.new-bid {
    animation: highlight 5s ease-out;
}

@keyframes highlight {
    0% {
        background-color: var(--bs-success);
        transform: translateX(-10px);
    }
    50% {
        transform: translateX(0);
    }
    100% {
        background-color: transparent;
    }
}

.new-quote {
    animation: highlight 1s ease-out;
    border-left: 4px solid var(--bs-success);
    position: relative;
}

.new-quote::before {
    content: 'New';
    position: absolute;
    top: 0;
    right: 0;
    background: var(--bs-success);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0 0.25rem 0 0.25rem;
    font-size: 0.75rem;
    font-weight: bold;
    opacity: 0;
    animation: fadeInOut 5s ease-in-out;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    10%, 90% { opacity: 1; }
}

/* Main Layout Styles */
.main-container {
    display: flex;
    min-height: 100vh;
    background-color: #ffffff;
}

/* App shell layout for proper footer positioning */
.app-shell {
    display: flex;
    min-height: 100vh;
    background-color: #ffffff;
}

.app-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 100vh;
}

/* Desktop layout - add left margin to account for fixed sidebar */
@media (min-width: 768px) {
    .app-main {
        margin-left: 256px; /* w-64 in Tailwind = 256px */
    }
    
    .main-layout-container {
        position: relative;
    }
}

/* Main content area should expand to fill available space */
.main-content-wrapper {
    flex: 1 0 auto;
    display: block;
}

.sidebar {
    width: 16rem;
    background-color: #f9fafb;
    border-right: 1px solid #e5e7eb;
    padding: 1rem;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
}

/* Search Bar Styles */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.875rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

/* Filter Styles */
.filter-section {
    margin-bottom: 1.5rem;
}

.filter-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.filter-option {
    margin-bottom: 0.25rem;
}

/* Quote Card Styles */
.quote-card {
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.2s ease;
}

.quote-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Login Form Styles */
.login-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-top: 2rem;
}

.login-container h2 {
    text-align: center;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.login-subtitle {
    text-align: center;
    color: #6c757d;
    margin-bottom: 2rem;
}

.custom-input {
    border: 1px solid #dee2e6;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background-color: #fff;
}

.custom-input:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.custom-button {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    background-color: #0a1929;
    border: none;
    font-weight: 500;
    margin-top: 1rem;
}

.custom-button:hover {
    background-color: #1a2a3a;
}

/* Locked Info Container Styles */
.locked-info-container {
    position: relative;
    margin: 1rem 0;
    padding: 1.5rem;
    border-radius: 8px;
    background: #ffffff; /* Changed to white */
    border: 2px solid #ffc107;
    overflow: hidden;
}

.locked-info-container .blurred-content {
    filter: blur(5px);
    -webkit-filter: blur(5px);
    opacity: 0.7;
    user-select: none;
}

.info-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 10;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.info-overlay span {
    color: #ffc107;
    font-weight: bold;
}

.logo-smiley {
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
}

.message-bubble {
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border: none;
}

/* Text truncation utility classes */
.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Task card compact styles */
.task-card-compact {
    max-height: 200px;
    transition: all 0.3s ease;
}

.task-card-compact:hover {
    transform: translateY(-2px);
}

/* Task card header gradient styling */
/* Service Provider page - Blue gradient header */
.provider-task-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
}

/* My Tasks page - Won tasks green gradient header */
.won-task-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
}

/* My Tasks page - Pending tasks blue gradient header */
.pending-task-header {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
}

/* Responsive grid improvements */
@media (min-width: 1280px) {
    .task-grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1536px) {
    .task-grid-responsive {
        grid-template-columns: repeat(4, 1fr);
    }
}