:root {
    /* Project theme tokens */
    --color-primary: #20282D;
    --color-secondary: #1F1F25;
    --color-blue: #141416;
    --color-sky: #82b440;
    --color-body: #5D666F;
    --color-heading-1: #1C2539;
    --color-title: #141416;
    --color-heading-dark: #141416;
    --transition: .3s;
    --bg-dark-1: #1E1E20;
    --color-white: #fff;
    --color-border: #DDD8F9;
    --border-width: 1px;
    --radius: 10px;
    --color-success: #3EB75E;
    --color-danger: #FF0003;
    --color-warning: #FF8F3C;
    --color-info: #1BA2DB;
    --color-facebook: #3B5997;
    --color-twitter: #1BA1F2;
    --color-youtube: #ED4141;
    --color-linkedin: #0077B5;
    --color-pinterest: #E60022;
    --color-instagram: #C231A1;
    --color-vimeo: #00ADEF;
    --color-twitch: #6441A3;
    --color-discord: #7289da;

    /* Chat specific aliases mapping to project tokens */
    --primary-color: var(--color-blue);
    --header-bg: var(--color-blue);
    --header-border: var(--color-blue);
    --chat-bg: #f7f8fa;
    --message-received-bg: #ffffff;
    --message-sent-bg: #eef3ff;
    --text-primary: var(--color-title);
    --text-secondary: var(--color-body);
    --text-on-primary: var(--color-white);
    --input-bg: #ffffff;
    --input-border: var(--color-border);
    --radius-chat: var(--radius);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    background-color: transparent;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    max-width: 430px;
    height: 100vh;
    max-height: 100vh;
    background-color: var(--chat-bg);
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    position: relative;
}

/* Header */
.chat-header {
    background-color: var(--header-bg);
    padding: 12px 16px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    border-bottom: none;
    height: 68px;
    color: var(--text-on-primary);
}
.file-download {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 12px;
    background-color: #25D366;
    color: white !important;
    border-radius: 18px;
    text-decoration: none;
    font-weight: normal;
    transition: background-color 0.3s;
}

.file-download:hover {
    background-color: #128C7E;
}

/* Add this to your existing styles */
.message.received .message-content {
    max-width: 80%;
    word-wrap: break-word;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.back-button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    margin-right: 5px;
}

.logo img {
    width: 100px;
    height: 100px;
    border-radius: 6px;
    object-fit: contain;
    background: transparent;
}

.header-text h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-on-primary);
    margin: 0;
    line-height: 1.2;
}

.header-text p {
    font-size: 13px;
    color: rgba(255,255,255,0.9);
    margin: 0;
    font-weight: 400;
}

.header-actions { display:none; }

.action-button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 18px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.action-button:hover {
    background-color: rgba(13, 153, 255, 0.1);
}

/* Messages */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-image: none;
    background-color: var(--chat-bg);
}

.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out;
}

.message.received {
    align-self: flex-start;
}

.message.sent {
    align-self: flex-end;
}

.message-content {
    padding: 8px 12px;
    border-radius: calc(var(--radius-chat) - 2px);
    font-size: 14.2px;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.message.received .message-content {
    background-color: var(--message-received-bg);
    border-top-left-radius: 0;
    color: var(--text-primary);
}

.message.sent .message-content {
    background-color: var(--message-sent-bg);
    border-top-right-radius: 0;
    color: var(--text-primary);
    border: 1px solid #dbe8ff;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
    text-align: right;
    padding: 0 2px;
}

/* Input Area */
.chat-input-container {
    background-color: #ffffff;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--input-border);
    min-height: 62px;
}

.attachment-button, .emoji-button { display:none; }

.attachment-button:hover,
.emoji-button:hover {
    background-color: rgba(13, 153, 255, 0.1);
}

.input-wrapper {
    flex: 1;
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 22px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    height: 44px;
}

.input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 15px;
    color: var(--text-primary);
    padding: 0;
    height: 100%;
}

.input-wrapper input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.emoji-button { display:none; }

.send-button {
    background-color: var(--primary-color);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, box-shadow .2s;
    box-shadow: 0 6px 16px #20282D;
}

.send-button:hover {
    background-color: #5D666F;
    box-shadow: 0 8px 18px #5D666F;
}

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

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #a0a0a0;
}

/* Responsive Design */
@media (max-width: 480px) {
    .chat-container {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .message {
        max-width: 90%;
    }
    
    .chat-messages { 
        padding: 12px 10px; 
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .chat-input-container { 
        padding: 8px 10px; 
        min-height: 60px;
        flex-shrink: 0;
    }
    
    .input-wrapper {
        height: 40px;
        padding: 0 12px;
    }
    
    .input-wrapper input {
        font-size: 14px;
    }
    
    .send-button {
        width: 40px;
        height: 40px;
    }
    
    .clear-button {
        font-size: 16px;
        margin-left: 8px;
    }
}

@media (max-width: 360px) {
    .chat-messages { 
        padding: 10px 8px; 
    }
    
    .chat-input-container { 
        padding: 6px 8px; 
        min-height: 56px;
    }
    
    .input-wrapper {
        height: 36px;
        padding: 0 10px;
    }
    
    .input-wrapper input {
        font-size: 13px;
    }
    
    .send-button {
        width: 36px;
        height: 36px;
    }
    
    .message-content {
        font-size: 13px;
        padding: 6px 10px;
    }
}

/* HTML Table Styles for Regulatory Information */
.message-content {
    overflow-x: auto;
}

.message-content table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
    background-color: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.message-content table th,
.message-content table td {
    padding: 12px 16px;
    text-align: left;
    border: 1px solid #d0d0d0;
    vertical-align: top;
    word-wrap: break-word;
}

.message-content table th {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    font-weight: 700;
    color: #2c3e50;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #4b7bec;
}

.message-content table td {
    background-color: #ffffff;
    color: #34495e;
    font-size: 13px;
    line-height: 1.6;
}

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

.message-content table tr:hover td {
    background-color: #e3f2fd;
    transition: background-color 0.2s ease;
}

.message-content table tr:hover th {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
}

/* Table container for horizontal scrolling */
.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.table-wrapper table {
    margin: 0;
    box-shadow: none;
    border-radius: 0;
}

/* Responsive table adjustments */
@media (max-width: 768px) {
    .message-content table {
        font-size: 12px;
        min-width: 500px;
    }
    
    .message-content table th,
    .message-content table td {
        padding: 8px 12px;
    }
    
    .message-content table th {
        font-size: 11px;
    }
    
    .message-content table td {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .message-content table {
        font-size: 11px;
        min-width: 400px;
    }
    
    .message-content table th,
    .message-content table td {
        padding: 6px 8px;
    }
    
    .message-content table th {
        font-size: 10px;
    }
    
    .message-content table td {
        font-size: 10px;
    }
}

/* Style for headings in regulatory content */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    font-weight: 600;
    color: var(--color-heading-1);
    line-height: 1.35;
}

.message-content h1 {
    color: var(--color-primary);
    font-size: 18px;
    margin: 18px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-border);
}

.message-content h2 {
    color: var(--color-primary);
    font-size: 16px;
    margin: 16px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-border);
}

.message-content h3 {
    color: var(--color-primary);
    font-size: 16px;
    margin: 16px 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 2px solid var(--color-border);
}

.message-content h4 {
    color: var(--color-heading-1);
    font-size: 14px;
    margin: 12px 0 8px 0;
}

.message-content h5 {
    font-size: 13px;
    margin: 10px 0 6px 0;
}

.message-content h6 {
    font-size: 12px;
    margin: 8px 0 6px 0;
}

/* Ensure links in tables are styled properly */
.message-content table a {
    color: #4b7bec;
    text-decoration: none;
    font-weight: 500;
}

.message-content table a:hover {
    color: #3a6ad4;
    text-decoration: underline;
}

/* Specific styling for regulatory tables */
.message-content table .ql-table-block {
    margin: 0;
    padding: 0;
}

.message-content table p {
    margin: 0;
    padding: 0;
}

.message-content table strong {
    font-weight: 700;
}

/* Override any inline styles that might interfere */
.message-content table td[style*="width"] {
    width: auto !important;
    min-width: 150px;
}

.message-content table td[style*="background"] {
    background-color: inherit !important;
}

.message-content table td[style*="color"] {
    color: inherit !important;
}

/* Force table display and override any conflicting styles */
.message-content table {
    display: table !important;
    table-layout: auto !important;
}

.message-content table tr {
    display: table-row !important;
}

.message-content table td,
.message-content table th {
    display: table-cell !important;
    vertical-align: top !important;
}

/* Ensure proper table structure is maintained */
.message-content table tbody {
    display: table-row-group !important;
}

.message-content table thead {
    display: table-header-group !important;
}

.message-content table tfoot {
    display: table-footer-group !important;
}

/* Override any inline styles that break table layout */
.message-content table[style] {
    width: 100% !important;
    border-collapse: collapse !important;
}

.message-content table td[style*="width"] {
    width: auto !important;
    min-width: 120px !important;
}

.message-content table th[style*="width"] {
    width: auto !important;
    min-width: 120px !important;
}

/* Regulatory page link button styles */
.message-content a[target="_blank"] {
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(75, 123, 236, 0.3);
}

.message-content a[target="_blank"]:hover {
    background: #3a6ad4 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(75, 123, 236, 0.4);
    text-decoration: none !important;
}

/* Mobile table adjustments */
@media (max-width: 768px) {
    .message-content table {
        font-size: 0.8em;
    }
    
    .message-content table th,
    .message-content table td {
        padding: 8px 10px;
    }
}
