/**
 * AI Agent for Lawyers - Frontend Styles (Premium Redesign with Background)
 */
:root {
    --primary-color: #0f172a;
    /* Deep Navy */
    --secondary-color: #1e293b;
    /* Lighter Navy */
    --accent-color: #c0a062;
    /* Premium Gold */
    --accent-hover: #d4af37;
    --text-light: #f8fafc;
    --text-dim: #cbd5e1;
    /* Lighter dim for better contrast */
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #334155;
    --message-bot-bg: rgba(30, 41, 59, 0.85);
    /* Semi-transparent */
    --message-user-bg: rgba(59, 130, 246, 0.9);
    /* Semi-transparent */
    --font-serif: "Georgia", "Times New Roman", Times, serif;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.ai-lawyer-plugin-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: var(--font-sans);
    background-color: #f1f5f9;
}

.ai-lawyer-chat-wrapper {
    max-width: 900px;
    margin: 2rem auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--primary-color);
}

/* Chat Widget Container with Background Image */
.ai-lawyer-chat-widget {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 75vh;
    min-height: 600px;
    background-image: url('https://images.unsplash.com/photo-1687289133469-b2a07a13b78b?q=80&w=987&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Dark Overlay for Readability */
.ai-lawyer-chat-widget::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.2);
    /* Even lighter overlay */
    backdrop-filter: blur(4px);
    /* Slight blur to soften background */
    z-index: 0;
}

/* Header */
.chat-header {
    background: rgba(15, 23, 42, 0.9);
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    z-index: 10;
    backdrop-filter: blur(10px);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.lawyer-avatar {
    background: linear-gradient(135deg, var(--accent-color), #eab308);
    border-radius: 50%;
    width: 60px;
    /* Slightly larger */
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(192, 160, 98, 0.4);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.avatar-icon {
    font-size: 30px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.lawyer-info h3 {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-light);
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.lawyer-info p {
    margin: 0.2rem 0 0;
    font-size: 0.95rem;
    color: var(--accent-color);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Chat Area */
.chat-messages {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background-color: transparent;
    scroll-behavior: smooth;
    position: relative;
    z-index: 1;
}

/* Controls */
.welcome-header-controls {
    position: relative;
    min-height: 40px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#api-status-indicator {
    background-color: rgba(0, 0, 0, 0.4);
    color: var(--text-light);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
}

#api-status-indicator.active {
    background-color: rgba(16, 185, 129, 0.3);
    color: #4ade80;
    border-color: rgba(74, 222, 128, 0.4);
}

#clear-chat-button {
    background: rgba(220, 38, 38, 0.2);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

#clear-chat-button:hover {
    background: rgba(220, 38, 38, 0.4);
    color: #fff;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.bot-message .message-avatar {
    background: var(--secondary-color);
    color: var(--accent-color);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-message .message-avatar {
    background: #2563eb;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-text {
    padding: 18px 24px;
    border-radius: 18px;
    line-height: 1.7;
    font-size: 1.05rem;
    /* Slightly larger for readability */
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
}

.bot-message .message-text {
    background: var(--message-bot-bg);
    color: var(--text-light);
    border-top-left-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-message .message-text {
    background: var(--message-user-bg);
    color: white;
    border-top-right-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Welcome Message Specifics */
.welcome-message {
    max-width: 100%;
    margin-right: 0;
}

.welcome-message .message-text {
    background: rgba(15, 23, 42, 0.85);
    /* Darker for welcome message */
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 24px;
}

.example-questions {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    margin: 24px 0;
}

.example-questions p strong {
    color: var(--accent-color);
    font-size: 1.1rem;
}

.example-questions ul {
    padding-left: 0;
    margin: 12px 0 0;
    list-style: none;
}

.example-questions li {
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-light);
    margin-bottom: 10px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
}

.example-questions li::before {
    content: '⚖️';
    margin-right: 10px;
    font-size: 1.1rem;
}

.example-questions li:hover {
    background: rgba(192, 160, 98, 0.15);
    border-color: var(--accent-color);
    transform: translateX(5px);
}

.disclaimer {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 1.5rem;
    display: block;
    padding: 10px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    text-align: center;
}

/* Input Area */
.chat-input-container {
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding: 24px 32px;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    /* Stack input and button */
    gap: 16px;
    align-items: center;
    /* Center items */
    background: rgba(255, 255, 255, 0.1);
    /* Increased opacity for better visibility */
    padding: 20px;
    /* Increased padding */
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    /* Stronger border */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    /* Added shadow for depth */
    transition: border-color 0.3s, box-shadow 0.3s, background 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(192, 160, 98, 0.3), 0 8px 20px rgba(0, 0, 0, 0.3);
    background: rgba(255, 255, 255, 0.15);
    /* Lighter on focus */
}

#chat-input {
    width: 100%;
    /* Full width */
    background: transparent;
    border: none;
    color: var(--text-light);
    padding: 12px;
    font-size: 1.1rem;
    resize: none;
    font-family: inherit;
    max-height: 150px;
    line-height: 1.5;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    /* Separator */
}

#chat-input:focus {
    outline: none;
    box-shadow: none;
    border-bottom-color: var(--accent-color);
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.send-button {
    width: 80%;
    /* Large width */
    max-width: 300px;
    height: 56px;
    /* Taller */
    background: var(--accent-color);
    border: none;
    border-radius: 28px;
    /* Rounded pill shape */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: var(--primary-color);
    flex-shrink: 0;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.send-button::after {
    content: '送信する';
    margin-left: 8px;
}

.send-button:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(192, 160, 98, 0.5);
}

.send-button:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.2);
    cursor: not-allowed;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: transparent;
    font-style: italic;
    color: var(--text-dim);
    font-size: 0.95rem;
    position: relative;
    z-index: 2;
}

.typing-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    margin: 0 3px;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* Comment Section */
.ai-lawyer-comment-section {
    padding: 30px 40px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center content */
}

.ai-lawyer-comment-section h4 {
    margin-top: 0;
    margin-bottom: 10px;
    color: var(--primary-color);
    font-family: var(--font-serif);
    font-size: 1.2rem;
    width: 100%;
}

.ai-lawyer-comment-section p {
    color: #64748b;
    font-size: 0.95rem;
    margin-bottom: 20px;
    width: 100%;
}

.comment-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    align-items: center;
}

#comment-input {
    width: 100%;
    background: white;
    border: 2px solid #cbd5e1;
    color: #334155;
    transition: border-color 0.2s;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 1rem;
    resize: none;
    font-family: inherit;
    max-height: 250px;
    /* Limit height */
    line-height: 1.5;
}

#comment-input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.send-comment-button {
    width: 80%;
    max-width: 300px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    padding: 0 28px;
    font-weight: 700;
    transition: all 0.2s;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.send-comment-button:hover {
    background: #334155;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Footer */
.chat-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    background-color: #e2e8f0;
    color: #64748b;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.footer-disclaimer {
    display: block;
    margin-bottom: 8px;
    color: #ef4444;
    /* Red warning color */
    font-weight: bold;
    font-size: 0.85rem;
    background: rgba(254, 226, 226, 0.5);
    padding: 8px;
    border-radius: 6px;
}

/* Copy Button */
.copy-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    margin-top: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
}

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

.chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}