/* Chat-specific styles - Right Sidebar Layout */
.chat-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.15), -2px 0 16px rgba(0, 0, 0, 0.1);
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    overflow: hidden;
    transform: translateX(100%);
}

.chat-container.open {
    transform: translateX(0);
}

.chat-header {
    background: linear-gradient(135deg, #0F766E, #134E4A, #0D9488);
    color: white;
    padding: 1rem 1rem 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    flex-shrink: 0;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    margin-left: auto;
    flex-shrink: 0;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Chat toggle button in navigation */
.chat-toggle-btn {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    border: 2px solid rgba(255,255,255,0.2) !important;
    cursor: pointer;
}

.chat-toggle-btn:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-2px);
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    pointer-events: none;
}

.ai-avatar {
    font-size: 2.2rem;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 1;
    flex-shrink: 0;
}

.chat-info h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    z-index: 1;
    color: white;
}

.chat-info p {
    margin: 0.25rem 0 0 0;
    opacity: 0.9;
    font-size: 0.8rem;
    font-weight: 400;
    z-index: 1;
    line-height: 1.3;
    color: white;
}

.chat-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 1;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #00ff88;
    animation: pulse-modern 2s infinite;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.5);
}

@keyframes pulse-modern {
    0% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.7;
        transform: scale(1.1);
    }
    100% { 
        opacity: 1;
        transform: scale(1);
    }
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: linear-gradient(180deg, #f8f9fa 0%, #ffffff 100%);
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 120, 212, 0.3) transparent;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 120, 212, 0.3);
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 120, 212, 0.5);
}

.message {
    display: flex;
    gap: 0.5rem;
    max-width: 95%;
    animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

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

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-message .message-avatar {
    background: linear-gradient(135deg, #0F766E, #0D9488);
    color: white;
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.25);
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.25);
}

.message-content {
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 0.5rem 0.7rem; /* More compact padding */
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 4px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.2);
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 0.8rem; /* Slightly smaller base font */
    line-height: 1.4; /* Tighter line height */
}

.message-content:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 6px rgba(0, 0, 0, 0.03);
}

.user-message .message-content {
    background: linear-gradient(135deg, #0F766E, #0D9488);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.12);
}

.message-content p {
    margin: 0 0 0.2rem 0; /* Tighter spacing */
    line-height: 1.4;
    font-size: 0.8rem;
}

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

.message-time {
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.5);
    align-self: flex-end;
    margin: 0.25rem 0.5rem 0 0.5rem;
    font-weight: 500;
}

.suggested-questions {
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.7);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.suggestions-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem 0 1rem;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.suggestions-header:hover {
    background: rgba(0, 120, 212, 0.05);
}

.suggestions-header p {
    margin: 0;
    font-weight: 600;
    color: #323130;
    font-size: 0.8rem;
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

.suggested-questions.collapsed .suggestions-header p {
    color: #605e5c;
    opacity: 0.8;
}

.collapse-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
}

.collapse-button:hover {
    background: rgba(0, 120, 212, 0.1);
}

.collapse-icon {
    font-size: 1.2rem;
    color: #0F766E;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    line-height: 1;
}

.suggested-questions.collapsed .collapse-icon {
    transform: rotate(-90deg);
    color: #605e5c;
}

/* Add a subtle hint when collapsed on mobile */
@media screen and (max-width: 768px) {
    .suggested-questions.collapsed .suggestions-header::after {
        content: " (tap to expand)";
        font-size: 0.75rem;
        color: #605e5c;
        font-weight: 400;
        opacity: 0.7;
    }
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.5rem 1rem 0.75rem 1rem;
    max-height: 140px;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.suggestion-chip {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(0, 120, 212, 0.2);
    border-radius: 12px;
    padding: 0.4rem 0.6rem;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    color: #323130;
    font-weight: 500;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    flex: 1 1 calc(50% - 0.2rem);
    white-space: normal;
    text-align: center;
    display: inline-block;
    min-width: 0;
    word-wrap: break-word;
    line-height: 1.2;
}

.suggestion-chip:hover {
    background: #0F766E;
    color: white;
    border-color: #0F766E;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(15, 118, 110, 0.3);
}

.suggested-questions.collapsed .suggestion-chips {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

.chat-input-container {
    padding: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.chat-input-wrapper {
    display: flex;
    gap: 0.4rem;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(0, 120, 212, 0.2);
    border-radius: 16px;
    padding: 0.4rem;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.chat-input-wrapper:focus-within {
    border-color: #0F766E;
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-1px);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.4rem;
    font-size: 0.8rem;
    outline: none;
    resize: none;
    color: #323130;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

#chat-input::placeholder {
    color: rgba(0, 0, 0, 0.5);
    font-weight: 400;
}

#send-button {
    background: linear-gradient(135deg, #0F766E, #0D9488);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0, 120, 212, 0.3);
}

#send-button:hover {
    transform: scale(1.05) translateY(-1px);
    box-shadow: 0 6px 16px rgba(0, 120, 212, 0.4);
}

#send-button:active {
    transform: scale(0.95);
}

#send-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(0, 120, 212, 0.15);
}

.send-icon {
    font-size: 0.9rem;
    line-height: 1;
}

.input-footer {
    margin-top: 0.4rem;
    text-align: center;
}

.input-footer small {
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.65rem;
    font-weight: 400;
}

/* Loading animation - Modern */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: 80%;
    align-self: flex-start;
    animation: slideInUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.typing-dots {
    background: rgba(255, 255, 255, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1.25rem;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    gap: 0.4rem;
}

.typing-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #0F766E;
    animation: typing-modern 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0ms; }
.typing-dot:nth-child(2) { animation-delay: 200ms; }
.typing-dot:nth-child(3) { animation-delay: 400ms; }

@keyframes typing-modern {
    0%, 60%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Error message */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    border-radius: var(--radius-lg);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}

/* Enhanced message content formatting */
.message-content strong {
    font-weight: 600;
    color: var(--primary-color);
}

.user-message .message-content strong {
    color: rgba(255, 255, 255, 0.95);
}

.message-content ul, .message-content ol {
    margin: 0.4rem 0;
    padding-left: 1.2rem;
}

.message-content li {
    margin: 0.25rem 0;
    line-height: 1.4;
    font-size: 0.8rem;
}

.message-content h1, .message-content h2, .message-content h3 {
    color: var(--primary-color);
    margin: 0.6rem 0 0.4rem 0;
    font-weight: 600;
    font-size: 0.85rem;
}

.user-message .message-content h1,
.user-message .message-content h2,
.user-message .message-content h3 {
    color: rgba(255, 255, 255, 0.95);
}

.message-content .emoji {
    font-size: 0.9em;
    margin-right: 0.2rem;
}

.message-content code {
    background: var(--gray-100);
    padding: 0.15rem 0.3rem;
    border-radius: 0.2rem;
    font-family: 'Courier New', monospace;
    font-size: 0.75em;
}

.user-message .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* Visual separators in messages */
.message-content hr {
    border: none;
    height: 1px;
    background: var(--gray-200);
    margin: 0.5rem 0;
}

.user-message .message-content hr {
    background: rgba(255, 255, 255, 0.3);
}

/* Mobile responsiveness - Sidebar optimization */
@media screen and (max-width: 768px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        right: 0;
        border-radius: 0;
        position: fixed;
        z-index: 1001;
        transform: translateX(100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }
    
    .chat-container.open {
        transform: translateX(0);
    }
    
    .chat-header {
        padding: 1rem;
        background: linear-gradient(135deg, #0F766E, #0D9488, #134E4A);
        color: white;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
        position: relative;
        z-index: 1002;
    }
    
    .chat-close-btn {
        background: rgba(255, 255, 255, 0.2);
        color: white;
        border: none;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 16px;
        font-weight: bold;
        margin-left: auto;
        z-index: 1003;
    }
    
    .chat-close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
    }
    
    .chat-info h3 {
        color: white !important;
        font-size: 1.1rem;
    }
    
    .chat-info p {
        color: rgba(255, 255, 255, 0.9) !important;
    }
    
    .ai-avatar {
        width: 40px;
        height: 40px;
        font-size: 2rem;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .suggestions-header {
        padding: 1rem 1rem 0.5rem 1rem;
    }
    
    .suggestions-header p {
        font-size: 0.85rem;
    }
    
    .collapse-button {
        padding: 0.5rem;
        min-width: 40px;
        min-height: 40px;
    }
    
    .collapse-icon {
        font-size: 1.2rem;
    }
    
    .suggestion-chips {
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        padding: 0.75rem 1.25rem 1.25rem 1.25rem;
        gap: 0.75rem;
        display: flex;
        width: 100%;
    }
    
    .suggestion-chip {
        text-align: left !important;
        border-radius: 12px;
        padding: 1rem 1.25rem;
        font-size: 0.9rem;
        min-height: 44px;
        display: block !important;
        align-items: center;
        width: 100% !important;
        box-sizing: border-box;
        flex: none !important;
        white-space: normal !important;
        max-width: none !important;
    }
    
    .message {
        max-width: 95%;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .message-content {
        padding: 0.6rem 0.8rem;
        border-radius: 10px;
    }
    
    .chat-input-wrapper {
        border-radius: 20px;
        padding: 0.625rem;
    }
    
    #send-button {
        width: 40px;
        height: 40px;
    }
}

@media screen and (max-width: 480px) {
    .chat-container {
        width: 100%;
        height: 100vh;
        right: 0;
        border-radius: 0;
        position: fixed;
    }
    
    .message-content {
        padding: 0.4rem 0.6rem; /* Even more compact on mobile */
        font-size: 0.75rem; /* Smaller font on mobile */
        border-radius: 8px;
    }
    
    .message-content p {
        margin: 0 0 0.15rem 0; /* Tighter spacing on mobile */
        line-height: 1.35;
    }
    
    .message {
        gap: 0.4rem; /* Tighter gap between avatar and content */
    }
}
    
    .chat-container.open {
        transform: translateX(0);
    }
    
    .chat-header {
        padding: 0.75rem;
    }
    
    .chat-messages {
        padding: 0.75rem;
    }
    
    .suggestions-header {
        padding: 0.75rem 0.75rem 0.5rem 0.75rem;
    }
    
    .suggestions-header p {
        font-size: 0.8rem;
    }
    
    .collapse-button {
        padding: 0.5rem;
        min-width: 36px;
        min-height: 36px;
    }
    
    .collapse-icon {
        font-size: 1.1rem;
    }
    
    .suggestion-chips {
        padding: 0.5rem 0.75rem 0.75rem 0.75rem;
        gap: 0.5rem;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        display: flex;
        width: 100%;
    }
    
    .suggestion-chip {
        padding: 0.75rem;
        font-size: 0.8rem;
        min-height: 36px;
        width: 100% !important;
        box-sizing: border-box;
        display: block !important;
        text-align: left !important;
        flex: none !important;
        white-space: normal !important;
        max-width: none !important;
        margin: 0 !important;
    }
    
    .chat-input-container {
        padding: 0.75rem;
    }
    
    .chat-input-wrapper {
        border-radius: 16px;
        padding: 0.5rem;
    }
    
    #send-button {
        width: 32px;
        height: 32px;
    }
    
    .send-icon {
        font-size: 0.9rem;
    }
}

/* Dashboard Mode Compatibility - Just color adjustments */
body.dashboard-mode .chat-container {
    background: rgba(255, 255, 255, 0.98); /* Slightly more opaque on dark background */
}

body.dashboard-mode .chat-messages {
    color: #333; /* Ensure text is readable on white background over dark dashboard */
}

body.dashboard-mode .message-content {
    color: #333 !important; /* Force dark text on dashboard mode */
}

body.dashboard-mode .user-message .message-content {
    color: white !important; /* Keep user messages white */
}

body.dashboard-mode .ai-message .message-content {
    color: #333 !important; /* AI messages dark for readability */
}

/* Enhanced Mobile Improvements */
@media (max-width: 480px) {
  .chat-header h3 {
    font-size: 1rem;
  }
  
  .chat-close-btn {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  
  .chat-input {
    font-size: 0.9rem;
    padding: 0.75rem;
  }
  
  .send-btn {
    padding: 0.75rem;
    min-width: 45px;
  }

  .ai-avatar {
    width: 30px;
    height: 30px;
  }

  .message-content {
    padding: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.4;
  }

  .typing-indicator {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  .chat-body {
    padding: 0.75rem;
  }

  .chat-input-container {
    padding: 0.75rem;
    gap: 0.5rem;
  }
}

/* Touch-friendly improvements */
@media (max-width: 768px) and (hover: none) {
  .send-btn, .chat-close-btn, .chat-toggle-btn {
    min-height: 44px;
    min-width: 44px;
  }
  
  .chat-input {
    min-height: 44px;
  }
  
  .message-content {
    -webkit-user-select: text;
    user-select: text;
  }
}
