* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #f5f5f5;
    height: 100vh;
    overflow: hidden;
}

/* Login Container */
#login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #202123 0%, #343541 100%);
}

#login-form {
    background-color: #fff;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 400px;
}

#login-form h1 {
    font-size: 24px;
    font-weight: 600;
    color: #202123;
    text-align: center;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

#login-form button[type="submit"] {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-top: 8px;
}

#login-form button[type="submit"]:hover {
    background-color: #0056b3;
}

/* Login to app transition */
#login-container,
#layout {
    transition: opacity 0.2s ease-in-out;
}

/* Layout wrapper */
#layout {
    display: flex;
    height: 100vh;
    min-width: 800px;
}

/* Sidebar */
#sidebar {
    width: 260px;
    flex-shrink: 0;
    background-color: #202123;
    color: #ececec;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid #343541;
}

.logo {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

/* User info in sidebar header (after login) */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-email {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-company {
    font-size: 12px;
    color: #8e8ea0;
}

.sidebar-nav {
    padding: 12px 8px;
    border-bottom: 1px solid #343541;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
}

.sidebar-section {
    margin-bottom: 20px;
}

.section-header {
    font-size: 11px;
    font-weight: 600;
    color: #8e8ea0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px 6px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s;
}

.sidebar-item:hover {
    background-color: #343541;
}

.sidebar-item.nav-item {
    font-weight: 500;
}

.item-icon {
    font-size: 14px;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.item-text {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 12px 8px;
    border-top: 1px solid #343541;
}

.settings-item {
    color: #8e8ea0;
}

.settings-item:hover {
    color: #ececec;
}

/* Clickable quote items */
.sidebar-item.quote-item {
    cursor: pointer;
}

.sidebar-item.quote-item:hover {
    background-color: #40414f;
}

/* Empty state for quotes */
.sidebar-empty {
    padding: 10px 12px;
    color: #8e8ea0;
    font-size: 13px;
    font-style: italic;
}

/* Main content area */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #fff;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

/* Chat container */
#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Quote viewer */
#quote-viewer,
#lead-viewer {
    display: none;
    flex-direction: column;
    height: 100%;
}

.quote-header {
    padding: 12px 20px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f5f5f5;
    flex-shrink: 0;
}

#back-to-chat-btn,
#back-to-chat-from-lead-btn {
    padding: 8px 16px;
    font-size: 14px;
    background-color: #202123;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#back-to-chat-btn:hover,
#back-to-chat-from-lead-btn:hover {
    background-color: #343541;
}

#quote-content,
#lead-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.quote-detail { max-width: 800px; margin: 0 auto; }

.quote-detail-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid #e0e0e0;
}
.quote-detail-header h2 { margin: 0; font-size: 1.4em; color: #202123; }

.status-badge {
    display: inline-block; padding: 4px 12px; border-radius: 12px;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
}
.status-badge.draft { background-color: #e3f2fd; color: #1565c0; }
.status-badge.sent { background-color: #fff3e0; color: #e65100; }
.status-badge.accepted { background-color: #e8f5e9; color: #2e7d32; }
.status-badge.rejected { background-color: #fce4ec; color: #c62828; }
.status-badge.expired { background-color: #f5f5f5; color: #616161; }

.quote-customer { margin-bottom: 20px; padding: 12px 16px; background-color: #f9f9f9; border-radius: 8px; }
.quote-customer p { margin: 4px 0; font-size: 14px; color: #333; }
.quote-meta { margin-bottom: 20px; font-size: 14px; color: #666; }

.quote-lines-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.quote-lines-table th, .quote-lines-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e0e0e0; }
.quote-lines-table th { background-color: #f5f5f5; font-weight: 600; font-size: 13px; color: #666; text-transform: uppercase; }
.quote-lines-table td { font-size: 14px; }

.line-type { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; }
.line-type.product { background-color: #e8f5e9; color: #2e7d32; }
.line-type.adhoc { background-color: #fff3e0; color: #e65100; }

.quote-total { text-align: right; font-size: 1.3em; font-weight: 700; color: #202123; padding: 12px 0; border-top: 2px solid #202123; }
.quote-dates { margin-top: 16px; font-size: 12px; color: #999; }
.quote-loading, .quote-error { text-align: center; padding: 40px; color: #666; font-size: 16px; }
.quote-error { color: #c62828; }
.item-total { text-align: right; font-weight: 500; }
.sidebar-item .item-status { font-size: 10px; padding: 2px 6px; border-radius: 8px; background-color: #343541; color: #8e8ea0; margin-left: auto; flex-shrink: 0; }
.sidebar-item .item-total-amount { font-size: 11px; color: #8e8ea0; margin-left: 4px; flex-shrink: 0; }

/* Quote view input bar */
#quote-input-area {
    display: flex;
    padding: 12px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    gap: 10px;
    flex-shrink: 0;
}

#quote-message-input {
    flex: 1;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    transition: border-color 0.2s;
}

#quote-message-input:focus { border-color: #007bff; }
#quote-message-input:disabled { background-color: #f5f5f5; cursor: not-allowed; }

#quote-send-btn {
    padding: 10px 20px;
    font-size: 15px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#quote-send-btn:hover:not(:disabled) { background-color: #0056b3; }
#quote-send-btn:disabled { background-color: #ccc; cursor: not-allowed; }

/* Quote response overlay */
#quote-response-overlay {
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #f0f7ff;
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

#quote-response-content {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
}

#quote-response-content p { margin: 0 0 0.5em 0; }
#quote-response-content p:last-child { margin-bottom: 0; }
#quote-response-content strong { font-weight: 600; }
#quote-response-content ul, #quote-response-content ol { margin: 0.5em 0; padding-left: 1.5em; }
#quote-response-content li { margin: 0.25em 0; }
#quote-response-content code { background-color: rgba(0,0,0,0.06); padding: 0.1em 0.3em; border-radius: 3px; font-size: 0.9em; }

/* Quote overlay loading state */
#quote-response-overlay.loading #quote-response-content {
    color: #666;
    font-style: italic;
}

#quote-response-overlay.loading #quote-response-content::after {
    content: '';
    animation: dots 1.5s infinite;
}

/* Context footnote on chat messages */
.message-context-footnote {
    font-size: 11px;
    color: #8e8ea0;
    margin-top: 6px;
    font-style: italic;
}

.message.user .message-context-footnote {
    color: rgba(255, 255, 255, 0.7);
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#input-area {
    display: flex;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    gap: 12px;
}

#message-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    outline: none;
    transition: border-color 0.2s;
}

#message-input:focus {
    border-color: #007bff;
}

#message-input:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

#send-btn {
    padding: 12px 24px;
    font-size: 16px;
    background-color: #007bff;
    color: #fff;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#send-btn:hover:not(:disabled) {
    background-color: #0056b3;
}

#send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.message {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user {
    align-self: flex-end;
    background-color: #007bff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.agent {
    align-self: flex-start;
    background-color: #cce5ff;
    color: #333;
    border-bottom-left-radius: 4px;
    white-space: normal;
}

/* Markdown styling for agent messages */
.message.agent p {
    margin: 0 0 0.75em 0;
}

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

.message.agent code {
    background-color: rgba(0, 0, 0, 0.08);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 0.9em;
}

.message.agent pre {
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75em 0;
}

.message.agent pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: 0.85em;
}

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

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

.message.agent h2, .message.agent h3, .message.agent h4 {
    margin: 0.75em 0 0.5em 0;
    font-weight: 600;
}

.message.agent h2 { font-size: 1.2em; }
.message.agent h3 { font-size: 1.1em; }
.message.agent h4 { font-size: 1em; }

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

.message.agent li {
    margin: 0.25em 0;
}

.message.agent a {
    color: #0056b3;
    text-decoration: underline;
}

.message.agent a:hover {
    color: #003d80;
}

.message.error {
    align-self: center;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    text-align: center;
    max-width: 90%;
}

.message.loading {
    align-self: flex-start;
    background-color: #e9ecef;
    color: #666;
    font-style: italic;
}

.message.loading::after {
    content: '';
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Action pills for agent suggestions */
.action-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.action-pill {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #007bff;
    background-color: #fff;
    border: 1px solid #007bff;
    border-radius: 20px;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    white-space: normal;
    text-align: left;
    max-width: 100%;
}

.action-pill:hover {
    background-color: #007bff;
    color: #fff;
}

.action-pill:active {
    background-color: #0056b3;
    border-color: #0056b3;
}

/* Product cards in chat messages */
.product-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0.75em 0;
}

.product-card {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 14px;
    transition: border-color 0.15s;
}

.product-card:hover {
    border-color: #007bff;
}

.product-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.product-card-name {
    font-weight: 600;
    font-size: 14px;
    color: #202123;
    flex: 1;
    min-width: 0;
}

.product-card-price {
    font-weight: 600;
    font-size: 14px;
    color: #007bff;
    white-space: nowrap;
    flex-shrink: 0;
}

.product-card-price-na {
    color: #999;
    font-weight: 400;
    font-style: italic;
    font-size: 12px;
}

.product-card-description {
    margin-top: 6px;
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Product catalog page */
#product-catalog {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.catalog-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.catalog-header h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #202123;
}

.catalog-header button {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
}

.catalog-header button:hover {
    background: #f3f4f6;
}

#catalog-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.catalog-grid .product-card {
    margin: 0;
}

.catalog-empty, .catalog-error {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-style: italic;
}

.catalog-loading {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}
