/* Coala AI Chat Animation Styles */
.coala-ai-chat-container {
    max-width: 1200px;
    margin: 0 auto;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    border: 1px solid #e9ecef;
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.chat-wrapper {
    display: flex;
    min-height: 600px;
    background: #ffffff;
    width: 100%;
    box-sizing: border-box;
}

/* Left Panel - Chat Interface */
.chat-panel {
    flex: 1;
    background: #f8f9fa;
    border-right: 1px solid #e9ecef;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex items from overflowing */
    box-sizing: border-box;
}

.chat-header {
    padding: 24px 24px 20px 24px;
    background: #f8f9fa;
}

.chat-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
}

.chat-messages {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    min-height: 320px;
    max-height: 400px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

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

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

.message.user {
    text-align: right;
}

.message.ai {
    text-align: left;
}

.message-bubble {
    display: inline-block;
    max-width: 85%;
    padding: 14px 18px;
    border-radius: 20px;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.message.user .message-bubble {
    background: #4a5568;
    color: white;
    border-bottom-right-radius: 6px;
}

.message.ai .message-bubble {
    background: #e2e8f0;
    color: #2d3748;
    border-bottom-left-radius: 6px;
}

.message.ai .message-bubble strong {
    color: #6c5ce7;
}

.chat-input-container {
    padding: 20px 24px 24px 24px;
    background: #f8f9fa;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

.chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid #cbd5e0;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    background: white;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    color: #4a5568;
    box-sizing: border-box;
    min-width: 0; /* Prevents overflow in flex containers */
}

.chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-input::placeholder {
    color: #a0aec0;
}

.send-button {
    padding: 14px 24px;
    background: #4a5568;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    min-width: 80px;
    touch-action: manipulation; /* Improves touch responsiveness */
    -webkit-tap-highlight-color: transparent; /* Removes tap highlight on iOS */
    box-sizing: border-box;
}

.send-button:hover {
    background: #2d3748;
    transform: translateY(-1px);
}

.send-button:active {
    transform: translateY(0);
}

.send-button:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

/* Remove left side progress bar styles - only need right side progress */

/* Right Panel - Live Preview */
.preview-panel {
    flex: 1;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    min-width: 0; /* Prevents flex items from overflowing */
    box-sizing: border-box;
}

.preview-header {
    padding: 24px 24px 20px 24px;
    background: #ffffff;
}

.preview-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
}

.preview-content {
    flex: 1;
    padding: 20px 24px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.building-message {
    font-size: 16px;
    color: #a0aec0;
    margin-bottom: 40px;
    text-align: center;
    font-weight: 500;
}

.ai-response {
    background: #f7fafc;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    max-width: 100%;
    margin-bottom: 40px;
    line-height: 1.6;
    text-align: left;
    min-height: 120px;
    font-size: 14px;
    color: #4a5568;
}

/* Inline highlights (badges) inside preview text */
.ai-response .hl {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    line-height: 1.2;
    margin: 0 2px;
    color: #1f2937;
    background: #e5e7eb;
}

.ai-response .hl-company {
    background: rgba(34, 197, 94, 0.25); /* green - matches company dot */
}
.ai-response .hl-industry {
    background: rgba(139, 92, 246, 0.25); /* purple - matches industry dot */
}
.ai-response .hl-product {
    background: rgba(34, 197, 94, 0.25); /* green - matches products dot */
}
.ai-response .hl-audience {
    background: rgba(251, 146, 60, 0.25); /* orange - matches audience dot */
}
.ai-response .hl-style {
    background: rgba(236, 72, 153, 0.25); /* pink - matches style dot */
}
.ai-response .hl-goal {
    background: rgba(6, 182, 212, 0.25); /* cyan - matches goals dot */
}

/* Progress Bar in Preview Panel */
.progress-container-preview {
    width: 100%;
    margin: 24px 0 16px 0;
}

.progress-bar-preview {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill-preview {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

.field-status-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 16px;
}

.field-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
    transition: all 0.3s ease;
}

.status-dot.completed {
    background: #48bb78;
    animation: pulse 1s ease-in-out;
}

.color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    opacity: 0.6;
}

.color-company { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.color-industry { background: linear-gradient(135deg, #a78bfa, #8b5cf6); }
.color-products { background: linear-gradient(135deg, #4ade80, #22c55e); }
.color-audience { background: linear-gradient(135deg, #fb923c, #f97316); }
.color-style { background: linear-gradient(135deg, #f472b6, #ec4899); }
.color-goals { background: linear-gradient(135deg, #22d3ee, #06b6d4); }

/* Typing Animation */
.typing-indicator {
    display: inline-block;
    padding: 14px 18px;
    background: #e2e8f0;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a0aec0;
    animation: typingAnimation 1.5s infinite;
}

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

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

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Responsive Design */

/* Base responsive container */
.coala-ai-chat-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 10px;
    box-sizing: border-box;
}

/* Large screens (desktops) - 1200px and up */
@media (min-width: 1200px) {
    .coala-ai-chat-container {
        max-width: 1200px;
        padding: 0;
    }
    
    .chat-messages {
        max-height: 450px;
    }
}

/* Medium-large screens (small desktops, large tablets) - 992px to 1199px */
@media (max-width: 1199px) and (min-width: 992px) {
    .coala-ai-chat-container {
        max-width: 95%;
    }
    
    .chat-header,
    .preview-header {
        padding: 20px 20px 16px 20px;
    }
    
    .chat-messages {
        padding: 16px 20px;
        max-height: 380px;
    }
    
    .chat-input-container {
        padding: 16px 20px 20px 20px;
    }
    
    .preview-content {
        padding: 16px 20px 20px 20px;
    }
}

/* Medium screens (tablets in landscape) - 768px to 991px */
@media (max-width: 991px) and (min-width: 768px) {
    .coala-ai-chat-container {
        max-width: 100%;
        margin: 0 5px;
    }
    
    .chat-wrapper {
        min-height: 500px;
    }
    
    .chat-header h3,
    .preview-header h3 {
        font-size: 18px;
    }
    
    .chat-messages {
        max-height: 320px;
        padding: 16px 18px;
    }
    
    .message-bubble {
        max-width: 90%;
        font-size: 13px;
        padding: 12px 16px;
    }
    
    .chat-input {
        font-size: 13px;
        padding: 12px 16px;
    }
    
    .send-button {
        padding: 12px 20px;
        font-size: 13px;
        min-width: 70px;
    }
    
    .ai-response {
        padding: 20px;
        font-size: 13px;
    }
    
    .field-status-item {
        font-size: 10px;
    }
}

/* Small screens (tablets in portrait, large phones) - 576px to 767px */
@media (max-width: 767px) and (min-width: 576px) {
    .coala-ai-chat-container {
        margin: 0;
        border-radius: 8px;
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    }
    
    .chat-wrapper {
        flex-direction: column;
        min-height: auto;
    }
    
    .chat-panel {
        flex: none;
        min-height: 450px;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .preview-panel {
        flex: none;
        min-height: 350px;
        border-right: none;
    }
    
    .chat-header,
    .preview-header {
        padding: 18px 16px 14px 16px;
    }
    
    .chat-header h3,
    .preview-header h3 {
        font-size: 17px;
    }
    
    .chat-messages {
        padding: 14px 16px;
        max-height: 280px;
        min-height: 200px;
    }
    
    .chat-input-container {
        padding: 14px 16px 18px 16px;
    }
    
    .input-wrapper {
        flex-direction: row;
        gap: 10px;
    }
    
    .chat-input {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .send-button {
        padding: 12px 18px;
        min-width: 65px;
        font-size: 13px;
    }
    
    .message-bubble {
        max-width: 85%;
        font-size: 13px;
        padding: 11px 15px;
    }
    
    .preview-content {
        padding: 14px 16px 18px 16px;
    }
    
    .ai-response {
        padding: 18px;
        font-size: 13px;
        margin-bottom: 30px;
    }
    
    .building-message {
        font-size: 15px;
        margin-bottom: 30px;
    }
    
    .field-status-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    
    .field-status-item {
        font-size: 10px;
    }
}

/* Extra small screens (phones) - up to 575px */
@media (max-width: 575px) {
    .coala-ai-chat-container {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: none;
        min-height: auto; /* Changed from 100vh to auto */
        height: auto;
    }
    
    .chat-wrapper {
        flex-direction: column;
        min-height: auto; /* Changed from 100vh to auto */
        height: auto;
    }
    
    .chat-panel {
        flex: none; /* Changed from flex: 1 */
        min-height: 50vh; /* Reduced from 60vh to 50vh */
        max-height: 50vh;
        border-right: none;
        border-bottom: 2px solid #e9ecef;
        display: flex;
        flex-direction: column;
    }
    
    .preview-panel {
        flex: none; /* Changed from flex: 1 */
        min-height: 50vh; /* Increased from 40vh to 50vh */
        max-height: 50vh;
        border-right: none;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .chat-header,
    .preview-header {
        padding: 16px 12px 12px 12px;
        background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
        border-bottom: 1px solid #e9ecef; /* Added border for clear separation */
        flex-shrink: 0; /* Prevent header from shrinking */
    }
    
    .chat-header h3,
    .preview-header h3 {
        font-size: 16px;
        font-weight: 700;
        margin: 0;
    }
    
    .chat-messages {
        padding: 12px;
        max-height: 250px; /* Fixed height instead of viewport calculation */
        min-height: 200px; /* Fixed height instead of viewport calculation */
        font-size: 13px;
        flex: 1; /* Allow it to grow within the chat panel */
        overflow-y: auto;
    }
    
    .chat-input-container {
        padding: 12px;
        background: #ffffff;
        border-top: 1px solid #e9ecef;
        flex-shrink: 0; /* Prevent input area from shrinking */
    }
    
    .input-wrapper {
        flex-direction: column;
        gap: 8px;
    }
    
    .chat-input {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px 16px;
        border-radius: 20px;
        border: 2px solid #cbd5e0;
    }
    
    .chat-input:focus {
        border-color: #667eea;
        box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.15);
    }
    
    .send-button {
        width: 100%;
        padding: 14px;
        font-size: 14px;
        font-weight: 700;
        border-radius: 20px;
        min-width: unset;
    }
    
    .message {
        margin-bottom: 12px;
    }
    
    .message-bubble {
        max-width: 90%;
        font-size: 14px;
        padding: 12px 16px;
        line-height: 1.5;
        border-radius: 18px;
    }
    
    .message.user .message-bubble {
        border-bottom-right-radius: 4px;
    }
    
    .message.ai .message-bubble {
        border-bottom-left-radius: 4px;
    }
    
    .preview-content {
        padding: 12px;
        overflow-y: auto;
        flex: 1; /* Allow it to grow within the preview panel */
        display: flex;
        flex-direction: column;
    }
    
    .ai-response {
        padding: 16px;
        font-size: 14px;
        line-height: 1.6;
        margin-bottom: 20px;
        border-radius: 16px;
    }
    
    .building-message {
        font-size: 14px;
        margin-bottom: 20px;
        line-height: 1.5;
    }
    
    .field-status-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        margin-top: 12px;
    }
    
    .field-status-item {
        font-size: 11px;
        padding: 4px 0;
    }
    
    .status-dot {
        width: 10px;
        height: 10px;
    }
    
    .color-indicator {
        width: 14px;
        height: 14px;
    }
    
    .progress-container-preview {
        margin: 16px 0 12px 0;
    }
    
    .progress-bar-preview {
        height: 8px;
        border-radius: 4px;
    }
    
    .progress-fill-preview {
        border-radius: 4px;
    }
    
    /* Typing indicator adjustments */
    .typing-indicator {
        padding: 12px 16px;
        border-radius: 18px;
        border-bottom-left-radius: 4px;
    }
    
    .typing-dot {
        width: 7px;
        height: 7px;
    }
}

/* Very small screens (older phones) - up to 380px */
@media (max-width: 380px) {
    .coala-ai-chat-container {
        min-height: auto;
    }
    
    .chat-panel {
        min-height: 45vh; /* Slightly smaller on very small screens */
        max-height: 45vh;
    }
    
    .preview-panel {
        min-height: 45vh; /* Slightly smaller on very small screens */
        max-height: 45vh;
    }
    
    .chat-messages {
        max-height: 200px;
        min-height: 150px;
    }
    
    .chat-header h3,
    .preview-header h3 {
        font-size: 15px;
    }
    
    .message-bubble {
        max-width: 95%;
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .chat-input {
        font-size: 16px;
        padding: 12px 14px;
    }
    
    .ai-response {
        padding: 14px;
        font-size: 13px;
    }
    
    .field-status-item {
        font-size: 10px;
    }
}

/* Landscape orientation adjustments for phones */
@media (max-width: 767px) and (orientation: landscape) {
    .coala-ai-chat-container {
        min-height: auto; /* Changed from 100vh */
        height: auto;
    }
    
    .chat-wrapper {
        flex-direction: row; /* Side by side in landscape */
        min-height: 100vh;
        height: 100vh;
    }
    
    .chat-panel,
    .preview-panel {
        flex: 1;
        min-height: 100vh;
        max-height: 100vh;
        overflow: hidden;
    }
    
    .chat-panel {
        border-right: 1px solid #e9ecef;
        border-bottom: none;
    }
    
    .chat-messages {
        max-height: calc(100vh - 200px);
        min-height: calc(100vh - 200px);
    }
    
    .preview-content {
        max-height: calc(100vh - 120px);
        overflow-y: auto;
    }
}

/* Debug utility classes for mobile visibility */
@media (max-width: 575px) {
    /* Ensure both panels are visible with distinct backgrounds */
    .chat-panel {
        background: #f8f9fa !important;
        border: 1px solid #dee2e6;
    }
    
    .preview-panel {
        background: #ffffff !important;
        border: 1px solid #dee2e6;
        border-top: 2px solid #667eea; /* Blue top border to distinguish */
    }
    
    /* Force visibility of preview content */
    .preview-content {
        background: #ffffff;
        min-height: 200px !important;
    }
    
    .building-message,
    .ai-response {
        display: block !important;
        visibility: visible !important;
    }
    
    /* Ensure field status grid is visible */
    .field-status-grid {
        display: grid !important;
        visibility: visible !important;
    }
    
    /* Progress bar visibility */
    .progress-container-preview {
        display: block !important;
        visibility: visible !important;
    }
}

/* Print styles */
@media print {
    .coala-ai-chat-container {
        box-shadow: none;
        border: 1px solid #000;
    }
    
    .chat-input {
        border: 1px solid #000;
    }
    
    .message-bubble {
        break-inside: avoid;
    }
}

/* Responsive utility classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Mobile debug class - add this class to container for debugging */
.mobile-debug {
    border: 3px solid red !important;
}

.mobile-debug .chat-panel {
    border: 2px solid blue !important;
    background: rgba(0, 0, 255, 0.1) !important;
}

.mobile-debug .preview-panel {
    border: 2px solid green !important;
    background: rgba(0, 255, 0, 0.1) !important;
}

.mobile-debug .chat-header::before {
    content: "CHAT PANEL";
    position: absolute;
    top: 0;
    left: 0;
    background: blue;
    color: white;
    padding: 2px 5px;
    font-size: 10px;
    z-index: 1000;
}

.mobile-debug .preview-header::before {
    content: "PREVIEW PANEL";
    position: absolute;
    top: 0;
    left: 0;
    background: green;
    color: white;
    padding: 2px 5px;
    font-size: 10px;
    z-index: 1000;
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .message-bubble {
        border: 2px solid;
    }
    
    .chat-input {
        border: 2px solid;
    }
    
    .control-btn,
    .send-button {
        border: 2px solid;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    .coala-ai-chat-container {
        background: #1a202c;
        border-color: #2d3748;
        color: #e2e8f0;
    }
    
    .chat-panel {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .preview-panel {
        background: #1a202c;
    }
    
    .chat-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .chat-input::placeholder {
        color: #a0aec0;
    }
    
    .message.ai .message-bubble {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .ai-response {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}
