/**
 * Bot Testing Interface CSS
 * Based on WordPress plugin design with fullscreen capabilities
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
}

/* Header */
.header {
    background: linear-gradient(135deg, #0057b7 0%, #ffd700 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 87, 183, 0.2);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header .flag {
    font-size: 1.2rem;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.org-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.org-badge.test {
    background: rgba(255, 193, 7, 0.8);
    color: #000;
    font-weight: 600;
}

.btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn-logout {
    background: rgba(220, 53, 69, 0.8);
    border-color: rgba(220, 53, 69, 0.8);
}

.btn-logout:hover {
    background: rgba(220, 53, 69, 1);
}

/* Main container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Widget positioning */
.widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    transition: all 0.3s ease;
}

.widget-container.minimized {
    width: 350px;
    height: 500px;
}

.widget-container.fullscreen {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: #f8f9fa;
}

.fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f8f9fa;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.fullscreen-container .header {
    flex-shrink: 0;
}

.fullscreen-container .main-content {
    flex: 1;
    overflow: hidden;
    padding: 0;
    max-width: none;
}

/* Chat interface */
.chat-interface {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Widget mode styling */
.widget-container.minimized .chat-interface {
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.widget-container.fullscreen .chat-interface {
    border-radius: 0;
    box-shadow: none;
}

.fullscreen-container .chat-interface {
    height: 100%;
    border-radius: 0;
    margin-top: 0;
}

.chat-header {
    background: linear-gradient(135deg, #0057b7 0%, #ffd700 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: pointer;
}

.widget-container.minimized .chat-header {
    padding: 0.8rem 1rem;
    border-radius: 15px 15px 0 0;
}

.widget-container.fullscreen .chat-header {
    padding: 1.5rem;
    border-radius: 0;
    cursor: default;
}

.chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header .flag {
    font-size: 1.5rem;
}

.chat-header h2 {
    font-size: 1.1rem;
    margin: 0;
}

.widget-container.minimized .chat-header h2 {
    font-size: 1rem;
}

.widget-container.fullscreen .chat-header h2 {
    font-size: 1.3rem;
}

.chat-status {
    font-size: 0.9rem;
    opacity: 0.9;
}

.fullscreen-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.fullscreen-toggle:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
}

.widget-container.minimized .messages-container {
    padding: 0.8rem;
}

.widget-container.fullscreen .messages-container {
    padding: 1.5rem;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.message {
    display: flex;
    margin-bottom: 1rem;
    animation: messageSlide 0.3s ease-out;
}

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

.message.bot {
    align-items: flex-start;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
    margin: 0 8px;
}

.message.bot .message-avatar {
    background: linear-gradient(135deg, #0057b7 0%, #ffd700 100%);
    color: white;
}

.message.user .message-avatar {
    background: #6c757d;
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 0.8rem 1rem;
    border-radius: 15px;
    position: relative;
    word-wrap: break-word;
}

.widget-container.minimized .message-content {
    max-width: 85%;
    padding: 0.6rem 0.8rem;
    border-radius: 12px;
}

.widget-container.fullscreen .message-content {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
}

.message.bot .message-content {
    background: white;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message.user .message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-text {
    margin: 0;
    line-height: 1.5;
}

.message-timestamp {
    font-size: 0.75rem;
    opacity: 0.6;
    display: block;
    margin-top: 0.5rem;
}

.message-sources {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
    font-size: 0.8rem;
}

.message-sources strong {
    display: block;
    margin-bottom: 0.5rem;
}

.message-sources ul {
    margin: 0;
    padding-left: 1rem;
    list-style-type: disc;
}

.message-sources li {
    margin-bottom: 0.25rem;
}

.message-sources a {
    color: #0057b7;
    text-decoration: none;
}

.message-sources a:hover {
    text-decoration: underline;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typingDots 1.4s infinite ease-in-out;
}

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

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

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

/* Input area */
.input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid #e9ecef;
    flex-shrink: 0;
}

.widget-container.minimized .input-area {
    padding: 0.8rem;
    border-radius: 0 0 15px 15px;
}

.widget-container.fullscreen .input-area {
    padding: 1.5rem;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 20px;
    transition: border-color 0.2s ease;
}

.input-container.focused {
    border-color: #0057b7;
}

.input-field {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    max-height: 120px;
    min-height: 20px;
    overflow-y: auto;
}

.input-field::placeholder {
    color: #6c757d;
}

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

.btn-action {
    background: #0057b7;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn-action:hover {
    background: #004494;
    transform: translateY(-1px);
}

.btn-action:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.btn-new-chat {
    background: #6c757d;
}

.btn-new-chat:hover {
    background: #5a6268;
}

/* Login page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0057b7 0%, #ffd700 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: #0057b7;
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-weight: 600;
    color: #333;
}

.form-input {
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #0057b7;
}

.btn-primary {
    background: #0057b7;
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: #004494;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.error-message {
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    text-align: center;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .header {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .header-info {
        justify-content: center;
    }
    
    .chat-interface {
        height: calc(100vh - 200px);
    }
    
    .fullscreen-container .chat-interface {
        height: calc(100vh - 80px);
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .login-card {
        margin: 1rem;
        padding: 2rem;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }
    
    .chat-header h2 {
        font-size: 1rem;
    }
    
    .messages-container {
        padding: 1rem;
    }
    
    .input-area {
        padding: 1rem;
    }
}

/* Focus styles for accessibility */
.btn:focus,
.btn-action:focus,
.fullscreen-toggle:focus {
    outline: 2px solid #0057b7;
    outline-offset: 2px;
}

.form-input:focus {
    box-shadow: 0 0 0 3px rgba(0, 87, 183, 0.1);
}

/* High contrast support */
@media (prefers-contrast: high) {
    .chat-interface,
    .login-card {
        border: 2px solid #000;
    }
    
    .message-content {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}