/* Modern AI Legal Chatbot Styles */

/* CSS Variables for consistent theming */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --background-gradient: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    --chat-bg: #f8fafc;
    --white: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --border-color: #e2e8f0;
    --shadow-light: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-large: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--chat-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Main chat wrapper */
.chat-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    background: var(--white);
    box-shadow: var(--shadow-large);
    position: relative;
}

/* Enhanced Header */
.chat-header {
    background: var(--primary-gradient);
    color: var(--white);
    padding: 1.5rem 2rem;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="20" cy="20" r="2" fill="rgba(255,255,255,0.1)"><animate attributeName="opacity" values="0;1;0" dur="3s" repeatCount="indefinite" begin="0s"/></circle><circle cx="80" cy="40" r="3" fill="rgba(255,255,255,0.1)"><animate attributeName="opacity" values="0;1;0" dur="3s" repeatCount="indefinite" begin="1s"/></circle><circle cx="40" cy="80" r="2" fill="rgba(255,255,255,0.1)"><animate attributeName="opacity" values="0;1;0" dur="3s" repeatCount="indefinite" begin="2s"/></circle></svg>');
    pointer-events: none;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    position: relative;
    z-index: 1;
}

.ai-avatar {
    position: relative;
}

.avatar-circle {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--white);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
}

.status-indicator {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #48bb78;
    border-radius: 50%;
    border: 2px solid var(--white);
    animation: pulse-status 2s infinite;
}

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

.header-info {
    flex: 1;
}

.assistant-name {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    background: linear-gradient(45deg, rgba(255,255,255,1), rgba(255,255,255,0.8));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.assistant-description {
    font-size: 0.95rem;
    opacity: 0.9;
    margin: 0;
}

.trust-badges {
    display: flex;
    gap: 0.75rem;
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.85rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.trust-badge:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

/* Welcome Section */
.welcome-section {
    padding: 3rem 2rem;
    text-align: center;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.welcome-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.expertise-areas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    max-width: 800px;
    margin: 0 auto;
}

.expertise-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.expertise-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-medium);
    border-color: rgba(102, 126, 234, 0.3);
}

.expertise-item i {
    font-size: 2rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.expertise-item span {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding-bottom: 140px; /* Space for fixed input area */
}

.chat-messages {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: var(--chat-bg);
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.5);
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: messageSlideIn 0.4s ease-out;
    max-width: 100%;
}

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

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin: 0 0.75rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-light);
}

.message.user-message .message-avatar {
    background: var(--secondary-gradient);
    color: var(--white);
    order: 2;
}

.message.assistant-message .message-avatar {
    background: var(--primary-gradient);
    color: var(--white);
    order: 1;
}

.message-content {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: var(--shadow-light);
    word-wrap: break-word;
    white-space: pre-wrap; /* This preserves formatting and line breaks */
}

.message.user-message .message-content {
    background: var(--secondary-gradient);
    color: var(--white);
    border-bottom-right-radius: 4px;
    order: 1;
}

.message.assistant-message .message-content {
    background: var(--white);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    order: 2;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    animation: messageSlideIn 0.4s ease-out;
}

.typing-indicator .message-avatar {
    background: var(--primary-gradient);
    color: var(--white);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* Chat Input Section */
.chat-input-section {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    padding: 1.5rem 2rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 100;
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
}

.input-wrapper {
    background: var(--white);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem;
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

.input-wrapper:focus-within {
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1), var(--shadow-medium);
}

#user-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    background: transparent;
    min-height: 24px;
    max-height: 120px;
}

#user-input::placeholder {
    color: var(--text-secondary);
}

.input-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn, .send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-light);
}

.action-btn {
    background: var(--chat-bg);
    color: var(--text-secondary);
}

.action-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.send-btn {
    background: var(--primary-gradient);
    color: var(--white);
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: var(--shadow-medium);
}

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

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.character-count {
    font-weight: 500;
}

.disclaimer {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    background: var(--white);
    padding: 2rem;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-large);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top: 4px solid rgba(102, 126, 234, 1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Searching Indicator */
.searching-indicator {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    animation: messageSlideIn 0.4s ease-out;
}

.searching-indicator .message-avatar {
    background: var(--primary-gradient);
    color: var(--white);
}

.searching-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--white);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
}

.search-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top: 2px solid rgba(102, 126, 234, 1);
    border-radius: 50%;
    animation: searchSpin 1s linear infinite;
}

@keyframes searchSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.search-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

/* Streaming Message Styles */
.message.streaming .message-content {
    position: relative;
}

.message.streaming .message-content::after {
    content: '▋';
    color: rgba(102, 126, 234, 0.8);
    animation: streamingCursor 1s infinite;
    margin-left: 2px;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .chat-wrapper {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
    
    .chat-container {
        padding-bottom: 120px; /* Space for mobile input area */
    }
    
    .chat-input-section {
        padding: 1rem 1.5rem;
        max-width: 100%;
        left: 0;
        transform: none;
    }
    
    .chat-header {
        padding: 1rem 1.5rem;
    }
    
    .header-content {
        gap: 1rem;
    }
    
    .avatar-circle {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .assistant-name {
        font-size: 1.25rem;
    }
    
    .trust-badges {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .welcome-section {
        padding: 2rem 1.5rem;
    }
    
    .welcome-content h2 {
        font-size: 1.5rem;
    }
    
    .expertise-areas {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .chat-messages {
        padding: 1rem;
    }
    
    .message-content {
        max-width: 85%;
        font-size: 0.9rem;
    }
    
    .input-actions {
        gap: 0.4rem;
    }
    
    .send-btn {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .chat-input-section {
        padding: 0.75rem 1rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .welcome-content p {
        font-size: 1rem;
    }
    
    .expertise-areas {
        gap: 0.75rem;
    }
    
    .message-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
    }
}

/* Legacy Bootstrap compatibility */
.border-dashed {
    border-style: dashed !important;
    border-width: 2px !important;
}

/* Lawyer recommendation card styling */
.lawyer-recommendation {
    width: 100%;
    max-width: 700px;
    margin: 20px auto;
}

.lawyer-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-medium);
    overflow: hidden;
    background-color: var(--white);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.lawyer-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-large);
}

.lawyer-card-header {
    background: var(--primary-gradient);
    color: var(--white);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.lawyer-card-header h4 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
}

.lawyer-card-body {
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
}

.lawyer-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border-color);
    flex-shrink: 0;
}

.lawyer-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lawyer-info {
    flex: 1;
}

.lawyer-info h5 {
    margin: 0 0 0.5rem 0;
    color: var(--text-primary);
    font-weight: 600;
}

.lawyer-specializations {
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.lawyer-description {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.lawyer-contact {
    font-size: 0.85rem;
}

.lawyer-contact p {
    margin: 0.25rem 0;
    color: var(--text-secondary);
}

.lawyer-contact i {
    width: 16px;
    color: rgba(102, 126, 234, 0.7);
}

@media (max-width: 576px) {
    .lawyer-card-body {
        flex-direction: column;
        text-align: center;
    }
    
    .lawyer-photo {
        align-self: center;
    }
    
    .lawyer-info {
        text-align: left;
    }
}