/* AI Coach Tabbed Interface Styles */
:root {
    --mcai-primary-color: #3b82f6;
    --mcai-primary-hover: #2563eb;
    --mcai-primary-light: rgba(59, 130, 246, 0.1);
    --mcai-success-color: #10b981;
    --mcai-success-hover: #059669;
}

/* Main container with modern styling */
.mcai-tabbed-container {
    max-width: 900px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    border: 1px solid #e5e7eb;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    line-height: 1.5;
}

/* Header section */
.mcai-header {
    background: linear-gradient(135deg, var(--mcai-primary-color) 0%, #6366f1 100%);
    padding: 18px 24px;
    color: white;
}

.mcai-header-title {
    font-size: 1.4em;
    font-weight: 600;
    text-align: center;
    margin: 0;
}

/* External video section (outside AI container) */
.mcai-external-video-section {
    width: 100%;
    margin: 0 0 20px 0;
    padding: 0 20px;
}

.mcai-external-video-section .mcai-video {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    position: relative;
}

.mcai-external-video-section .mcai-video::before {
    content: "";
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.mcai-external-video-section .mcai-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Video section (when present) - Legacy for compatibility */
.mcai-video-section {
    padding: 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
}

.mcai-video-section .mcai-video {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.mcai-video-section .mcai-video::before {
    content: "";
    display: block;
    padding-top: 56.25%; /* 16:9 aspect ratio */
}

.mcai-video-section .mcai-video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Briefing section */
.mcai-briefing-section {
    padding: 20px 24px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.mcai-briefing-section h2 {
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.mcai-briefing-section p {
    color: #6b7280;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.mcai-briefing-section p:last-child {
    margin-bottom: 0;
}

/* Main assistant area */
.mcai-assistant {
    height: 600px;
    display: flex;
    flex-direction: column;
    background: white;
}

/* Tab Navigation */
.mcai-tab-nav {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    position: relative;
}

/* When briefing section is not present, add top border radius to tab nav */
.mcai-tabbed-container > .mcai-assistant > .mcai-tab-nav {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.mcai-tab-nav::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: var(--mcai-primary-color);
    width: 33.33%;
    transition: transform 0.3s ease;
}

.mcai-tab-nav[data-active="1"]::after { transform: translateX(0%); }
.mcai-tab-nav[data-active="2"]::after { transform: translateX(100%); }
.mcai-tab-nav[data-active="3"]::after { transform: translateX(200%); }

.mcai-tab-btn {
    flex: 1;
    padding: 14px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95em;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
    font-family: inherit;
}

.mcai-tab-btn:hover {
    color: #374151;
    background: #f3f4f6;
}

.mcai-tab-btn.active {
    color: var(--mcai-primary-color);
    background: white;
}

.mcai-tab-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Tab Content */
.mcai-tab-content {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
}

.mcai-tab-content.active {
    display: flex;
}

/* Chat Tab Styles */
.mcai-chat-tab-header {
    background: #f8fafc;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mcai-chat-title {
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mcai-ai-icon {
    width: 20px;
    height: 20px;
    background: var(--mcai-primary-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.mcai-save-chat-btn {
    background: var(--mcai-success-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: inherit;
}

.mcai-save-chat-btn:hover {
    background: var(--mcai-success-hover);
}

.mcai-save-chat-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Chat messages area */
.mcai-chat-messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafbfc;
    min-height: 0;
}

/* Individual message styles */
.mcai-tabbed-message {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    position: relative;
    transition: transform 0.1s ease;
    clear: both;
    word-wrap: break-word;
}

.mcai-tabbed-message:hover {
    transform: translateY(-1px);
}

.mcai-tabbed-message.user {
    background: var(--mcai-primary-color);
    color: white;
    margin-left: auto;
    float: right;
}

.mcai-tabbed-message.ai {
    background: white;
    border: 1px solid #e5e7eb;
    color: #374151;
    margin-right: auto;
    float: left;
}

.mcai-tabbed-message.error {
    background: #fee2e2;
    border: 1px solid #fecaca;
    color: #dc2626;
    margin-right: auto;
    float: left;
}

/* Message content formatting */
.mcai-tabbed-message h1,
.mcai-tabbed-message h2,
.mcai-tabbed-message h3,
.mcai-tabbed-message h4 {
    margin: 0.5em 0;
    font-weight: 600;
    color: inherit;
}

.mcai-tabbed-message h1 { font-size: 1.2em; }
.mcai-tabbed-message h2 { font-size: 1.1em; }
.mcai-tabbed-message h3 { font-size: 1.05em; }
.mcai-tabbed-message h4 { font-size: 1em; }

.mcai-tabbed-message p {
    margin: 0 0 8px 0;
}

.mcai-tabbed-message p:last-child {
    margin-bottom: 0;
}

.mcai-tabbed-message ul,
.mcai-tabbed-message ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.mcai-tabbed-message li {
    margin-bottom: 0.3em;
}

.mcai-tabbed-message li:last-child {
    margin-bottom: 0;
}

/* Link styles for markdown links */
.mcai-tabbed-message a {
    color: #2271b1;
    text-decoration: underline;
    cursor: pointer;
}

.mcai-tabbed-message a:hover {
    color: #135e96;
    text-decoration: underline;
}

.mcai-tabbed-message a:visited {
    color: #6c2e9c;
}

/* Copy button for messages */
.mcai-tabbed-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 11px;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: inherit;
    font-weight: 500;
}

.mcai-tabbed-copy-btn:hover {
    background: rgba(0, 0, 0, 0.2);
}

.mcai-tabbed-message:hover .mcai-tabbed-copy-btn {
    opacity: 1;
}

/* Chat input area */
.mcai-chat-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* AI disclaimer */
.mcai-disclaimer {
    font-size: 0.8em;
    color: #6b7280;
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

/* Start button styling for tabbed interface */
.mcai-tabbed-container .mcai-start-button {
    background-color: var(--mcai-primary-color) !important;
    border-radius: 8px !important;
    padding: 12px 24px !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    transition: all 0.2s ease !important;
}

.mcai-tabbed-container .mcai-start-button:hover {
    background-color: var(--mcai-primary-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
}

.mcai-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.mcai-message-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95em;
    outline: none;
    font-family: inherit;
    transition: border-color 0.2s ease;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    overflow-y: auto;
    box-sizing: border-box;
}

.mcai-message-input:focus {
    border-color: var(--mcai-primary-color);
    box-shadow: 0 0 0 3px var(--mcai-primary-light);
}

.mcai-message-input:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.mcai-send-btn {
    background: var(--mcai-primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    width: 48px;
    min-height: 44px;
    height: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: background 0.2s ease;
    flex-shrink: 0;
    align-self: stretch;
}

.mcai-send-btn:hover {
    background: var(--mcai-primary-hover);
}

.mcai-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Your Info Tab Styles */
.mcai-info-form {
    padding: 32px;
    overflow-y: auto;
    min-height: 0;
    background: #fafbfc;
}

.mcai-form-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.mcai-form-section:last-of-type {
    margin-bottom: 32px;
}

.mcai-form-section label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.mcai-form-section .mcai-form-subtitle {
    font-size: 0.85em;
    color: #6b7280;
    margin-bottom: 12px;
    font-style: italic;
    font-weight: normal;
}

.mcai-context-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9em;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.mcai-context-input:focus {
    outline: none;
    border-color: var(--mcai-primary-color);
    box-shadow: 0 0 0 3px var(--mcai-primary-light);
}

.mcai-form-actions {
    text-align: center;
    padding: 24px 0;
}

.mcai-form-save-btn {
    background: var(--mcai-primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: inherit;
}

.mcai-form-save-btn:hover {
    background: var(--mcai-primary-hover);
}

.mcai-form-save-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Saved Chat Tab Styles */
.mcai-saved-chat-display {
    background: white;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.mcai-saved-chat-header {
    background: #f8fafc;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
}

.mcai-saved-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #fafbfc;
}

.mcai-no-saved-chat {
    text-align: center;
    color: #9ca3af;
    padding: 60px 20px;
    font-style: italic;
}

/* Loading states */
.mcai-loading-state {
    position: relative;
}

.mcai-loading-state .mcai-message-input {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.mcai-loading-state .mcai-send-btn {
    background: #9ca3af;
    cursor: not-allowed;
}

.mcai-streaming-indicator {
    display: inline-block;
    color: #6b7280;
    font-style: italic;
    animation: mcai-pulse 1.5s ease-in-out infinite;
}

.mcai-cursor {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #374151;
    border-radius: 50%;
    animation: mcai-pulse-circle 1.5s ease-in-out infinite;
    margin-left: 2px;
    vertical-align: middle;
}

@keyframes mcai-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes mcai-pulse-circle {
    0%, 100% { 
        opacity: 1; 
        transform: scale(1); 
    }
    50% { 
        opacity: 0.3; 
        transform: scale(0.8); 
    }
}

/* Success/Error messages */
.mcai-form-save-success,
.mcai-form-save-error {
    margin: 0 0 15px 0;
    padding: 12px 15px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

.mcai-form-save-success {
    background-color: #d1fae5;
    border: 1px solid #a7f3d0;
    color: #065f46;
}

.mcai-form-save-error {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

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

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .mcai-external-video-section {
        padding: 0 15px;
        margin-bottom: 15px;
    }

    .mcai-external-video-section .mcai-video {
        border-radius: 8px;
    }

    .mcai-tabbed-container {
        border-radius: 8px;
        margin: 10px;
    }

    .mcai-header {
        padding: 16px 20px;
    }

    .mcai-header-title {
        font-size: 1.2em;
    }

    .mcai-tab-btn {
        padding: 12px 8px;
        font-size: 0.9em;
    }

    .mcai-chat-messages-container {
        padding: 16px;
    }

    .mcai-chat-input-container {
        padding: 16px;
    }

    .mcai-tabbed-message {
        max-width: 95%;
        padding: 12px 14px;
    }

    .mcai-input-area {
        gap: 8px;
    }

    .mcai-send-btn {
        width: 40px;
        height: 40px;
    }

    .mcai-message-input {
        padding: 10px 12px;
        min-height: 40px;
    }

    .mcai-info-form {
        padding: 20px;
    }

    .mcai-form-section {
        padding: 16px;
    }

    .mcai-video-section {
        padding: 16px;
    }

    .mcai-briefing-section {
        padding: 16px 20px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Utility classes */
.mcai-btn {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    font-weight: 500;
}

.mcai-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.mcai-btn.primary {
    background: var(--mcai-primary-color);
    color: white;
    border-color: var(--mcai-primary-color);
}

.mcai-btn.primary:hover {
    background: var(--mcai-primary-hover);
    border-color: var(--mcai-primary-hover);
}

/* Hide original elements when using tabbed interface */
.mcai-tabbed-container .mcai-wrapper,
.mcai-tabbed-container .mcai-two-column-wrapper,
.mcai-tabbed-container .mcai-chat-container {
    display: none;
}

/* Single tab mode (no tab navigation) */
.mcai-assistant:not(:has(.mcai-tab-nav)) .mcai-tab-content {
    display: flex !important;
}

.mcai-assistant:not(:has(.mcai-tab-nav)) #mcai-chat-tab {
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}