/* ─── Cornerstone MONK Assistant - Styles ───────────────────── */

:root {
    --primary: #cf4364;
    --primary-dark: #b33a56;
    --primary-light: #fce4ec;
    --accent: #F59E0B;
    --bg: #F8FAFC;
    --bg-card: #FFFFFF;
    --text: #1E293B;
    --text-light: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --success: #10B981;
    --error: #EF4444;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ─── Layout ──────────────────────────────────────── */

.app-container {
    display: flex;
    height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────── */

.sidebar {
    width: 280px;
    background: var(--text);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    width: 36px;
    height: 36px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-header .subtitle {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
}

.sidebar.collapsed .sidebar-header h1,
.sidebar.collapsed .sidebar-header .subtitle {
    display: none;
}

.new-chat-btn {
    margin: 16px 20px;
    padding: 10px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: var(--primary-dark);
}

.sidebar.collapsed .new-chat-btn span {
    display: none;
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
}

.conv-item {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-bottom: 2px;
    font-size: 13px;
    color: rgba(255,255,255,0.7);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: all 0.15s;
}

.conv-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.conv-item.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* ─── Right-Click Context Menu ────────────────────── */

.conv-context-menu {
    position: fixed;
    z-index: 9999;
    min-width: 180px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 4px 0;
    animation: ctxFadeIn 0.12s ease;
}

@keyframes ctxFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

.ctx-menu-item {
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.ctx-menu-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.ctx-icon {
    font-size: 14px;
    width: 18px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error);
}

.status-dot.online {
    background: var(--success);
}

.sidebar.collapsed .conversations-list,
.sidebar.collapsed .sidebar-footer .status-text {
    display: none;
}

/* ─── Main Chat Area ──────────────────────────────── */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 16px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    z-index: 10;
}

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

.toggle-sidebar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 20px;
    transition: background 0.15s;
}

.toggle-sidebar-btn:hover {
    background: var(--bg);
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.chat-header-right {
    display: flex;
    gap: 8px;
}

.header-btn {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-light);
    transition: all 0.15s;
}

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

/* ─── User Dropdown Menu ──────────────────────────── */

.user-dropdown {
    position: relative;
}

.user-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    font-family: inherit;
    transition: all 0.15s;
}

.user-dropdown-btn:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.user-dropdown-btn .user-icon {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: white;
}

.user-dropdown-btn .user-icon svg {
    fill: white;
    width: 14px;
    height: 14px;
}

.user-dropdown-btn .user-dropdown-name {
    font-weight: 500;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-btn .dropdown-arrow {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.user-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.user-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 240px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.user-dropdown.open .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
}

.dropdown-user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    color: white;
}

.dropdown-user-avatar svg {
    fill: white;
    width: 20px;
    height: 20px;
}

.dropdown-user-details {
    flex: 1;
    min-width: 0;
}

.dropdown-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-user-email {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: var(--bg);
}

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

.dropdown-item-danger {
    color: var(--error);
}

.dropdown-item-danger:hover {
    background: #FEF2F2;
}

/* ─── Modal Styles ────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: modalFadeIn 0.2s ease;
}

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

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    margin: 24px;
    animation: modalSlideIn 0.2s ease;
}

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

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.15s;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

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

.modal-btn-primary:hover {
    background: var(--primary-dark);
}

.modal-btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.modal-btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.modal-btn-secondary:hover {
    background: var(--border);
}

.modal-error {
    background: #FEF2F2;
    color: var(--error);
    border: 1px solid #FECACA;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

.modal-success {
    background: #F0FDF4;
    color: #16A34A;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* Profile Modal */
.profile-avatar {
    width: 80px;
    height: 80px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin: 0 auto 20px;
}

.profile-field {
    margin-bottom: 16px;
}

.profile-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.profile-field .profile-value {
    font-size: 14px;
    color: var(--text);
    padding: 8px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

/* Modal form groups */
.modal-body .form-group {
    margin-bottom: 16px;
}

.modal-body .form-group:last-child {
    margin-bottom: 0;
}

.modal-body .form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.modal-body .form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    outline: none;
    box-sizing: border-box;
}

.modal-body .form-group input:focus {
    border-color: var(--primary);
    background: white;
}

/* Stats Modal */
.modal-content-wide {
    max-width: 500px;
}

.stats-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.stats-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.stats-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg);
    border-radius: var(--radius-sm);
}

.stat-item .stat-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.stat-item .stat-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-light);
}

.stat-item .stat-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

/* ─── Response Cards & Tables ─────────────────────────────── */

.response-with-collapsible {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.response-intro {
    margin-bottom: 0;
    padding: 12px 16px;
    background: #F8FAFC;
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.response-intro p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
}

/* View Details Button */
.view-details-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    align-self: flex-start;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.view-details-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.view-details-btn.expanded {
    background: var(--primary-dark);
}

.view-details-btn .btn-icon {
    font-size: 14px;
}

.view-details-btn .btn-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.view-details-btn.expanded .btn-arrow {
    transform: rotate(180deg);
}

/* Collapsible Content */
.collapsible-content {
    overflow-y: auto;
    max-height: 400px;
    opacity: 1;
    transition: max-height 0.4s ease, opacity 0.3s ease;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
    border-color: transparent;
    overflow: hidden;
}

.collapsible-content::-webkit-scrollbar {
    width: 6px;
}

.collapsible-content::-webkit-scrollbar-track {
    background: var(--bg);
    border-radius: 3px;
}

.collapsible-content::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 3px;
}

.collapsible-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}

.response-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.response-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.response-card .card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.response-card .card-header .card-icon {
    font-size: 20px;
}

.response-card .card-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

.response-card .card-body {
    padding: 16px;
}

/* Occupancy card specific */
.occupancy-cards {
    gap: 12px;
}

.occupancy-card .card-header {
    padding: 10px 16px;
}

.occupancy-card .card-header h4 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.occupancy-card .card-body {
    padding: 10px 16px 14px;
}

.occupancy-card .data-table .label-cell {
    width: 130px;
    font-weight: 600;
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 0;
}

.occupancy-card .data-table .value-cell {
    font-size: 13px;
    padding: 5px 0;
}

.occupancy-card .occupancy-pct strong {
    font-size: 16px;
    color: var(--primary);
}

/* Property card specific */
.property-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* Tenant card specific */
.tenant-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.tenant-card .tenant-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.tenant-card .tenant-avatar {
    width: 48px;
    height: 48px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.tenant-card .tenant-details {
    flex: 1;
}

.tenant-card .tenant-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.tenant-card .tenant-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 4px;
}

.tenant-status.status-currently-living {
    background: #D1FAE5;
    color: #065F46;
}

.tenant-status.status-moving-out {
    background: #FEF3C7;
    color: #92400E;
}

.tenant-status.status-past {
    background: #F3F4F6;
    color: #6B7280;
}

/* Vacant property styling */
.vacant-header {
    background: linear-gradient(135deg, #6B7280 0%, #4B5563 100%) !important;
}

.vacant-badge {
    display: inline-block;
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 12px;
    margin-left: auto;
}

/* Lease card specific */
.lease-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.lease-expiry-summary {
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lease-expiry-summary.expiry-future {
    background: #EFF6FF;
    color: #1D4ED8;
    border: 1px solid #BFDBFE;
}

.lease-expiry-summary.expiry-today {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #FCD34D;
}

.lease-expiry-summary.expiry-past {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FECACA;
}

/* Certificate card specific */
.certificate-card .card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* Data table styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table tr {
    border-bottom: 1px solid var(--border);
}

.data-table tr:last-child {
    border-bottom: none;
}

.data-table td {
    padding: 10px 8px;
    font-size: 13px;
}

.data-table .label-cell {
    color: var(--text-light);
    white-space: nowrap;
    width: 40%;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-table .field-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

.data-table .value-cell {
    color: var(--text);
    font-weight: 500;
    word-break: break-word;
}

.data-table .value-cell a {
    color: var(--primary);
    text-decoration: none;
}

.data-table .value-cell a:hover {
    text-decoration: underline;
}

.data-table .value-cell.highlight-date {
    color: var(--primary);
    font-weight: 600;
}

.data-table.compact td {
    padding: 8px 6px;
    font-size: 12px;
}

/* Tabular results from dynamic_query — full-width data table */
.data-table-wrap {
    overflow-x: auto;
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg, #fff);
}

.results-table {
    border-collapse: collapse;
    min-width: 100%;
    font-size: 13px;
}

.results-table thead {
    background: var(--primary, #c5375f);
    color: #fff;
}

.results-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.results-table tbody td {
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: top;
    word-break: break-word;
}

.results-table tbody tr:nth-child(even) {
    background: rgba(0, 0, 0, 0.02);
}

.results-table tbody tr:hover {
    background: rgba(197, 55, 95, 0.05);
}

.results-table tbody tr:last-child td {
    border-bottom: none;
}

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

.results-table a:hover {
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .response-card .card-header {
        padding: 12px 14px;
    }
    
    .response-card .card-body {
        padding: 12px;
    }
    
    .data-table .label-cell {
        width: 35%;
    }
    
    .data-table td {
        padding: 8px 4px;
        font-size: 12px;
    }
}

/* ─── Messages ────────────────────────────────────── */

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

.messages-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

/* Welcome screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.welcome-screen .welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.welcome-screen p {
    color: var(--text-light);
    max-width: 460px;
    line-height: 1.6;
    margin-bottom: 32px;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 600px;
    width: 100%;
}

.suggestion-card {
    padding: 14px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
    transition: all 0.15s;
}

.suggestion-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.suggestion-card .icon {
    margin-bottom: 6px;
    font-size: 18px;
}

/* Message bubbles */
.message {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

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

.message.user .message-avatar svg {
    fill: white;
    width: 16px;
    height: 16px;
}

.message.assistant .message-avatar {
    background: var(--accent);
    color: white;
}

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

.message-content .sender {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.message-content .text {
    font-size: 14px;
    line-height: 1.65;
    color: var(--text);
}

.message-content .text p {
    margin-bottom: 8px;
}

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

.message-content .text ul,
.message-content .text ol {
    padding-left: 20px;
    margin-bottom: 8px;
}

.message-content .meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    align-items: center;
}

.message-content .meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: var(--bg);
    border-radius: 12px;
    font-size: 10px;
}

.message-content .meta .meta-intent {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.message-content .meta .meta-speed {
    background: #FEF3C7;
    color: #92400E;
}

.message-content .meta .meta-time {
    background: #F1F5F9;
    color: var(--text-light);
}

.typing-indicator-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-timer {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    padding: 4px 10px;
    background: #FEF3C7;
    color: #92400E;
    border-radius: 12px;
    animation: pulse-timer 2s infinite;
}

@keyframes pulse-timer {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* ─── Input Area ──────────────────────────────────── */

.input-area {
    padding: 16px 24px 24px;
    background: var(--bg);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.input-box {
    display: flex;
    align-items: flex-end;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    transition: border-color 0.2s;
    overflow: visible;
}

.input-box:focus-within {
    border-color: var(--primary);
}

.input-box textarea {
    flex: 1;
    padding: 14px 16px;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    min-height: 48px;
    max-height: 160px;
    line-height: 1.5;
    background: transparent;
}

/* ─── Mode Selector ──────────────────────────────── */

.mode-selector {
    position: relative;
    display: flex;
    align-items: center;
    align-self: center;
    margin-right: 4px;
}

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s;
    white-space: nowrap;
    line-height: 1;
}

.mode-toggle:hover {
    border-color: var(--text-light);
    color: var(--text-light);
    background: var(--bg);
}

.mode-toggle.mode-dynamic {
    border-color: var(--text-light);
    color: var(--text-light);
}

.mode-toggle.mode-gpu {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

.mode-icon {
    font-size: 11px;
}

.mode-label {
    font-size: 11px;
}

.mode-arrow {
    font-size: 8px;
    transition: transform 0.2s;
    margin-left: 2px;
}

.mode-selector.open .mode-arrow {
    transform: rotate(180deg);
}

.mode-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 260px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px);
    transition: all 0.15s ease;
}

.mode-selector.open .mode-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mode-option {
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.mode-option:last-child {
    border-bottom: none;
}

.mode-option:first-child {
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.mode-option:last-child {
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.mode-option:hover {
    background: var(--bg);
}

.mode-option.active {
    background: var(--bg);
    border-left: 3px solid var(--text-light);
}

.mode-option-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}

.mode-option-icon {
    font-size: 14px;
}

.mode-option-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.mode-badge {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: auto;
    background: var(--bg);
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.mode-badge-fast {
    background: var(--bg);
    color: var(--text-muted);
}

.mode-badge-ai {
    background: var(--bg);
    color: var(--text-muted);
}

.mode-badge-gpu {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border-color: rgba(16, 185, 129, 0.3);
}

.mode-option-desc {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    padding-left: 20px;
}

/* ─── Mode indicator in meta ──────────────────────── */

.message-content .meta .meta-mode {
    background: var(--bg);
    color: var(--text-muted);
}

.message-content .meta .meta-mode-dynamic {
    background: rgba(139, 92, 246, 0.08);
    color: #8b5cf6;
}

.message-content .meta .meta-mode-gpu {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
}

.message-content .meta .meta-mode.meta-mode-auto {
    background: var(--bg);
    color: var(--text-muted);
}

.send-btn {
    padding: 10px 16px;
    margin: 6px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.send-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ─── Responsive ──────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        z-index: 100;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .suggestion-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Scrollbar ───────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ─── Markdown rendering in messages ──────────────── */

.message-content .text code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.message-content .text pre {
    background: var(--text);
    color: #E2E8F0;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
}

.message-content .text pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ─── Auth Pages (Login / Register) ───────────────── */

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1E293B 0%, #0F172A 100%);
    padding: 24px;
    overflow: auto;
}

.auth-card {
    background: var(--bg-card);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.auth-header {
    margin-bottom: 24px;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: var(--primary-light);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 12px;
}

.auth-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.auth-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.auth-card h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.auth-desc {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 24px;
}

.auth-error {
    background: #FEF2F2;
    color: var(--error);
    border: 1px solid #FECACA;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

.auth-form {
    text-align: left;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group label .optional {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 11px;
}

.form-group input {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color 0.2s;
    outline: none;
    box-sizing: border-box;
}

.form-group input:focus {
    border-color: var(--primary);
    background: white;
}

.form-group input::placeholder {
    color: var(--text-muted);
}

/* Password input with toggle */
.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.password-input-wrapper input {
    width: 100%;
    padding-right: 44px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    opacity: 0.6;
    transition: opacity 0.15s;
}

.password-toggle:hover {
    opacity: 1;
}

.password-toggle .eye-icon {
    font-size: 16px;
    position: relative;
    display: inline-block;
}

.password-toggle.visible .eye-icon::after {
    content: '';
    position: absolute;
    left: -2px;
    top: 50%;
    width: calc(100% + 4px);
    height: 2px;
    background: var(--text);
    transform: rotate(-45deg);
}

.auth-submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background 0.2s;
}

.auth-submit-btn:hover {
    background: var(--primary-dark);
}

.auth-submit-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.auth-footer {
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-light);
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

/* ─── Auth success message ────────────────────────── */

.auth-success {
    background: #F0FDF4;
    color: #16A34A;
    border: 1px solid #BBF7D0;
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: center;
    font-weight: 500;
}

/* ─── OTP Verification Step ───────────────────────── */

.otp-icon {
    width: 64px;
    height: 64px;
    background: #EFF6FF;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 16px;
}

.otp-input-group {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 24px 0;
}

.otp-box {
    width: 48px;
    height: 56px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: 'Inter', monospace;
    font-size: 22px;
    font-weight: 600;
    text-align: center;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    -moz-appearance: textfield;
}

.otp-box::-webkit-inner-spin-button,
.otp-box::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.otp-box:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.otp-dash {
    color: var(--text-muted);
    font-size: 18px;
    margin: 0 2px;
}

.otp-timer {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 16px;
}

.otp-timer span {
    font-weight: 600;
    color: var(--primary);
}

/* ─── User info in sidebar ────────────────────────── */

.user-info {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.user-info .user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.user-info .user-avatar svg,
.user-info .user-avatar .user-avatar-icon {
    fill: white;
    color: white;
    width: 16px;
    height: 16px;
}

.user-info .user-details {
    flex: 1;
    min-width: 0;
}

.user-info .user-name {
    font-size: 13px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .user-email {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.6);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    transition: all 0.15s;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: rgba(255,255,255,0.4);
}

.sidebar.collapsed .user-info .user-details,
.sidebar.collapsed .user-info .logout-btn {
    display: none;
}

/* ─── Model Profile Switcher ──────────────────────── */

.model-switcher {
    position: relative;
}

.model-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    transition: all 0.2s;
    white-space: nowrap;
}

.model-toggle-btn:hover {
    border-color: var(--primary);
    background: var(--bg);
}

.model-toggle-btn.switching {
    opacity: 0.6;
    pointer-events: none;
}

.model-toggle-btn.profile-balanced {
    border-color: #10b981;
    color: #065f46;
    background: rgba(16, 185, 129, 0.06);
}

.model-toggle-btn.profile-accuracy {
    border-color: #8b5cf6;
    color: #5b21b6;
    background: rgba(139, 92, 246, 0.06);
}

.model-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}

.model-status-dot.dot-balanced {
    background: #10b981;
    box-shadow: 0 0 4px rgba(16, 185, 129, 0.5);
}

.model-status-dot.dot-accuracy {
    background: #8b5cf6;
    box-shadow: 0 0 4px rgba(139, 92, 246, 0.5);
}

.model-arrow {
    font-size: 9px;
    color: var(--text-muted);
    transition: transform 0.2s;
}

.model-switcher.open .model-arrow {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
}

.model-switcher.open .model-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-dropdown-header {
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.model-option:last-child {
    border-bottom: none;
}

.model-option:hover {
    background: var(--bg);
}

.model-option.active {
    background: var(--bg);
}

.model-option-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.model-opt-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.model-opt-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.model-opt-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
}

.model-opt-check {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    min-width: 18px;
    text-align: center;
}

@media (max-width: 768px) {
    .model-profile-name {
        display: none;
    }
    .model-toggle-btn {
        padding: 6px 8px;
    }
}

/* ─── Response Feedback ─────────────────────────────────── */

.feedback-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.feedback-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.feedback-btn:hover {
    border-color: var(--text-light);
    color: var(--text);
    background: #f1f5f9;
}

.feedback-btn.fb-like:hover,
.feedback-btn.fb-like.fb-active {
    color: var(--success);
    border-color: var(--success);
    background: #ecfdf5;
}

.feedback-btn.fb-dislike:hover,
.feedback-btn.fb-dislike.fb-active {
    color: var(--error);
    border-color: var(--error);
    background: #fef2f2;
}

.feedback-btn.fb-comment:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}

.feedback-btn:disabled {
    opacity: 0.5;
    cursor: default;
    pointer-events: none;
}

.feedback-submitted .feedback-btn:not(.fb-active) {
    opacity: 0.35;
}

.feedback-comment-box {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-top: 6px;
    width: 100%;
}

.feedback-comment-input {
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    width: 360px;
    max-width: 70vw;
    min-height: 60px;
    max-height: 120px;
    font-family: inherit;
    color: var(--text);
    resize: vertical;
    line-height: 1.4;
}

.feedback-comment-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(207, 67, 100, 0.1);
}

.feedback-comment-submit {
    font-size: 11px;
    padding: 4px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
}

.feedback-comment-submit:hover {
    background: var(--primary-dark);
}

.feedback-status {
    font-size: 11px;
    margin-left: 4px;
}

.feedback-status-ok {
    color: var(--success);
}

.feedback-status-err {
    color: var(--error);
}
