/* ==========================================================================
   CUSTOM.CSS - Consolidated Styles
   ========================================================================== */

/* ==========================================================================
   1. GLOBAL RESETS & BASE STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    font-weight: 400;
}

body {
    overflow-x: hidden; /* Prevents horizontal scrollbars */
    overflow-y: auto;   /* Allows vertical scrolling */
}
p {
    margin: 0;
    padding: 0;
}

/* ==========================================================================
   2. LAYOUT & CONTAINERS (Theme Fixer)
   ========================================================================== */
body, #wrapper, #page-content-wrapper, #main-container, #chat-content {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}

html.dark body, html.dark #wrapper, html.dark #page-content-wrapper, 
html.dark #main-container, html.dark #chat-content {
    background-color: #0f172a !important;
    color: #f8fafc !important;
}

#landing-content {
    background-color: #f8fafc !important;
}

html.dark #landing-content {
    background-color: #0f172a !important;
}

html.dark .text-muted {
    color: #94a3b8 !important;
}

.container-fluid-2 {
    height: 75vh !important;
    overflow: auto;
}

.container-fluid-2 h1 {
    text-align: center;
}

/* ==========================================================================
   3. SIDEBAR STYLES & COLLAPSE
   ========================================================================== */
#sidebar-wrapper, nav {
    background-color: #ffffff !important;
    border-color: #e2e8f0 !important;
}

html.dark #sidebar-wrapper, html.dark nav {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

#sidebar-wrapper {
    transition: width 0.3s ease-in-out, transform 0.3s ease-in-out;
}

#sidebar-wrapper.mobile-sidebar-open {
    transform: translateX(0) !important;
}

/* Shrink width when collapsed */
#sidebar-wrapper.sidebar-collapsed {
    width: 5rem !important; /* 80px width */
}

/* Hide text, conversations, and user details when collapsed */
#sidebar-wrapper.sidebar-collapsed .sidebar-text,
#sidebar-wrapper.sidebar-collapsed .sidebar-conversations,
#sidebar-wrapper.sidebar-collapsed .sidebar-user-details,
#sidebar-wrapper.sidebar-collapsed .sidebar-collapse-icon {
    display: none !important;
}

/* Show expand icon ONLY when collapsed */
#sidebar-wrapper:not(.sidebar-collapsed) .sidebar-expand-icon {
    display: none !important;
}

/* Center elements when collapsed */
#sidebar-wrapper.sidebar-collapsed .sidebar-quick-links a,
#sidebar-wrapper.sidebar-collapsed .sidebar-header {
    justify-content: center !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

#sidebar-wrapper.sidebar-collapsed .sidebar-user-btn {
    justify-content: center !important;
}

.sidebar-quick-links a, .sidebar-link {
    text-decoration: none !important;
}

/* ==========================================================================
   4. CHAT INTERFACE (BUBBLES, INPUT, CONTAINERS)
   ========================================================================== */
.chat-container {
    width: 100%;
    height: auto;
}

.chat-container .user-chat-container,
.chat-container .bot-chat-container {
    width: 100%;
    height: auto;
    padding: 10px 0;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
}

.chat-container .bot-chat-container {
    background-color: var(--bs-tertiary-bg);
}

.chat-container .user-chat-container .user-pic,
.chat-container .bot-chat-container .bot-icon {
    width: 50px;
    height: 50px;
    border: 1px solid var(--bs-border-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-container .user-chat-container i {
    font-size: 30px !important;
}

.chat-container .bot-chat-container .bot-response {
    height: auto;
    width: 80%;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: justify;
}

/* Modern Chat Messages */
.chat-message {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    width: 100%;
    animation: slide-up 0.3s ease-out forwards;
}

.chat-message strong {
    display: none; /* Hide old labels */
}

.chat-message.user-message {
    justify-content: flex-end;
}

.chat-message.assistant-message {
    justify-content: flex-start;
}

.bubble {
    max-width: 85%;
    padding: 0.875rem 1.25rem;
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Assistant Message Bubble */
.assistant-message .bubble {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 1.25rem 1.25rem 1.25rem 0.25rem !important;
}

html.dark .assistant-message .bubble {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

/* User Message Bubble */
.user-message .bubble {
    background: linear-gradient(135deg, #6366f1 0%, #9333ea 100%) !important;
    color: #ffffff !important;
    border-radius: 1.25rem 1.25rem 0.25rem 1.25rem !important;
}

html.dark .user-message .bubble {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border: 1px solid #475569 !important;
}

html.dark .user-avatar {
    background-color: #475569 !important;
    color: #e2e8f0 !important;
}

/* Chat Input Area */
.chat-input-form {
    border-top: 1px solid var(--bs-border-color);
    background-color: var(--bs-body-bg);
    width: 100%;
}

.chat-input-wrapper {
    max-width: 768px;
    width: 100%;
}

.chat-input-group {
    display: flex;
    align-items: center;
    background-color: var(--bs-secondary-bg);
    border-radius: 50px;
    padding: 0 6px;
    border: 1px solid var(--bs-border-color);
    transition: box-shadow 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.chat-input-group:focus-within {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb), 0.3);
}

.chat-input-field {
    flex: 1 1 auto;
    background: transparent;
    border: none;
    outline: none;
    color: var(--bs-body-color);
    padding: 10px 4px;
    font-size: 1rem;
    resize: none;
    min-height: 24px;
}

.chat-input-field::placeholder {
    color: var(--bs-text-muted);
    opacity: 0.7;
}

.chat-input-field:focus {
    outline: none;
    box-shadow: none;
}

#mic-btn, #submit-btn, #attach-btn {
    flex-shrink: 0;
}

#attach-btn {
    line-height: 3rem;
}

#submit-btn {
    background-color: var(--bs-primary);
    color: #fff;
    border: none;
    transition: background-color 0.2s;
}

#submit-btn:hover {
    background-color: var(--bs-primary-dark, #0b5ed7);
}

#submit-btn i {
    color: inherit !important;
    display: inline-block !important;
    font-size: 16px !important;
}

.chat-input-container {
    min-height: 56px;
    max-height: 200px;
    overflow-y: visible;
}

html.dark .chat-input-container {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark .chat-input-container textarea {
    color: #f8fafc !important;
}

html.dark .chat-input-container textarea::placeholder {
    color: #94a3b8 !important;
}

html.dark .chat-input-container #mic-btn:hover {
    background-color: #334155 !important;
}

#input_value {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    max-width: 100%;
    line-height: 2.5rem;
    max-height: 72px !important; /* Exactly 3 lines (24px * 3) */
}

textarea {
    resize: none;
}

/* ==========================================================================
   5. MARKDOWN & RTL STYLING
   ========================================================================== */
.bubble h1, .bubble h2, .bubble h3 {
    font-weight: bold;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.bubble h1 { font-size: 1.5rem; }
.bubble h2 { font-size: 1.25rem; }
.bubble h3 { font-size: 1.1rem; }

.bubble strong { font-weight: 700; }
.bubble a { color: #6366f1; text-decoration: underline; }

.bubble ul, .bubble ol {
    margin-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.bubble ul { list-style-type: disc; }
.bubble ol { list-style-type: decimal; }
.bubble li { margin-bottom: 0.25rem; }

.bubble code {
    background-color: rgba(0,0,0,0.05);
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

html.dark .bubble code {
    background-color: rgba(255,255,255,0.1);
}

.bubble pre {
    background-color: #0f172a;
    color: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.75rem 0;
    border: 1px solid #334155;
}

.bubble pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

/* RTL Fixes */
.bubble[dir="rtl"] {
    text-align: right;
}

.bubble[dir="rtl"] ul, .bubble[dir="rtl"] ol {
    margin-left: 0;
    margin-right: 1.5rem;
}

/* ==========================================================================
   6. UI COMPONENTS (LANDING, MODALS, DROPDOWNS, FORMS)
   ========================================================================== */
/* Landing Page Cards */
#landing-content .rounded-xl.bg-white {
    background-color: #ffffff !important;
    border-color: #f1f5f9 !important;
}

#landing-content .rounded-xl.bg-white h3 { color: #1e293b !important; }
#landing-content .rounded-xl.bg-white p { color: #64748b !important; }

html.dark #landing-content .rounded-xl {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark #landing-content .rounded-xl h3 { color: #ffffff !important; }
html.dark #landing-content .rounded-xl p { color: #94a3b8 !important; }

/* Modals */
html.dark .modal-content {
    background-color: #1e293b !important;
    color: #f8fafc !important;
}

html.dark .modal-header, html.dark .modal-footer {
    border-color: #334155 !important;
}

html.dark .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* User Dropdowns */
.user-dropdown-menu {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    overflow: hidden;
}

html.dark .user-dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

.user-dropdown-menu .dropdown-item {
    color: #475569 !important;
    background-color: transparent !important;
}

html.dark .user-dropdown-menu .dropdown-item {
    color: #cbd5e1 !important;
}

.user-dropdown-menu .dropdown-item:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}

html.dark .user-dropdown-menu .dropdown-item:hover {
    background-color: #334155 !important;
    color: #f8fafc !important;
}

.user-dropdown-menu .dropdown-item.text-red-500 {
    color: #ef4444 !important;
}

html.dark .user-dropdown-menu .dropdown-item.text-red-500 {
    color: #f87171 !important;
}

.user-dropdown-menu .dropdown-item.text-red-500:hover {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
}

html.dark .user-dropdown-menu .dropdown-item.text-red-500:hover {
    background-color: #7f1d1d33 !important;
    color: #ef4444 !important;
}

.user-dropdown-menu .dropdown-divider {
    border-color: #e2e8f0 !important;
    margin: 0.25rem 0 !important;
}

html.dark .user-dropdown-menu .dropdown-divider {
    border-color: #334155 !important;
}

/* Thinking Dropdown */
html.dark .thinking-dropdown {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3) !important;
}

html.dark .thinking-dropdown .dropdown-item {
    color: #cbd5e1 !important;
}

html.dark .thinking-dropdown .dropdown-item:hover {
    background-color: #334155 !important;
    color: #f8fafc !important;
}

/* Forms & Checkboxes */
html.dark .form-check-input {
    background-color: #475569;
    border-color: #64748b;
}

html.dark .form-check-input:checked {
    background-color: #6366f1;
    border-color: #6366f1;
}

html.dark .form-check-input:focus {
    box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.25);
}

html.dark .form-select {
    color: #f8fafc;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23cbd5e1' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* ==========================================================================
   7. QUIZ & PATH NODES
   ========================================================================== */
.quiz-option-label {
    color: #1e293b; /* slate-800 for light mode */
}

html.dark .quiz-option-label {
    color: #e2e8f0; /* slate-200 for dark mode */
}

/* Note: @apply requires a Tailwind CSS build step. If not using one, replace with standard CSS. */
.quiz-option-text {
    @apply text-slate-800 dark:text-slate-200;
}

.path-node {
    position: relative;
    transition: all 0.3s ease;
}

.path-node.completed .node-circle {
    animation: completedPulse 2s infinite;
}

.path-node.current .node-circle {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.3);
}

.path-node.completed:hover .node-circle,
.path-node.current:hover .node-circle,
.path-node.bonus:hover .node-circle {
    transform: scale(1.15);
}

.path-node.locked {
    cursor: not-allowed;
    opacity: 0.7;
}

.connector {
    transition: all 0.3s ease;
}

@keyframes completedPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* ==========================================================================
   8. SETTINGS & LANGUAGE OPTIONS
   ========================================================================== */
.lang-option.active, .theme-option.active {
    border-color: #6366f1 !important;
    background-color: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

html.dark .lang-option.active, html.dark .theme-option.active {
    background-color: rgba(99, 102, 241, 0.15);
}

/* ==========================================================================
   9. MISC COMPONENTS (Features, Submit Form, User, Chat Today)
   ========================================================================== */
.container-fluid-2 .bot-feature-container {
    width: 80%;
    height: 400px;
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-around;
    flex-wrap: wrap;
}

.container-fluid-2 .bot-feature-container .feature-container {
    width: 250px;
    height: 350px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    flex-direction: column;
}

.container-fluid-2 .bot-feature-container .feature-container .feature {
    width: 100%;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    box-shadow: rgba(0, 0, 0, 0.25) 0px 0.0625em 0.0625em, rgba(0, 0, 0, 0.25) 0px 0.125em 0.5em, rgba(255, 255, 255, 0.1) 0px 0px 0px 1px inset;
    border-radius: 10px;
}

.container-fluid-2 .bot-feature-container .feature-container .icon {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.container-fluid-2 .bot-feature-container .feature-container .icon i {
    font-size: 28px;
}

.submit-form {
    width: 500px;
    height: 60px;
    border: 2px solid var(--bs-border-color);
    border-radius: 10px;
    margin: 30px auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    box-shadow: rgba(14, 30, 37, 0.12) 0px 2px 4px 0px, rgba(14, 30, 37, 0.32) 0px 2px 16px 0px;
}

.submit-form input {
    height: 50px;
    width: 400px;
    padding: 10px;
    border: none;
    background: var(--bs-body-bg);
    outline: none;
}

.submit-form button {
    border: none;
    background: none;
    font-size: 28px;
}

.user {
    display: flex;
    align-items: center;
    justify-content: space-evenly;
    margin: 10px 0 30px 0;
}

.user i {
    font-size: 20px;
}

.user p {
    font-weight: bold;
}

.chat-today {
    height: auto;
    margin-bottom: 20px;
}

.chat-today .chat {
    display: flex;
    align-items: center;
    margin: 10px 0 0 0;
    justify-content: space-evenly;
    overflow-y: auto;
    font-size: 15px;
    cursor: pointer;
}

.chat-today .chat p {
    height: auto;
    margin: 0 10px;
}

.chat-today .chat p:hover {
    color: gray;
    transition: ease-in-out;
}

.chat-today small {
    font-weight: bold;
}

#list-group {
    padding: 10px;
    width: 250px;
    height: 100vh !important;
    overflow: auto !important;
}

.spinner-main {
    display: none;
    align-items: center;
    justify-content: center;
}

.navbar .container-fluid {
    position: relative;
}

#theme-toggle-btn {
    margin-left: auto;
    z-index: 10;
}

/* ==========================================================================
   10. ANIMATIONS & SCROLLBARS
   ========================================================================== */
@keyframes slide-up {
    from { opacity: 0; transform: translateY(15px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

html.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}

/* ==========================================================================
   11. UTILITY CLASSES
   ========================================================================== */
.d-none { display: none !important; }
.d-flex { display: flex !important; }

/* ==========================================================================
   12. RESPONSIVE MEDIA QUERIES
   ========================================================================== */
@media (max-width: 1200px) {
    .container-fluid-2 {
        overflow: auto;
    }
    .bot-feature-container {
        height: auto;
    }
}

@media (max-width: 991.98px) {
    #sidebar-wrapper {
        display: none !important;
    }
    #sidebar-wrapper.d-none {
        display: none !important;
    }
    #sidebar-wrapper:not(.d-none) {
        display: flex !important;
    }
}

@media (max-width: 500px) {
    .submit-form {
        width: 300px;
        height: 60px;
    }
    
    .submit-form input {
        height: 50px;
        width: 250px;
    }
}
#submitQuizBtn {
    background-color: #4f46e5 !important; /* indigo-600 */
    color: #ffffff !important;            /* white text */
    border: none !important;
}

#submitQuizBtn:hover:not(:disabled) {
    background-color: #4338ca !important; /* indigo-700 */
}

#submitQuizBtn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* Dark Mode Overrides */
html.dark #submitQuizBtn {
    background-color: #6366f1 !important; /* indigo-500 */
    color: #ffffff !important;
}

html.dark #submitQuizBtn:hover:not(:disabled) {
    background-color: #4f46e5 !important; /* indigo-600 */
}
/* ==========================================================================
   13. CONVERSATION UTILITY DROPDOWN & MODALS (Visibility Fixes)
   ========================================================================== */

/* --- Dropdown Menu --- */
.custom-dropdown {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    border-radius: 0.5rem !important;
    overflow: hidden !important;
    min-width: 160px !important;
}

html.dark .custom-dropdown {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3) !important;
}

.custom-dropdown button {
    width: 100% !important;
    text-align: left !important;
    padding: 0.625rem 1rem !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    border: none !important;
    background: transparent !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.75rem !important;
}

/* Rename Option */
.custom-dropdown .btn-rename {
    color: #334155 !important;
}
html.dark .custom-dropdown .btn-rename {
    color: #f1f5f9 !important; /* Bright white/gray for dark mode visibility */
}
.custom-dropdown .btn-rename:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
}
html.dark .custom-dropdown .btn-rename:hover {
    background-color: #334155 !important;
    color: #ffffff !important;
}

/* Divider */
.custom-dropdown .dropdown-divider {
    height: 1px !important;
    background-color: #e2e8f0 !important;
    margin: 0.25rem 0 !important;
    border: none !important;
}
html.dark .custom-dropdown .dropdown-divider {
    background-color: #334155 !important;
}

/* Delete Option */
.custom-dropdown .btn-delete {
    color: #dc2626 !important;
}
html.dark .custom-dropdown .btn-delete {
    color: #f87171 !important;
}
.custom-dropdown .btn-delete:hover {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
}
html.dark .custom-dropdown .btn-delete:hover {
    background-color: rgba(127, 29, 29, 0.2) !important;
    color: #ef4444 !important;
}

/* --- Modals Overlay --- */
#renameModal, #deleteModal {
    background-color: rgba(0, 0, 0, 0.6) !important;
    backdrop-filter: blur(4px) !important;
}

/* Modal Content Box */
#renameModal .modal-box, #deleteModal .modal-box {
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    color: #0f172a !important;
    border-radius: 0.75rem !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25) !important;
    max-width: 28rem !important;
    width: 100% !important;
    padding: 1.5rem !important;
    margin: 1rem !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
}

html.dark #renameModal .modal-box, html.dark #deleteModal .modal-box {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

/* Modal Headings */
#renameModal h3, #deleteModal h3 {
    color: #0f172a !important;
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    margin-bottom: 1rem !important;
}
html.dark #renameModal h3, html.dark #deleteModal h3 {
    color: #ffffff !important;
}

/* Modal Text */
#deleteModal .modal-text {
    font-size: 0.875rem !important;
    color: #64748b !important;
    margin-bottom: 1.5rem !important;
    line-height: 1.5 !important;
}
html.dark #deleteModal .modal-text {
    color: #cbd5e1 !important;
}

/* Modal Input */
#renameInput {
    width: 100% !important;
    padding: 0.75rem 1rem !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 0.5rem !important;
    background-color: #f8fafc !important;
    color: #0f172a !important;
    font-size: 0.875rem !important;
    margin-bottom: 1.5rem !important;
    outline: none !important;
}
#renameInput:focus {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
}
html.dark #renameInput {
    background-color: #0f172a !important;
    border-color: #475569 !important;
    color: #f8fafc !important;
}
html.dark #renameInput::placeholder {
    color: #94a3b8 !important;
}

/* Modal Buttons Container - FORCES SIDE-BY-SIDE LAYOUT */
.modal-actions {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 0.75rem !important;
    margin-top: 1.5rem !important;
}

/* Modal Buttons Base */
.modal-actions button {
    padding: 0.625rem 1.25rem !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    border-radius: 0.5rem !important;
    border: none !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
}

/* Cancel Button */
.modal-actions .btn-cancel {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}
.modal-actions .btn-cancel:hover {
    background-color: #e2e8f0 !important;
    color: #0f172a !important;
}
html.dark .modal-actions .btn-cancel {
    background-color: #334155 !important;
    color: #e2e8f0 !important;
}
html.dark .modal-actions .btn-cancel:hover {
    background-color: #475569 !important;
    color: #ffffff !important;
}

/* Save Button */
.modal-actions .btn-save {
    background-color: #4f46e5 !important;
    color: #ffffff !important;
}
.modal-actions .btn-save:hover {
    background-color: #4338ca !important;
}

/* Delete Confirm Button */
.modal-actions .btn-delete-confirm {
    background-color: #dc2626 !important;
    color: #ffffff !important;
}
.modal-actions .btn-delete-confirm:hover {
    background-color: #b91c1c !important;
}

/* Delete Icon Background */
#deleteModal .icon-bg {
    background-color: #fef2f2 !important;
    color: #dc2626 !important;
}
html.dark #deleteModal .icon-bg {
    background-color: rgba(127, 29, 29, 0.2) !important;
    color: #f87171 !important;
}
/* Settings: Font Size Overrides */
#chat-messages.text-sm .bubble { font-size: 0.85rem !important; }
#chat-messages.text-base .bubble { font-size: 0.95rem !important; }
#chat-messages.text-lg .bubble { font-size: 1.15rem !important; }
   /* 1. Streak Button Base */
  .streak-btn {
      position: relative;
      overflow: visible; /* Allow embers to float outside */
      transition: all 0.3s ease;
  }

  /* 🔥 ACTIVE STATE: The Permanent Flame */
  .streak-btn.streak-active {
      background: linear-gradient(135deg, #ffedd5 0%, #fed7aa 100%) !important; 
      border-color: #fdba74 !important; 
      box-shadow: 0 0 15px rgba(249, 115, 22, 0.4) !important; 
  }

  html.dark .streak-btn.streak-active {
      background: linear-gradient(135deg, #431407 0%, #7c2d12 100%) !important; 
      border-color: #ea580c !important; 
      box-shadow: 0 0 20px rgba(234, 88, 12, 0.5) !important; 
  }

  /* The Fire Icon: HIGHLY DYNAMIC Flicker Animation */
  .streak-btn.streak-active .streak-icon {
      color: #ea580c !important; 
      /* Fast, chaotic flame movement */
      animation: dynamic-flame 1.2s infinite ease-in-out;
      /* Multi-layered drop shadow for realistic glow */
      filter: drop-shadow(0 0 3px rgba(234, 88, 12, 0.9)) 
              drop-shadow(0 -2px 6px rgba(251, 146, 60, 0.7));
      z-index: 2;
      position: relative;
  }

  html.dark .streak-btn.streak-active .streak-icon {
      color: #fb923c !important; 
      filter: drop-shadow(0 0 4px rgba(251, 146, 60, 1)) 
              drop-shadow(0 -3px 8px rgba(255, 100, 0, 0.8));
  }

  /* The Count Text: Solid & Bold */
  .streak-btn.streak-active .streak-count {
      color: #9a3412 !important; 
      font-weight: 800 !important;
      z-index: 2;
      position: relative;
  }

  html.dark .streak-btn.streak-active .streak-count {
      color: #ffedd5 !important; 
  }

  /* 🔥 KEYFRAMES: The "Dynamic Living Flame" Effect (Chaotic & Fast) */
  @keyframes dynamic-flame {
      0% { 
          transform: scale(1) rotate(0deg) translateY(0); 
      }
      15% { 
          transform: scale(1.15) rotate(-6deg) translateY(-2px); 
      }
      30% { 
          transform: scale(0.9) rotate(4deg) translateY(1px); 
      }
      45% { 
          transform: scale(1.1) rotate(-3deg) translateY(-3px); 
      }
      60% { 
          transform: scale(1.05) rotate(5deg) translateY(0); 
      }
      75% { 
          transform: scale(1.12) rotate(-4deg) translateY(-1px); 
      }
      100% { 
          transform: scale(1) rotate(0deg) translateY(0); 
      }
  }

  /* 🔥 DYNAMIC BACKGROUND GLOW */
  .streak-btn.streak-active::before {
      content: '';
      position: absolute;
      inset: -5px;
      background: radial-gradient(circle at center, rgba(255, 100, 0, 0.3) 0%, transparent 70%);
      animation: pulse-glow 1.5s infinite alternate;
      pointer-events: none;
      z-index: 0;
      border-radius: 9999px;
  }

  @keyframes pulse-glow {
      0% { opacity: 0.4; transform: scale(0.95); }
      100% { opacity: 0.8; transform: scale(1.05); }
  }

  /* 🔥 FLOATING EMBER PARTICLE (The ultimate dynamic touch) */
  .streak-btn.streak-active::after {
      content: '';
      position: absolute;
      width: 4px;
      height: 4px;
      background: #fbbf24; /* Bright Amber */
      border-radius: 50%;
      top: 30%;
      right: 35%;
      opacity: 0;
      animation: float-ember 1.8s infinite ease-out;
      pointer-events: none;
      z-index: 3;
      box-shadow: 0 0 6px #fbbf24;
  }

  /* Second ember for extra chaos */
  .streak-btn.streak-active .streak-icon::after {
      content: '';
      position: absolute;
      width: 3px;
      height: 3px;
      background: #f97316; /* Orange */
      border-radius: 50%;
      top: 50%;
      left: 20%;
      opacity: 0;
      animation: float-ember 2.2s infinite ease-out 0.5s; /* 0.5s delay */
      pointer-events: none;
      box-shadow: 0 0 4px #f97316;
  }
      
    /* Smooth transition for step switching */
    .step-container {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    .step-container.hidden {
        display: none;
    }
        /* Smooth transition for step switching */
    .step-container {
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    .step-container.hidden {
        display: none;
    }

    /* Slow, elegant rotation for the 7-arrow circle */
    @keyframes spin-slow {
        from { transform: rotate(0deg); }
        to { transform: rotate(360deg); }
    }
    .animate-spin-slow {
        animation: spin-slow 8s linear infinite;
    }
/* Message Actions Toolbar - Floating Pill Style */
.message-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0; /* Hidden by default */
    transform: translateY(5px); /* Start slightly lower for slide-up effect */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Pill Styling */
    background-color: #f8fafc; /* Very light grey */
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    border-radius: 9999px; /* Fully rounded pill shape */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Dark mode support for the pill */
html.dark .message-actions {
    background-color: #1e293b; /* Slate 800 */
    border-color: #334155;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Show and slide up on hover */
.chat-message:hover .message-actions {
    opacity: 1;
    transform: translateY(0);
}

/* Always visible on mobile */
@media (max-width: 768px) {
    .message-actions {
        opacity: 1;
        transform: translateY(0);
    }
}

.action-btn {
    background: transparent;
    border: none;
    color: #64748b; /* Slate 500 */
    cursor: pointer;
    padding: 0.35rem;
    border-radius: 50%; /* Circular buttons inside the pill */
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background-color: #e2e8f0; /* Slate 200 */
    color: #0f172a; /* Slate 900 */
    transform: scale(1.1); /* Slight pop effect */
}

html.dark .action-btn:hover {
    background-color: #334155;
    color: #f8fafc;
}

.action-btn.delete-btn:hover {
    background-color: #fee2e2; /* Red 100 */
    color: #ef4444; /* Red 500 */
}
/* 1. Fix RTL (Persian/Arabic) Text Direction */
.bubble[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

/* 2. Edit Mode Styles */
.edit-textarea {
    width: 100%;
    min-height: 80px;
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    resize: vertical;
    outline: none;
    margin-bottom: 0.5rem;
}

.edit-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end; /* Buttons on the right */
}

/* If RTL, put edit buttons on the left */
.bubble[dir="rtl"] .edit-actions {
    justify-content: flex-start; 
}

.btn-edit-save {
    background-color: #10b981; /* Green */
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-edit-cancel {
    background-color: #ef4444; /* Red */
    color: white;
    border: none;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}