:root {
    --primary-color: #6c5ce7;
    --secondary-color: #a8a4e6;
    --background-color: #f8f9fa;
    --chat-bg: #ffffff;
    --user-msg-bg: #e9ecef;
    --assistant-msg-bg: #f8f9fa;
    --code-bg: #1e1e1e;
    --code-text: #d4d4d4;
}

body {
    font-family: 'Space Mono', monospace;
    background-color: var(--background-color);
    color: #333;
    line-height: 1.6;
}

.chat-container {
    background-color: var(--chat-bg);
    border-radius: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    height: 70vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.message {
    position: relative;
    margin-bottom: 1.5rem;
    padding: 1rem;
    border-radius: 0.75rem;
    max-width: 85%;
    transition: all 0.3s ease;
}

.message:hover .copy-button {
    opacity: 1;
}

.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 0.5rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.copy-button:hover {
    background: rgba(255, 255, 255, 1);
}

.user-message {
    background-color: var(--user-msg-bg);
    margin-left: auto;
    color: #2d3436;
}

.assistant-message {
    background-color: var(--assistant-msg-bg);
    margin-right: auto;
    color: #2d3436;
}

/* Code block styling */
pre[class*="language-"] {
    margin: 1rem 0;
    padding: 1rem !important;
    border-radius: 0.5rem;
    background: var(--code-bg) !important;
    border: 1px solid #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

code[class*="language-"] {
    font-family: 'Space Mono', monospace !important;
    padding: 0;
    color: var(--code-text) !important;
    text-shadow: none !important;
    font-size: 0.9rem;
}

/* Streaming code block effect */
.code-loading {
    position: relative;
    overflow: hidden;
}

.code-loading::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background-color: var(--primary-color);
    animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* Bootstrap overrides and custom components */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

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

.subject-badge {
    background-color: var(--secondary-color);
    color: white;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
}

.input-container {
    background-color: var(--chat-bg);
    border-radius: 1rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

textarea {
    font-family: 'Space Mono', monospace;
    resize: none;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
}

/* Prism.js toolbar customization */
div.code-toolbar>.toolbar {
    opacity: 0;
    transition: opacity 0.3s ease;
}

div.code-toolbar:hover>.toolbar {
    opacity: 1;
}

div.code-toolbar>.toolbar>.toolbar-item>button {
    background: none;
    border: none;
    color: #fff !important;
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    margin-right: 0.5rem;
}

div.code-toolbar>.toolbar>.toolbar-item>button::before {
    font-family: "Font Awesome 6 Free";
    content: "\f0c5";
    margin-right: 0.25rem;
}

/* Line numbers styling */
.line-numbers .line-numbers-rows {
    border-right: 2px solid #333;
    padding: 1rem 0;
}

.line-numbers-rows>span:before {
    color: #666;
}

/* Token colors for syntax highlighting */
.token.comment {
    color: #6a9955 !important;
}

.token.string {
    color: #ce9178 !important;
}

.token.number {
    color: #b5cea8 !important;
}

.token.keyword {
    color: #569cd6 !important;
}

.token.function {
    color: #dcdcaa !important;
}

.token.operator {
    color: #d4d4d4 !important;
}

.token.punctuation {
    color: #d4d4d4 !important;
}

/* Add smooth scrolling to body */
html {
    scroll-behavior: smooth;
}

/* Add transition for custom subject input */
#customSubject {
    max-height: 0;
    opacity: 0;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
    border: none;
}

#customSubject.show {
    max-height: 50px;
    opacity: 1;
    padding: 0.375rem 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
}

.disabled {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.disabled::after {
    content: '🔒';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    z-index: 1;
}

[data-feature].disabled::before {
    content: 'Premium Feature';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    text-align: center;
    padding: 0.5rem;
    z-index: 2;
}

/* Usage Indicator Styles */
.usage-indicator {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

.usage-indicator.success {
    border-color: #28a745;
}

.usage-indicator.warning {
    border-color: #ffc107;
    background-color: #fff8e1;
}

.usage-indicator.danger {
    border-color: #dc3545;
    background-color: #ffebee;
}

.usage-indicator.unlimited {
    border-color: #6f42c1;
    background-color: #f3e5f5;
}

.usage-indicator .progress {
    height: 8px;
}

/* Premium Feature Styles */
.premium-locked {
    position: relative;
    opacity: 0.7;
}

.premium-locked::after {
    content: "Premium Feature";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-weight: bold;
    border-radius: inherit;
}

/* Upgrade Modal Styles */
#upgradeModal .card {
    transition: transform 0.3s, box-shadow 0.3s;
}

#upgradeModal .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

#upgradeModal .price {
    font-size: 1.5rem;
    font-weight: bold;
    color: #6f42c1;
    margin-bottom: 15px;
}

#upgradeModal .border-primary {
    box-shadow: 0 0 15px rgba(111, 66, 193, 0.2);
}

/* Authentication pages */
.auth-container {
    max-width: 500px;
    margin: 0 auto;
}

/* Profile page */
#profileInfo input {
    background-color: #f8f9fa;
}

.usage-indicator .progress {
    height: 10px;
    border-radius: 5px;
    background-color: #e9ecef;
}

.usage-indicator.unlimited .progress-bar {
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
}

#messageHistory {
    /* max-height: 300px; */
    overflow-y: auto;
    border-radius: 0.5rem;
}

#messageHistory .list-group-item:first-child {
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

#messageHistory .list-group-item:last-child {
    border-bottom-left-radius: 0.5rem;
    border-bottom-right-radius: 0.5rem;
}

#messageHistory .list-group-item {
    transition: all 0.2s ease;
}

#messageHistory .list-group-item:hover {
    background-color: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Subscription card */
#subscriptionCard {
    border-left: 4px solid var(--primary-color);
}

.price {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.price span {
    font-size: 1rem;
    color: #6c757d;
}

/* Stripe Elements */
#cardElement {
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background-color: white;
}

/* Daily message limit alert */
.alert-warning {
    border-left: 4px solid #ffc107;
    background-color: #fff8e1;
}

.alert-warning h5 {
    color: #856404;
    display: flex;
    align-items: center;
}

.alert-warning h5 i {
    margin-right: 0.5rem;
}

.alert-warning .btn-primary {
    background-color: #ffc107;
    border-color: #ffc107;
    color: #212529;
}

.alert-warning .btn-primary:hover {
    background-color: #e0a800;
    border-color: #d39e00;
}

/* Navbar */
.navbar {
    border-radius: 0.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Message limit warning */
.limit-warning {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.25rem;
}

/* Subscription cancellation alert */
.alert-info {
    background-color: #e3f2fd;
    border-color: #90caf9;
    color: #0d47a1;
}

.alert-info h5 {
    color: #0d47a1;
    display: flex;
    align-items: center;
}

.alert-info h5 i {
    margin-right: 0.5rem;
}

.alert-info .btn-primary {
    background-color: #1976d2;
    border-color: #1976d2;
}

.alert-info .btn-primary:hover {
    background-color: #1565c0;
    border-color: #1565c0;
}

/* Favorite Subjects */
.favorite-subjects {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.subject-badge {
    display: flex;
    align-items: center;
    padding: 8px 15px;
    border-radius: 20px;
    font-weight: 500;
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.subject-badge.gold {
    background: linear-gradient(135deg, #f9d423 0%, #f83600 100%);
}

.subject-badge.silver {
    background: linear-gradient(135deg, #e6e6e6 0%, #b3b3b3 100%);
}

.subject-badge.bronze {
    background: linear-gradient(135deg, #cb8d6b 0%, #8c5c3d 100%);
}

.subject-badge i {
    margin-right: 8px;
    font-size: 14px;
}

.subject-badge .count {
    margin-left: 8px;
    background-color: rgba(255, 255, 255, 0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
}

.no-favorites {
    color: #6c757d;
    font-style: italic;
    text-align: center;
    padding: 10px;
}

/* History Panel */
.history-panel {
    position: fixed;
    top: 0;
    right: -350px; /* Start off-screen */
    width: 350px;
    height: 100vh;
    background-color: var(--chat-bg);
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.history-panel.open {
    right: 0; /* Slide in */
}

.history-header {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.history-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Message history items */
#messageHistory .list-group-item {
    border-left: none;
    border-right: none;
    border-radius: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
    padding: 0.75rem 1rem;
}

#messageHistory .list-group-item:first-child {
    border-top: none;
}

#messageHistory .list-group-item:last-child {
    border-bottom: none;
}

#messageHistory .list-group-item:hover {
    background-color: #f8f9fa;
}

.history-item-subject {
    font-weight: bold;
    color: var(--primary-color);
}

.history-item-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #6c757d;
    font-size: 0.9rem;
}

.history-item-time {
    font-size: 0.8rem;
    color: #adb5bd;
}

.no-history {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
}

/* Delete button for history items */
.delete-history-item {
    color: #adb5bd;
    background: none;
    border: none;
    padding: 0.25rem;
    margin-left: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.delete-history-item:hover {
    color: #dc3545;
    opacity: 1;
}

/* Clear All button container */
.clear-all-container {
    padding: 0.75rem;
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    margin-bottom: 0.5rem;
}

/* Confirmation dialog */
.confirmation-dialog {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: fadeIn 0.2s ease;
}

.clear-all-confirmation {
    position: relative;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.confirmation-content {
    text-align: center;
    padding: 0.5rem;
}

.confirmation-buttons {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Toast notifications */
#toastContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1050;
}

.toast {
    padding: 0.75rem 1.25rem;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.1);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 350px;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.toast-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.toast-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

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

/* Make the history item content clickable */
.history-item-content {
    cursor: pointer;
}