/**
 * Dialogue Chat Styles
 *
 * Chat-like styling for pretend dialogue modal
 * Matches actual chat.css styling exactly
 */

/* == MODAL SIZING - Best Practices == */

/*
 * Modal sizing follows responsive design best practices:
 * - Mobile: Full screen (100vw x 100vh)
 * - Tablet/Desktop: 80% of viewport with proper margins
 * - Ultra-wide: Capped at reasonable maximum width
 * - Proper spacing to prevent touching screen edges
 * - Bootstrap modal-dialog-centered handles vertical alignment
 */

/* Mobile: Full screen experience */
@media (max-width: 767px) {
    .dialogue-chat-modal-dialog {
        max-width: 100vw !important;
        width: 100vw !important;
        max-height: 100vh !important;
        height: 100vh !important;
        margin: 0 !important;
    }

    .dialogue-chat-modal-content {
        height: 100vh !important;
        border-radius: 0 !important;
    }
}

/* Tablet and Desktop: Match chat window size (70.833333% = ~71%) */
@media (min-width: 768px) {
    .dialogue-chat-modal-dialog {
        max-width: 70.833333vw !important; /* Match chat window width */
        width: 70.833333vw !important;
        max-height: 85vh !important; /* 85vh to account for browser chrome */
        margin: 1.75rem auto !important; /* Bootstrap default margin */
    }

    .dialogue-chat-modal-content {
        max-height: min(80vh, calc(100vh - 3.5rem)) !important; /* Max height constraint */
        width: 100% !important;
    }
}

/* Large Desktop: Cap maximum width to match chat constraints */
@media (min-width: 1920px) {
    .dialogue-chat-modal-dialog {
        max-width: min(70.833333vw, 1360px) !important; /* Proportional cap for ultra-wide */
    }
}

/* Modal structure */
.dialogue-chat-modal-content {
    display: flex;
    flex-direction: column;
    background-color: var(--surface);
    border-radius: 12px;
    border: 3px solid #000000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.dialogue-chat-modal-content .modal-header {
    flex: 0 0 auto;
    background: var(--color-background) !important;
    color: var(--color-text) !important;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.dialogue-chat-modal-content .modal-title {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--color-text) !important;
}

.dialogue-chat-modal-content .btn-close {
    /* Close button uses default Bootstrap styling for light backgrounds */
}

.dialogue-chat-modal-content .modal-body {
    flex: 1 1 auto;
    overflow: hidden;
    padding: 0;
}

.dialogue-chat-modal-content .modal-footer {
    flex: 0 0 auto;
    border-top: 1px solid var(--color-border, #dee2e6);
    padding: 1rem 1.5rem;
}

/* == MESSAGES CONTAINER == */

.dialogue-chat-messages {
    height: 500px; /* Fixed height to match other modals */
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    background-color: var(--color-background, #f8f9fa);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

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

.dialogue-chat-messages::-webkit-scrollbar-track {
    background: var(--color-background, #f8f9fa);
}

.dialogue-chat-messages::-webkit-scrollbar-thumb {
    background: var(--color-border, #dee2e6);
    border-radius: 4px;
}

.dialogue-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted, #adb5bd);
}

/* == MESSAGE STYLING (Matches chat.css exactly) == */

/* Message bubbles */
.dialogue-chat-messages .message {
    display: flex;
    margin-bottom: 1.5rem;
    max-width: 85%;
    animation: messageSlideIn 0.3s ease-out;
}

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

.dialogue-chat-messages .message.user-message {
    margin-left: auto !important;
}

.dialogue-chat-messages .message.assistant-message,
.dialogue-chat-messages .message.coach-message {
    margin-right: auto !important;
}

/* Message wrapper (groups content and timestamp) */
.dialogue-chat-messages .message-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
    min-width: 0;
}

/* Message content */
.dialogue-chat-messages .message-content {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-lg, 12px);
    word-wrap: break-word;
    line-height: 1.5;
}

/* Clearfix for floated avatar */
.dialogue-chat-messages .message-content::after {
    content: "";
    display: table;
    clear: both;
}

/* Message avatar (floated inside assistant/coach messages) */
.dialogue-chat-messages .message-avatar {
    float: left;
    width: 48px;
    height: 48px;
    margin-right: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 50%;
    overflow: hidden;
    background: transparent;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-sizing: border-box;
}

.dialogue-chat-messages .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* User avatar (floated inside user messages on the right) */
.dialogue-chat-messages .message.user-message .message-avatar {
    float: right;
    margin-right: 0;
    margin-left: 0.75rem;
}

/* Message text content - flows around avatar */
.dialogue-chat-messages .message-text {
    word-wrap: break-word;
    white-space: pre-wrap;
}

/* Background colors with gradients (matches chat.css) */
.dialogue-chat-messages .message.assistant-message .message-content,
.dialogue-chat-messages .message.coach-message .message-content {
    background: var(--chat-coach-gradient, linear-gradient(135deg, var(--chat-coach-color, var(--blue, #0d6efd)), var(--chat-coach-color-dark, var(--blue-dark, #0a58ca))));
    color: var(--white, #ffffff);
    border: none;
}

.dialogue-chat-messages .message.user-message .message-content {
    background: var(--chat-user-gradient, linear-gradient(135deg, var(--chat-user-color, var(--brand-1, #6366f1)), var(--chat-user-color-dark, var(--brand-2, #8b5cf6))));
    color: var(--white, #ffffff);
}

/* Message timestamp - hidden by default */
.dialogue-chat-messages .message-time,
.dialogue-chat-messages .message-timestamp {
    display: none !important;
}

/* == MARKDOWN FORMATTING (Matches chat.css) == */

.dialogue-chat-messages .message-content h1,
.dialogue-chat-messages .message-content h2,
.dialogue-chat-messages .message-content h3,
.dialogue-chat-messages .message-content h4,
.dialogue-chat-messages .message-content h5,
.dialogue-chat-messages .message-content h6 {
    margin: 0.5rem 0;
    font-weight: 600;
}

.dialogue-chat-messages .message-content h1 { font-size: 1.25rem; }
.dialogue-chat-messages .message-content h2 { font-size: 1.15rem; }
.dialogue-chat-messages .message-content h3 { font-size: 1.1rem; }
.dialogue-chat-messages .message-content h4 { font-size: 1.05rem; }
.dialogue-chat-messages .message-content h5 { font-size: 1rem; }
.dialogue-chat-messages .message-content h6 { font-size: 0.95rem; }

.dialogue-chat-messages .message-content p {
    margin: 0.5rem 0;
}

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

.dialogue-chat-messages .message-content ul,
.dialogue-chat-messages .message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.dialogue-chat-messages .message-content li {
    margin: 0.25rem 0;
}

.dialogue-chat-messages .message-content blockquote {
    border-left: 3px solid rgba(255, 255, 255, 0.3);
    padding-left: 1rem;
    margin: 0.5rem 0;
    font-style: italic;
}

.dialogue-chat-messages .message-content code {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.dialogue-chat-messages .message-content pre {
    background: rgba(0, 0, 0, 0.2);
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.dialogue-chat-messages .message-content pre code {
    background: none;
    padding: 0;
}

.dialogue-chat-messages .message-content strong,
.dialogue-chat-messages .message-content b {
    font-weight: 600;
}

.dialogue-chat-messages .message-content em,
.dialogue-chat-messages .message-content i {
    font-style: italic;
}

.dialogue-chat-messages .message-content a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

.dialogue-chat-messages .message-content a:hover {
    color: white;
}

/* == TYPING INDICATOR == */

.dialogue-chat-messages .typing-indicator {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    animation: fadeIn 0.3s ease-in;
    margin-top: auto;
    margin-bottom: 1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.dialogue-chat-messages .typing-bubble {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: var(--chat-coach-gradient, linear-gradient(135deg, var(--chat-coach-color, var(--blue, #0d6efd)), var(--chat-coach-color-dark, var(--blue-dark, #0a58ca))));
    color: var(--white, #ffffff);
    border-radius: var(--radius-lg, 12px);
    border-bottom-left-radius: 4px;
    max-width: 85%;
}

.dialogue-chat-messages .typing-text {
    font-size: 0.9375rem;
    color: var(--white, #ffffff);
}

.dialogue-chat-messages .dots {
    display: inline-flex;
    gap: 0.25rem;
}

.dialogue-chat-messages .dot {
    width: 6px;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.dialogue-chat-messages .dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-4px);
    }
}

/* == ACTION BUTTON == */

.dialogue-action-btn {
    min-width: 120px;
    font-weight: 600;
    padding: 0.625rem 1.5rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.dialogue-action-btn.btn-warning {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #000;
}

.dialogue-action-btn.btn-warning:hover {
    background-color: #ffb300;
    border-color: #ffb300;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.dialogue-action-btn.btn-primary {
    background: var(--grad-brand);
    border-color: var(--brand-1);
}

.dialogue-action-btn.btn-primary:hover {
    background: var(--grad-brand-rev);
    border-color: var(--brand-2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--brand-rgb), 0.4);
}

/* == MOBILE RESPONSIVENESS == */

@media (max-width: 767px) {
    .dialogue-chat-messages {
        height: calc(100vh - 180px); /* Full height minus header and footer on mobile */
        padding: 1rem;
    }

    .dialogue-chat-messages .message {
        max-width: 95%;
    }

    .dialogue-chat-messages .message-content {
        padding: 0.625rem 1rem;
    }

    .dialogue-chat-messages .message-avatar {
        width: 40px;
        height: 40px;
    }

    .dialogue-chat-modal-content .modal-header {
        border-radius: 0;
    }
}

/* == THEME SUPPORT == */

/* Dark mode is automatically handled by the theme system via CSS variable overrides in variables.css */
/* No explicit .theme-dark rules needed - variables like --surface, --color-border adapt automatically */
