/* Deal Research Chat Styles */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-radius: 0.375rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

body {
    background-color: #f8f9fa;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Sidebar Styles */
.sidebar {
    background-color: white;
    border-right: 1px solid #dee2e6;
    min-height: calc(100vh - 56px);
    padding: 0;
}


.sidebar-content {
    padding: 1rem;
}

.sidebar-title {
    color: var(--secondary-color);
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

/* Main Content */
.main-content {
    padding: 0;
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

/* Chat Container */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: white;
}

.chat-header {
    flex-shrink: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: #f8f9fa;
}

.chat-input-container {
    flex-shrink: 0;
}

/* Message Styles */
.message {
    display: flex;
    margin-bottom: 1rem;
    animation: fadeInUp 0.3s ease-out;
}

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

.user-message .message-avatar {
    background-color: var(--primary-color);
    color: white;
}

.ai-message .message-avatar {
    background-color: var(--success-color);
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-text {
    background-color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    margin-bottom: 0.25rem;
    word-wrap: break-word;
}

.user-message .message-text {
    background-color: var(--primary-color);
    color: white;
    margin-left: auto;
    max-width: 80%;
}

.ai-message .message-text {
    background-color: white;
    border: 1px solid #dee2e6;
    max-width: 90%;
}

.message-time {
    font-size: 0.75rem;
    color: var(--secondary-color);
    margin-left: 0.5rem;
}

/* Deal Cards */
.deal-card {
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 1rem;
    margin: 0.5rem 0;
    box-shadow: var(--box-shadow);
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    transform: translateY(20px);
    position: relative;
    overflow: visible;
}

.deal-card.fade-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.deal-card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.deal-card .deal-title {
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 0.5rem;
}

.deal-card .deal-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--success-color);
}

.deal-card .deal-merchant {
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.deal-card .deal-discount {
    background-color: var(--danger-color);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
    margin-top: 0.5rem;
}

/* Deal Images */
.deal-image {
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    transition: transform 0.2s ease;
}

.deal-card:hover .deal-image {
    transform: scale(1.02);
}

/* Deal Card Layout */
.deal-card .row {
    margin: 0;
}

.deal-card .col-md-8,
.deal-card .col-md-4 {
    padding-left: 0;
    padding-right: 0;
}

.deal-card .col-md-8 {
    padding-right: 0;
}

.deal-card .col-md-8.with-image {
    padding-left: 48px; /* Shift text to the right only when there's an image */
}

.deal-card .col-md-4 {
    padding-left: 1rem;
}

/* Merchant Logo Tab */
.merchant-logo-tab {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px 0 0 0;
    padding: 0;
}

.merchant-logo {
    width: 32px;
    height: 32px;
    border-radius: 0;
    object-fit: contain;
    background-color: #f8f9fa;
    padding: 0;
    transition: transform 0.2s ease;
    display: block;
}

.merchant-logo-tab:hover .merchant-logo {
    transform: scale(1.05);
}

/* Typing Indicator */
.typing-indicator {
    margin-bottom: 1rem;
    padding-left: 1rem; /* Match the chat-messages padding */
    background-color: #f8f9fa; /* Match the chat-messages background */
}

.typing-indicator .message {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0; /* Override the default message margin */
}

.typing-indicator .message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    flex-shrink: 0;
    background-color: var(--success-color);
    color: white;
}

.typing-indicator .message-content {
    flex: 1;
    min-width: 0;
}

.typing-dots {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: white;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 90%;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

/* Connection Status */
#connection-status {
    font-size: 0.875rem;
}

#connection-status .fa-circle {
    font-size: 0.5rem;
}

#connection-status.connected .fa-circle {
    color: var(--success-color) !important;
}

#connection-status.disconnected .fa-circle {
    color: var(--danger-color) !important;
}

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

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

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .main-content {
        width: 100%;
    }
    
    .message-text {
        max-width: 95% !important;
    }
    
    .deal-card {
        margin: 0.25rem 0;
    }
}

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

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

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

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

/* Input Focus Styles */
#message-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Button Hover Effects */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Error States */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
}

/* Success States */
.success-message {
    background-color: #d1edff;
    color: #0c5460;
    border: 1px solid #bee5eb;
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
}

/* Markdown Content Styles */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.2;
}

.message-text h1 { font-size: 1.5rem; }
.message-text h2 { font-size: 1.3rem; }
.message-text h3 { font-size: 1.1rem; }
.message-text h4 { font-size: 1rem; }
.message-text h5 { font-size: 0.9rem; }
.message-text h6 { font-size: 0.8rem; }

.message-text p {
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.message-text ul,
.message-text ol {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
}

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

.message-text blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin: 1rem 0;
    font-style: italic;
    color: var(--secondary-color);
    background-color: #f8f9fa;
    padding: 0.75rem 1rem;
    border-radius: 0 0.375rem 0.375rem 0;
}

.message-text code {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.25rem;
    padding: 0.125rem 0.25rem;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875em;
    color: #e83e8c;
}

.message-text pre {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

.message-text pre code {
    background-color: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.875rem;
}

.message-text th,
.message-text td {
    border: 1px solid #dee2e6;
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.message-text th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.message-text tr:nth-child(even) {
    background-color: #f8f9fa;
}

.message-text a {
    color: var(--primary-color);
    text-decoration: none;
}

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

.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

.message-text hr {
    border: none;
    border-top: 1px solid #dee2e6;
    margin: 1.5rem 0;
}

/* Deal-specific markdown styles */
.message-text .deal-reference {
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    border-radius: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-weight: 500;
    color: var(--primary-color);
    display: inline-block;
    margin: 0 0.125rem;
}

/* Prompt Editor Styles */
.prompt-editor-container {
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
}

.prompt-header {
    flex-shrink: 0;
}

.prompt-list-container {
    height: calc(100vh - 56px - 120px);
    overflow-y: auto;
}

.prompt-editor-form {
    height: calc(100vh - 56px - 120px);
    overflow-y: auto;
}

.prompt-item {
    cursor: pointer;
    border: 1px solid #dee2e6;
    margin-bottom: 0.5rem;
    border-radius: var(--border-radius);
    transition: all 0.2s ease;
}

.prompt-item:hover {
    background-color: #f8f9fa;
    border-color: var(--primary-color);
}

.prompt-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.prompt-item.active h6,
.prompt-item.active small,
.prompt-item.active p,
.prompt-item.active .text-muted {
    color: white !important;
}

.prompt-item h6 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.prompt-item p {
    font-size: 0.8rem;
    line-height: 1.3;
    margin-bottom: 0;
}

#prompt-text {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

#no-prompt-selected {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#no-prompt-selected i {
    opacity: 0.5;
}

/* Toast Styles */
.toast {
    min-width: 300px;
}

.toast.bg-success {
    background-color: var(--success-color) !important;
}

.toast.bg-danger {
    background-color: var(--danger-color) !important;
}

/* Form Validation */
.form-control:invalid {
    border-color: var(--danger-color);
}

.form-control:valid {
    border-color: var(--success-color);
}

/* Button Hover Effects */
.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

/* Modal Enhancements */
.modal-header {
    border-bottom: 2px solid #dee2e6;
}

.modal-footer {
    border-top: 2px solid #dee2e6;
}

/* Macro Validation Panel Styles */
.macro-validation-panel {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: var(--border-radius);
    padding: 1rem;
    height: 100%;
    min-height: 400px;
}

.macro-status-container {
    max-height: 350px;
    overflow-y: auto;
}

.macro-status-container .badge {
    font-size: 0.75rem;
    margin: 0.125rem 0;
    display: block;
    text-align: left;
    padding: 0.5rem;
    border-radius: 0.25rem;
}

.macro-status-container h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.macro-status-container .text-success h6,
.macro-status-container .text-danger h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Disabled Save Button */
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Required Macros Input */
#required-macros {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .prompt-editor-container .row {
        flex-direction: column;
    }
    
    .prompt-list-container {
        height: 200px;
        border-right: none !important;
        border-bottom: 1px solid #dee2e6;
    }
    
    .prompt-editor-form {
        height: calc(100vh - 56px - 320px);
    }
}
