/* Guideline Advisor - Clinical UI Styles */

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

:root {
    /* Primary Colors - Clinical Blue Scheme */
    --primary-blue: #1e40af;
    --primary-blue-dark: #1e3a8a;
    --primary-blue-light: #3b82f6;
    --primary-blue-hover: #2563eb;
    
    /* Background Colors */
    --bg-light: #f1f5f9;
    --bg-white: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-header: #ffffff;
    
    /* Text Colors */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Border & Divider Colors */
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --divider-color: #e2e8f0;
    
    /* UI Colors */
    --border-radius: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    /* Status Colors */
    --success-green: #059669;
    --warning-yellow: #d97706;
    --error-red: #dc2626;
    --info-blue: #0284c7;
    
    /* Chat Colors */
    --chat-user-bg: #1e40af;
    --chat-assistant-bg: #f8fafc;
    --chat-border: #e2e8f0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: linear-gradient(180deg, #f9fafb 0%, #eef2ff 45%, #e0f2fe 100%);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-blue);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.sidebar-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

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

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 0 20px;
    margin-bottom: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    padding: 10px 18px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    border-radius: 999px;
    margin: 4px 10px;
    position: relative;
}

.sidebar-link:hover {
    background: rgba(59, 130, 246, 0.08);
    color: var(--primary-blue);
    border-left-color: transparent;
}

.sidebar-link.active {
    background: linear-gradient(90deg, #4f46e5 0%, #3b82f6 50%, #0ea5e9 100%);
    color: #ffffff;
    border-left-color: transparent;
    font-weight: 600;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.35);
}

.sidebar-link::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #cbd5f5;
    margin-right: 10px;
    flex-shrink: 0;
}

.sidebar-link.active::before {
    background: #ffffff;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

/* Message Icon Link */
.message-icon-link,
.notification-icon-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}

.message-icon-link:hover,
.notification-icon-link:hover {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.message-icon-link:active,
.notification-icon-link:active {
    transform: translateY(0);
}

.message-icon-link svg,
.notification-icon-link svg {
    width: 20px;
    height: 20px;
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    border: 2px solid white;
}

.content-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    padding: 20px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

.content-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.content-body {
    padding: 32px;
    max-width: 1400px;
}

/* Cards */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Generic clinical card wrapper (used in admin dashboard sections) */
.clinical-card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 22px;
    border: 1px solid var(--border-color);
}

/* Simple status badges (used in admin guidelines) */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}

.status-active {
    background: #dcfce7;
    color: #166534;
}

.status-demo {
    background: #fee2e2;
    color: #b91c1c;
}

/* Buttons */
.btn,
.btn-primary,
.btn-secondary,
.btn-success,
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background: linear-gradient(90deg, #4f46e5 0%, #3b82f6 50%, #0ea5e9 100%);
    color: white;
    font-weight: 500;
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(90deg, #4338ca 0%, #2563eb 50%, #0284c7 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: linear-gradient(135deg, #e5f2ff, #e0f2fe);
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #dbeafe, #bae6fd);
}

.btn-success {
    background: var(--success-green);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #f97316, #ef4444);
    color: white;
}

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

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

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--bg-white);
    color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-error {
    color: var(--error-red);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: var(--success-green);
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: var(--error-red);
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-color: var(--warning-yellow);
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-color: var(--info-blue);
}

/* Disclaimer */
.disclaimer {
    background: #fffbeb;
    border-left: 4px solid var(--warning-yellow);
    padding: 12px 16px;
    margin: 16px 0;
    font-size: 13px;
    color: #78350f;
    border-radius: 4px;
    font-weight: 400;
}

/* Chat Interface - ChatGPT-style with project colors */
.chat-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
}

.chat-main {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 100%;
}

.chat-container {
    display: flex;
    flex-direction: column;
    padding: 0 24px 24px;
    min-height: 0;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

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

.chat-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.02em;
}

.chat-date {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-badge {
    margin-left: 4px;
}

.chat-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chat-action-form {
    display: inline;
}

.btn-chat-secondary {
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--primary-blue-light);
    color: #fff;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-chat-secondary:hover {
    background: var(--primary-blue-hover);
}

a.btn-chat-secondary {
    align-items: center;
}

.btn-chat-clear {
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--error-red);
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: opacity 0.2s;
}

.btn-chat-clear:hover {
    opacity: 0.9;
}

.chat-messages {
    flex: 1 1 auto;
    min-height: 280px;
    max-height: calc(100vh - 320px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px 0 20px;
    margin-bottom: 20px;
}

.chat-welcome {
    text-align: center;
    padding: 48px 24px 32px;
    max-width: 560px;
    margin: 0 auto;
}

.chat-welcome-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.chat-welcome-desc {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 24px;
}

.chat-welcome .disclaimer {
    margin: 24px auto 0;
    max-width: 480px;
    text-align: left;
}

.chat-input-card {
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--bg-white);
    padding: 20px 24px;
    box-shadow: var(--shadow-sm);
}

.chat-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.chat-input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-input-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.chat-input-hint {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-textarea {
    width: 100%;
    min-height: 100px;
    max-height: 240px;
    padding: 14px 18px;
    font-size: 15px;
    line-height: 1.6;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    resize: vertical;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-textarea::placeholder {
    color: var(--text-muted);
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--primary-blue-light);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.chat-form-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.chat-features {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.chat-feature {
    font-size: 13px;
    color: var(--text-secondary);
}

.chat-feature-check {
    color: var(--primary-blue);
    margin-right: 6px;
}

.chat-submit-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.chat-guideline-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-guideline-label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.chat-guideline-select {
    min-width: 180px;
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
}

.chat-guideline-select:focus {
    outline: none;
    border-color: var(--primary-blue-light);
}

.btn-chat-send {
    padding: 12px 24px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    background: var(--primary-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

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

.chat-send-icon {
    font-size: 16px;
    line-height: 1;
}

.message {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
}

.message-user {
    text-align: right;
}

.message-user .message-content {
    display: inline-block;
    background: var(--chat-user-bg);
    color: #fff;
    padding: 14px 18px;
    border-radius: 18px 18px 4px 18px;
    max-width: 75%;
    text-align: left;
    font-weight: 400;
    font-size: 15px;
    line-height: 1.5;
}

.message-assistant .message-content {
    background: var(--chat-assistant-bg);
    padding: 14px 18px;
    border-radius: 18px 18px 18px 4px;
    line-height: 1.6;
    white-space: pre-wrap;
    border: 1px solid var(--chat-border);
    font-size: 15px;
}

.message-time {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Chat search bar (filter messages, previous/next) */
.chat-search-bar {
    padding: 12px 0 14px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

.chat-search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.chat-search-input {
    flex: 1;
    min-width: 180px;
    padding: 10px 14px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-white);
    color: var(--text-primary);
}

.chat-search-input:focus {
    outline: none;
    border-color: var(--primary-blue-light);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.chat-search-clear,
.chat-search-prev,
.chat-search-next {
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.chat-search-clear:hover,
.chat-search-prev:hover:not(:disabled),
.chat-search-next:hover:not(:disabled) {
    background: var(--bg-light);
    border-color: var(--primary-blue-light);
}

.chat-search-prev:disabled,
.chat-search-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.chat-search-nav {
    display: flex;
    gap: 6px;
}

.message.chat-search-hidden {
    display: none !important;
}

.message.chat-search-current {
    scroll-margin-top: 12px;
    scroll-margin-bottom: 12px;
}

/* Links inside chat messages (linkified URLs) */
.chat-message-link {
    color: var(--primary-blue);
    text-decoration: underline;
    word-break: break-all;
}

.chat-message-link:hover {
    color: var(--primary-blue-dark);
}

/* Arrow button – fixed on right edge of screen, vertically centered */
.chat-history-arrow-fixed {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999;
}

.chat-history-arrow-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 80px;
    padding: 0;
    border: none;
    border-radius: 12px 0 0 12px;
    background: var(--primary-blue-light);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.12);
}

.chat-history-arrow-btn:hover {
    background: var(--primary-blue-hover);
}

.chat-history-arrow-icon {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    user-select: none;
}

/* Right sidebar – chat history (slides in from right) */
.chat-history-sidebar-wrap {
    position: fixed;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
}

.chat-history-sidebar-wrap.open {
    pointer-events: auto;
}

.chat-history-sidebar-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.chat-history-sidebar-wrap.open .chat-history-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    cursor: pointer;
}

.chat-history-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 90vw;
    background: var(--bg-white);
    border-left: 1px solid var(--border-color);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    padding: 16px 14px;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 1001;
}

.chat-history-sidebar-wrap.open .chat-history-sidebar {
    transform: translateX(0);
}

.chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 4px 6px 8px;
}

.chat-sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.chat-sidebar-toggle-icon {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 999px;
    color: var(--text-secondary);
}

.chat-sidebar-toggle-icon:hover {
    background: #eff6ff;
    color: var(--primary-blue);
}

.chat-sidebar-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-sidebar-item {
    display: block;
    padding: 8px 10px;
    border-radius: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    border: 1px solid transparent;
}

.chat-sidebar-item:hover {
    background: #eff6ff;
    border-color: #dbeafe;
}

.chat-sidebar-item.active {
    background: var(--primary-blue);
    border-color: var(--primary-blue);
    color: #ffffff;
}

.chat-sidebar-item-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.chat-sidebar-item-meta {
    font-size: 11px;
    color: var(--text-muted);
}

.chat-sidebar-item.active .chat-sidebar-item-meta {
    color: #e0f2fe;
}

.chat-sidebar-empty {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 10px;
}

/* Citations */
.citations {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.citations-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.citations-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.citations-list li {
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-cols-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 32px; }

.flex { display: flex; }

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.gap-8 { gap: 32px; }

/* Admin tables - shared patterns */
.admin-users-table-wrapper,
.admin-packages-table-wrapper {
    width: 100%;
}

.admin-users-table th,
.admin-users-table td,
.admin-packages-table th,
.admin-packages-table td {
    white-space: nowrap;
}

/* Chat history delete icon button */
.chat-history-delete-btn {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
}

.chat-history-delete-btn:hover {
    color: #dc2626;
    border-color: #fecaca;
    background: #fef2f2;
    box-shadow: var(--shadow-sm);
}

.chat-history-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    text-decoration: none;
}

.chat-history-icon-btn:hover {
    color: var(--primary-blue);
    border-color: #bfdbfe;
    box-shadow: var(--shadow-sm);
}

.chat-history-pin-btn-active {
    color: #f59e0b;
    border-color: #facc15;
    background: #fffbeb;
}

/* Guideline action buttons */
.guideline-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    text-decoration: none;
}

.guideline-icon-btn:hover {
    color: var(--primary-blue);
    border-color: #bfdbfe;
    box-shadow: var(--shadow-sm);
}

.guideline-delete-btn {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    padding: 0;
}

.guideline-delete-btn:hover {
    color: var(--error-red);
    border-color: #fca5a5;
    background: #fee2e2;
    box-shadow: var(--shadow-sm);
}

/* Analytics filters */
.admin-analytics-filters {
    flex-wrap: wrap;
}

.admin-analytics-filter-btn {
    align-self: flex-end;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
        z-index: 40;
        top: 64px;
        height: calc(100vh - 64px);
    }

    .main-content {
        margin-left: 0;
        min-width: 0;
        overflow-x: hidden;
    }

    .content-body {
        padding: 12px 16px;
        min-width: 0;
        overflow-x: hidden;
    }

    .content-header {
        padding: 16px 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .content-title {
        font-size: 20px;
    }

    /* Chat mobile */
    .chat-layout {
        flex-direction: column;
        gap: 12px;
        padding: 0 4px;
    }

    .chat-main {
        width: 100%;
    }

    .chat-container {
        padding: 0 16px 16px;
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 16px;
        margin: 0 -16px 0;
        margin-bottom: 12px;
        padding-bottom: 12px;
    }

    .chat-header-main {
        gap: 8px;
    }

    .chat-title {
        font-size: 17px;
    }

    .chat-date {
        font-size: 12px;
    }

    .chat-actions {
        width: 100%;
    }

    .chat-search-bar {
        padding: 10px 0 12px;
    }

    .chat-search-row {
        flex-wrap: wrap;
    }

    .chat-search-input {
        font-size: 16px;
        min-width: 0;
    }

    .chat-messages {
        min-height: 200px;
        max-height: none;
        overflow-y: visible;
        padding: 16px 0 14px;
    }

    .chat-welcome {
        padding: 28px 20px 24px;
    }

    .chat-welcome-title {
        font-size: 20px;
    }

    .chat-welcome-desc {
        font-size: 14px;
    }

    .chat-input-card {
        padding: 18px 20px;
    }

    .chat-form-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-submit-row {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-guideline-wrap {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    .chat-guideline-select {
        width: 100%;
        min-width: 0;
    }

    .btn-chat-send {
        width: 100%;
        justify-content: center;
    }

    .message-user .message-content,
    .message-assistant .message-content {
        max-width: 92%;
        padding: 12px 14px;
        font-size: 14px;
    }

    .chat-history-sidebar {
        max-width: 320px;
    }

    .chat-history-arrow-fixed {
        right: 8px;
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-cols-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Mobile sidebar toggle */
.sidebar-toggle {
    display: none;
    position: static;
    z-index: 1;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    color: #000;
}

/* Remove old bar styles; now using SVG icon */

@media (max-width: 1024px) {
    .sidebar-toggle {
        display: inline-flex;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.35);
    }

    .content-header {
        position: sticky;
        top: 0;
        z-index: 60;
    }

    .main-content {
        min-width: 0;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .content-body {
        min-width: 0;
        overflow-x: hidden;
        overflow-y: visible;
    }

    .chat-layout {
        gap: 16px;
    }

    /* Let the page scroll on tablet so user can scroll down (iPad fix) */
    .chat-messages {
        max-height: none;
        overflow-y: visible;
        -webkit-overflow-scrolling: auto;
    }

    .chat-container {
        padding: 0 20px 20px;
    }
}

@media (max-width: 640px) {
    body {
        font-size: 13px;
    }

    .content-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        padding: 12px 12px;
    }

    .content-body {
        padding: 12px;
    }

    .chat-container {
        padding: 0 16px 16px;
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .chat-input-card {
        padding: 16px;
    }

    .chat-form-footer {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-submit-row {
        flex-direction: column;
    }

    .chat-guideline-wrap {
        width: 100%;
    }

    .chat-guideline-select {
        flex: 1;
        min-width: 0;
    }

    .chat-messages {
        max-height: none;
        overflow-y: visible;
        padding: 16px 0;
    }

    .message-user .message-content {
        max-width: 90%;
    }

    .flex-between {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .grid,
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr));
    }

    .admin-analytics-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .admin-analytics-filters .form-group {
        width: 100%;
        max-width: 260px;
    }

    .admin-analytics-filters .form-label {
        text-align: left;
        width: 100%;
    }

    .admin-analytics-filter-btn {
        width: 100%;
        max-width: 260px;
        justify-content: center;
    }

    .admin-users-table-wrapper,
    .admin-packages-table-wrapper {
        overflow-x: visible;
    }

    .admin-users-table,
    .admin-users-table thead,
    .admin-users-table tbody,
    .admin-users-table th,
    .admin-users-table td,
    .admin-users-table tr,
    .admin-packages-table,
    .admin-packages-table thead,
    .admin-packages-table tbody,
    .admin-packages-table th,
    .admin-packages-table td,
    .admin-packages-table tr {
        display: block;
        width: 100%;
    }

    .admin-users-table thead,
    .admin-packages-table thead {
        display: none;
    }

    .admin-users-table tr,
    .admin-packages-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background: var(--bg-white);
        overflow: hidden;
    }

    .admin-users-table td,
    .admin-packages-table td {
        padding: 8px 12px;
        text-align: left !important;
        white-space: normal;
        position: relative;
        border-bottom: 1px solid var(--border-light);
    }

    .admin-users-table td:last-child,
    .admin-packages-table td:last-child {
        border-bottom: none;
    }

    .admin-users-table td::before,
    .admin-packages-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 2px;
        font-size: 11px;
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.03em;
    }
}

@media (max-width: 480px) {
    .content-body {
        padding: 8px 12px;
    }

    .chat-layout {
        padding: 0;
    }

    .chat-main {
        border-radius: 8px;
        border-left: none;
        border-right: none;
    }

    .chat-container {
        padding: 0 12px 12px;
    }

    .chat-header {
        padding: 10px 12px;
        margin: 0 -12px 0;
        padding-bottom: 10px;
    }

    .chat-title {
        font-size: 16px;
    }

    .btn-chat-secondary,
    .btn-chat-clear {
        padding: 6px 10px;
        font-size: 11px;
    }

    .chat-search-bar {
        padding: 8px 0;
    }

    .chat-search-clear {
        width: 100%;
    }

    .chat-messages {
        min-height: 180px;
        max-height: none;
    }

    .chat-welcome {
        padding: 24px 16px 20px;
    }

    .chat-welcome-title {
        font-size: 18px;
    }

    .chat-input-card {
        padding: 14px 16px;
    }

    .chat-textarea {
        min-height: 88px;
        padding: 12px 14px;
        font-size: 16px;
    }

    .message-user .message-content,
    .message-assistant .message-content {
        max-width: 95%;
        padding: 10px 12px;
        font-size: 13px;
    }
}

/* Pagination (Bootstrap 5 view, no framework) - scope to main content only */
.content-body nav .d-flex { display: flex; }
.content-body nav .d-none { display: none; }
.content-body nav .d-sm-flex { display: none; }
.content-body nav .flex-fill { flex: 1 1 auto; }
.content-body nav .small { font-size: 12px; }
.content-body nav .text-muted { color: var(--text-muted); }
.content-body nav .fw-semibold { font-weight: 600; }
@media (min-width: 576px) {
    .content-body nav .d-sm-none { display: none; }
    .content-body nav .d-sm-flex { display: flex; }
    .content-body nav .flex-sm-fill { flex: 1 1 auto; }
    .content-body nav .align-items-sm-center { align-items: center; }
    .content-body nav .justify-content-sm-between { justify-content: space-between; }
}
.content-body nav .justify-content-between { justify-content: space-between; }
.content-body nav .justify-items-center { justify-items: center; }

.content-body .pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.content-body .page-item {
    list-style: none;
}

.content-body .page-link {
    display: inline-block;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--primary-blue);
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    min-width: 40px;
    text-align: center;
}

.content-body .page-link:hover {
    background: var(--bg-light);
    color: var(--primary-blue-dark);
    border-color: var(--primary-blue-light);
}

.content-body .page-item.disabled .page-link {
    color: var(--text-muted);
    pointer-events: none;
    background: var(--bg-light);
}

.content-body .page-item.active .page-link {
    background: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.content-body .page-item:not(:first-child) .page-link { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; }
.content-body .page-item:not(:last-child) .page-link { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.content-body .page-item:first-child .page-link { border-top-left-radius: 6px; border-bottom-left-radius: 6px; }
.content-body .page-item:last-child .page-link { border-top-right-radius: 6px; border-bottom-right-radius: 6px; }
