/* Finax 2.0 Styles */
* {
    box-sizing: border-box;
}

/* ===== Main Finax Window ===== */
.finax-window {
    width: 25%;
    min-width: 15%;
    max-width: 35%;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    background-color: #1b1c1d;
    z-index: 400;
    overflow: hidden; /* Contain the menu within the window */
    /* Sliding animation */
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.3s ease,
                opacity 0.3s ease;
    will-change: transform;
}

.finax-window.minimized {
    width: 15%;
}

/* Hidden Chat State - Slide out to the left */
.finax-window.hidden {
    transform: translateX(-100%);
    pointer-events: none;
}

/* Slide-in animation class for explicit opening */
.finax-window.slide-in {
    animation: finaxSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes finaxSlideIn {
    0% {
        transform: translateX(-100%);
        opacity: 0.5;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== Resize Handle ===== */
.finax-resize-handle {
    width: 6px;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    cursor: ew-resize;
    background: transparent;
    z-index: 500;
    transition: background-color 0.2s ease;
}

.finax-resize-handle:hover,
.finax-resize-handle.active {
    background: linear-gradient(to left, #741ea9 0%, transparent 100%);
}

.finax-resize-handle::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 2px;
    transform: translateY(-50%);
    width: 2px;
    height: 40px;
    background-color: #5a6363;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.finax-resize-handle:hover::after {
    opacity: 1;
}

/* ===== Chat Wrapper ===== */
.chat-wrap {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 8px;
}

/* ===== Chat Header ===== */
.chat-header {
    width: 100%;
    height: 48px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    border-bottom: 1px solid #2d2e30;
    margin-bottom: 8px;
}

.chat-header-right,
.chat-header-center,
.chat-header-left {
    display: flex;
    align-items: center;
}

.chat-header-center {
    flex: 1;
    justify-content: center;
}

.finax-title {
    font-size: 18px;
    font-weight: 500;
    font-family: "Rubik", sans-serif;
    color: #fff;
}

#finax-menu-icon {
    font-size: 20px;
    cursor: pointer;
    color: #7f7f7f;
    transition: color 0.2s ease;
}

#finax-menu-icon:hover {
    color: #fff;
}

/* ===== Asimunim Balance ===== */
.asimunim-balance {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: linear-gradient(135deg, rgba(171, 47, 247, 0.18) 0%, rgba(171, 47, 247, 0.08) 100%);
    border: 1px solid rgba(171, 47, 247, 0.35);
    border-radius: 8px;
    cursor: default;
}

.asimunim-balance i {
    font-size: 14px;
    color: #ab2ff7;
}

.asimunim-value {
    font-size: 13px;
    font-family: "Rubik", sans-serif;
    font-weight: 500;
    color: #ab2ff7;
    letter-spacing: 0.3px;
    min-width: 30px;
    text-align: center;
}

/* Balance counting down animation - numbers only */
.asimunim-value.counting {
    animation: countingPulse 0.15s ease-out;
}

@keyframes countingPulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

/* ===== Menu ===== */
.finax-menu {
    width: 80%;
    height: 100%;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 500;
    display: flex;
    flex-direction: column;
    background-color: #282a2c;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
    /* Simple sliding animation */
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.3s ease, visibility 0.3s ease;
}

/* Menu open state */
.finax-menu.open {
    transform: translateX(0);
    visibility: visible;
}

.finax-menu-header {
    width: 100%;
    height: 48px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid #3a3a3d;
}

.menu-header-right,
.menu-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Menu Header Buttons */
.menu-header-btn {
    font-size: 16px;
    cursor: pointer;
    color: #7f7f7f;
    transition: color 0.2s ease;
}

.menu-header-btn:hover {
    color: #fff;
}

#finax-menu-close {
    font-size: 20px;
    cursor: pointer;
    color: #7f7f7f;
    transition: color 0.2s ease;
}

#finax-menu-close:hover {
    color: #fff;
}

.finax-menu-wrap {
    width: 100%;
    height: calc(100% - 48px);
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow-y: auto;
}

/* Menu Scrollbar - Dark gray style matching chat window */
.finax-menu-wrap::-webkit-scrollbar {
    width: 6px;
}

.finax-menu-wrap::-webkit-scrollbar-track {
    background: transparent;
}

.finax-menu-wrap::-webkit-scrollbar-thumb {
    background-color: #3a3a3d;
    border-radius: 6px;
}

.finax-menu-wrap::-webkit-scrollbar-thumb:hover {
    background-color: #57575c;
}

#new-chat-button {
    width: 100%;
    padding: 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-radius: 10px;
    transition: background-color 0.2s ease;
}

#new-chat-button:hover {
    background-color: #313436;
}

#new-chat-button i {
    font-size: 16px;
    color: #7f7f7f;
}

.finax-menu-button-text {
    font-size: 15px;
    font-family: "Rubik", sans-serif;
    color: #b0b0b0;
}

.chat-history {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.chat-history-group-title {
    font-size: 12px;
    font-family: "Rubik", sans-serif;
    color: #7f7f7f;
    padding: 8px 12px 4px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chat-history-item {
    width: 100%;
    padding: 10px 12px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: background-color 0.2s ease;
}

.chat-history-item:hover {
    background-color: #313436;
}

.chat-history-item.active {
    background-color: #3a3d40;
}

.chat-history-item-title {
    flex: 1;
    font-size: 14px;
    font-family: "Rubik", sans-serif;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item-delete {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.chat-history-item:hover .chat-history-item-delete {
    opacity: 1;
}

.chat-history-item-delete:hover {
    background-color: #4a4d50;
}

.chat-history-item-delete i {
    font-size: 12px;
    color: #7f7f7f;
}

.chat-history-item-delete:hover i {
    color: #ff6b6b;
}

.chat-history-empty {
    padding: 16px 12px;
    font-size: 13px;
    font-family: "Rubik", sans-serif;
    color: #7f7f7f;
    text-align: center;
}

.chat-history-loading {
    padding: 16px 12px;
    font-size: 13px;
    font-family: "Rubik", sans-serif;
    color: #7f7f7f;
    text-align: center;
}

/* ===== Delete Dialog ===== */
.finax-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(2px);
}

.finax-dialog-overlay.visible {
    display: flex;
}

.finax-dialog {
    background-color: #2a2b2d;
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    animation: dialogSlideIn 0.2s ease-out;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.finax-dialog-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 16px;
    background-color: rgba(255, 107, 107, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finax-dialog-icon i {
    font-size: 24px;
    color: #ff6b6b;
}

.finax-dialog-title {
    font-size: 18px;
    font-family: "Rubik", sans-serif;
    font-weight: 500;
    color: #fff;
    margin-bottom: 8px;
}

.finax-dialog-message {
    font-size: 14px;
    font-family: "Rubik", sans-serif;
    color: #a0a0a0;
    margin-bottom: 24px;
    line-height: 1.5;
}

.finax-dialog-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.finax-dialog-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-family: "Rubik", sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.finax-dialog-btn:active {
    transform: scale(0.98);
}

.finax-dialog-btn-cancel {
    background-color: #3a3b3d;
    color: #d0d0d0;
}

.finax-dialog-btn-cancel:hover {
    background-color: #4a4b4d;
}

.finax-dialog-btn-confirm {
    background-color: #dc3545;
    color: #fff;
}

.finax-dialog-btn-confirm:hover {
    background-color: #c82333;
}

/* ===== Messages Container ===== */
.messages-container {
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    padding: 8px 4px;
}

.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background-color: #3a3a3d;
    border-radius: 6px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background-color: #57575c;
}

/* =============================================
   WELCOME STATE (New chat / empty chat)
   ============================================= */

.finax-compose-area {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

/* Center compose area when there are no messages */
.chat-wrap.is-welcome .messages-container {
    display: none;
}

.chat-wrap.is-welcome .finax-compose-area {
    margin-top: auto;
    margin-bottom: auto;
}

.finax-welcome {
    /* Big welcome block (only in welcome mode / empty chat) */
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px 0 10px;
    text-align: center;
}

.chat-wrap.is-welcome .finax-welcome {
    display: flex;
}

/* Small intro (visible in normal chat mode only when no messages) */
.finax-intro {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 4px 6px 0 6px;
}

.chat-wrap.is-welcome .finax-intro {
    display: none;
}

/* Hide intro when chat has messages (existing/active chat) */
.chat-wrap.has-messages .finax-intro {
    display: none;
}

.finax-intro-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
    opacity: 1;
    transform: none;
    will-change: transform, opacity;
}

.finax-intro-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.finax-intro-greeting {
    font-family: "Rubik", sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    opacity: 1;
    transform: none;
    will-change: transform, opacity;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.finax-intro-tagline {
    font-family: "Rubik", sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: #bdbdbd;
    opacity: 1;
    transform: none;
    will-change: transform, opacity;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.finax-welcome-icon {
    width: 44px;
    height: 44px;
    opacity: 1;
    transform: none;
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.35));
    will-change: transform, opacity;
}

.finax-welcome-greeting {
    font-family: "Rubik", sans-serif;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    opacity: 1;
    transform: none;
    will-change: transform, opacity;
}

.finax-welcome-tagline {
    font-family: "Rubik", sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #e9e9e9;
    opacity: 1;
    transform: none;
    will-change: transform, opacity;
}

/* Animations (played when .is-animating is added) */
.finax-welcome.is-animating .finax-welcome-icon,
.finax-welcome.is-animating .finax-welcome-greeting,
.finax-welcome.is-animating .finax-welcome-tagline {
    /* Force starting state for the animation so it looks consistent even though the default is visible */
    opacity: 0;
}

.finax-welcome.is-animating .finax-welcome-icon {
    transform: translateY(14px) rotate(0deg) scale(0.92);
}

.finax-welcome.is-animating .finax-welcome-greeting {
    transform: translateX(18px);
}

.finax-welcome.is-animating .finax-welcome-tagline {
    transform: translateY(-10px);
}

.finax-welcome.is-animating .finax-welcome-icon {
    animation: finaxWelcomeIconIn 800ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.finax-welcome.is-animating .finax-welcome-greeting {
    animation: finaxWelcomeGreetingIn 520ms cubic-bezier(0.2, 0.9, 0.2, 1) 180ms forwards;
}

.finax-welcome.is-animating .finax-welcome-tagline {
    animation: finaxWelcomeTaglineIn 520ms cubic-bezier(0.2, 0.9, 0.2, 1) 320ms forwards;
}

/* Intro animations (same feel, smaller) */
.finax-intro.is-animating .finax-intro-icon,
.finax-intro.is-animating .finax-intro-greeting,
.finax-intro.is-animating .finax-intro-tagline {
    opacity: 0;
}

.finax-intro.is-animating .finax-intro-icon {
    transform: translateY(10px) rotate(0deg) scale(0.92);
    animation: finaxWelcomeIconIn 700ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
}

.finax-intro.is-animating .finax-intro-greeting {
    transform: translateX(14px);
    animation: finaxWelcomeGreetingIn 440ms cubic-bezier(0.2, 0.9, 0.2, 1) 140ms forwards;
}

.finax-intro.is-animating .finax-intro-tagline {
    transform: translateY(-8px);
    animation: finaxWelcomeTaglineIn 440ms cubic-bezier(0.2, 0.9, 0.2, 1) 240ms forwards;
}

@keyframes finaxWelcomeIconIn {
    0% {
        opacity: 0;
        transform: translateY(14px) rotate(0deg) scale(0.92);
    }
    65% {
        opacity: 1;
        transform: translateY(-8px) rotate(320deg) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(-6px) rotate(360deg) scale(1);
    }
}

@keyframes finaxWelcomeGreetingIn {
    from {
        opacity: 0;
        transform: translateX(18px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes finaxWelcomeTaglineIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.finax-prompt-chips {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 0 4px;
}

.chat-wrap.is-welcome .finax-prompt-chips {
    display: flex;
}

.finax-chip {
    appearance: none;
    border: 1px solid #3a3a3d;
    background-color: #2d2e30;
    color: #d0d0d0;
    font-family: "Rubik", sans-serif;
    font-size: 12px;
    line-height: 1.2;
    padding: 8px 10px;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.12s ease, color 0.2s ease;
    max-width: 100%;
    direction: rtl;
    text-align: center;
}

.finax-chip:hover {
    background-color: #313436;
    border-color: #4a4a4d;
    color: #fff;
}

.finax-chip:active {
    transform: scale(0.98);
}

.finax-chip:focus-visible {
    outline: 2px solid rgba(124, 156, 255, 0.85);
    outline-offset: 2px;
}

/* ===== Message Styles ===== */
.message-box {
    width: 100%;
    display: flex;
    flex-direction: row;
    gap: 10px;
}

.user-msg {
    max-width: 85%;
    padding: 10px 14px;
    color: #fff;
    font-size: 15px;
    font-family: "Rubik", sans-serif;
    line-height: 1.5;
    border-radius: 16px 4px 16px 16px;
    background-color: #460e8b;
    margin-right: auto;
}

/* User message file attachments */
.user-msg-files {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.user-msg-file {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 12px;
}

.user-msg-file img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
}

.user-msg-file i {
    font-size: 14px;
    opacity: 0.9;
}

.user-msg-file span {
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.finax-msg-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.finax-msg-icon.spinning {
    animation: spin 1.2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.finax-msg {
    max-width: 90%;
    font-size: 15px;
    font-family: "Rubik", sans-serif;
    color: #fff;
    line-height: 1.6;
}

/* ===== Markdown Styles ===== */
.finax-msg strong {
    font-weight: 600;
}

.finax-msg em {
    font-style: italic;
}

.finax-msg a {
    color: #7c9cff;
    text-decoration: none;
}

.finax-msg a:hover {
    text-decoration: underline;
}

.finax-msg .md-code-block {
    display: block;
    background-color: #2d2e30;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.finax-msg .md-code-block code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.finax-msg .md-inline-code {
    background-color: #3a3a3d;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 13px;
}

.finax-msg .md-list {
    margin: 8px 0;
    padding-right: 20px;
    list-style-position: inside;
}

.finax-msg .md-list li {
    margin-bottom: 4px;
    list-style-type: disc;
}

.finax-msg .md-header {
    margin: 12px 0 8px 0;
    font-weight: 600;
}

.finax-msg h2.md-header {
    font-size: 18px;
}

.finax-msg h3.md-header {
    font-size: 16px;
}

.finax-msg h4.md-header {
    font-size: 15px;
}

.source-btn {
    display: inline-block;
    padding: 4px 12px;
    margin-top: 8px;
    color: #fff;
    font-size: 11px;
    font-family: "Rubik", sans-serif;
    border-radius: 20px;
    border: none;
    background-color: #303437;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.source-btn:hover {
    background-color: #3f4447;
}

.sources-list {
    margin: 8px 0;
    padding-right: 20px;
    display: none;
}

.sources-list li {
    list-style: disc;
    margin-bottom: 4px;
    color: #b0b0b0;
}

.sources-list a {
    color: #7c9cff;
    text-decoration: none;
}

.sources-list a:hover {
    text-decoration: underline;
}

/* ===== Prompt Window ===== */
.prompt-window {
    width: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid #3a3a3d;
    border-radius: 20px;
    background-color: #232425;
    overflow: hidden;
    margin-top: 0;
}

.text-box {
    width: 100%;
    padding: 12px 16px 0 16px;
}

.prompt-textarea {
    width: 100%;
    min-height: 72px; /* 3 rows approximately */
    max-height: 216px; /* 9 rows approximately */
    font-size: 15px;
    font-family: "Rubik", sans-serif;
    color: #e9e9e9;
    background-color: transparent;
    border: none;
    resize: none;
    line-height: 1.6;
    overflow-y: auto;
}

.prompt-textarea:focus {
    outline: none;
}

.prompt-textarea::placeholder {
    color: #7f7f7f;
}

.prompt-textarea::-webkit-scrollbar {
    width: 4px;
}

.prompt-textarea::-webkit-scrollbar-track {
    background: transparent;
}

.prompt-textarea::-webkit-scrollbar-thumb {
    background-color: #4a4a4d;
    border-radius: 4px;
}

/* ===== File Preview Area ===== */
.file-preview-area {
    display: none;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid #3a3a3d;
}

.file-preview-area.has-files {
    display: flex;
}

.file-preview-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background-color: #2d2e30;
    border-radius: 8px;
    max-width: 180px;
}

.file-preview-item.image-preview {
    padding: 4px;
}

.file-preview-item.image-preview img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
}

.file-preview-item .file-icon {
    font-size: 18px;
    color: #7c9cff;
    flex-shrink: 0;
}

.file-preview-item .file-icon.pdf { color: #ff6b6b; }
.file-preview-item .file-icon.word { color: #4a90d9; }
.file-preview-item .file-icon.excel { color: #27ae60; }
.file-preview-item .file-icon.text { color: #95a5a6; }

.file-preview-item .file-name {
    font-size: 12px;
    font-family: "Rubik", sans-serif;
    color: #d0d0d0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.file-preview-item .file-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ff6b6b;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.file-preview-item:hover .file-remove {
    opacity: 1;
}

.file-preview-item .file-remove i {
    font-size: 10px;
    color: #fff;
}

.file-preview-item .file-remove:hover {
    background-color: #ff4757;
}

/* ===== Tools Bar ===== */
.tools-bar {
    width: 100%;
    height: 44px;
    padding: 6px 12px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

.add-button,
#send-button {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.add-button {
    background-color: transparent;
}

.add-button:hover {
    background-color: #3a3a3d;
}

#send-button {
    display: none;
    background-color: #741ea9;
}

#send-button:hover {
    background-color: #8a2bc4;
}

#send-button.visible {
    display: flex;
}

.add-button i,
#send-button i {
    font-size: 16px;
    color: #b0b0b0;
}

#send-button i {
    color: #fff;
    transform: scaleX(-1);
}

/* Stop state (while waiting for AI) */
#send-button.is-stop {
    background-color: #c0392b;
}

#send-button.is-stop:hover {
    background-color: #e74c3c;
}

/* Don't mirror the stop icon */
#send-button.is-stop i {
    transform: none;
}

/* ===== Disclaimer ===== */
.finax-disclaimer {
    margin: 8px 0 0 0;
    padding: 0;
    font-size: 11px;
    text-align: center;
    color: #7f7f7f;
    font-family: "Rubik", sans-serif;
}

/* ===== Final HS Code Display ===== */
.finax-message-text {
    width: 100%;
    font-size: 15px;
    font-family: "Rubik", sans-serif;
    color: #fff;
    line-height: 1.6;
}

.final-hs-reply {
    line-height: 1.8;
}

.final-hs-rules-prefix {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #b0b0b0;
    opacity: 0.95;
}

.final-hs-reply strong {
    color: #b794f4;
}

.hsCodeCont,
.hsCodeCont:visited {
    display: inline;
    direction: ltr;
    text-decoration: none;
    color: inherit;
    unicode-bidi: embed;
}

.hsCodeCont:hover {
    text-decoration: underline;
}

.hsCodeDigit {
    display: inline;
    font-size: inherit;
    font-family: "Consolas", "Monaco", monospace;
    padding-left: 3px;
}

.chapterNum {
    color: #ffd700;
}

.headingNum {
    color: #ff7a7a;
}

.subheadingNum {
    color: #e2b2ff;
}

.clauseNum {
    color: #5dade2;
}

.subclauseNum {
    color: #ef54bc;
}

.checkDigit {
    color: #7f8c8d;
}

/* ===== Tariff Tax Table ===== */
.tax-title {
    width: 100%;
    height: auto;
    margin-top: 10px;
    font-size: 24px;
    font-weight: bold;
    color: #2bb7ff;
}

.customs-tax-title {
    width: 100%;
    height: auto;
    margin: 6px 0 0 0;
    font-size: 22px;
    font-weight: bold;
    color: #8d57ff;
}

.customsHStax {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 8px;
    font-size: 14px;
}

.taxTableTitle {
    text-align: right;
    padding: 8px 10px;
    font-weight: 500;
    color: #b0b0b0;
    border-bottom: 1px solid #3a3a3d;
}

tr.customsTableRow {
    background-color: transparent;
}

tr.customsTableRow:nth-child(even) {
    background-color: #232323;
}

tr.customsTableRow td {
    padding: 8px 10px;
    vertical-align: middle;
    border-bottom: 1px solid #2d2e30;
}

.agreementFlag {
    width: 24px;
    height: 24px;
    display: inline-block;
    vertical-align: middle;
    margin-left: 8px;
}

.agreementFlag img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 2px;
}

.agreementName {
    padding: 8px 5px 8px 0;
}

.finax-msg .agreementName,
.finax-message-text .agreementName {
    display: inline-block;
    vertical-align: middle;
    color: #e9e9e9;
    padding: 0;
}

.finax-msg .agreementName.help,
.finax-message-text .agreementName.help {
    cursor: help;
    border-bottom: 1px dotted #7f7f7f;
}

.no-tariff-data {
    color: #7f7f7f;
    font-style: italic;
    margin: 12px 0;
}

/* ===== Loading Animation ===== */
.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ===== Responsive - Tablet ===== */
@media screen and (max-width: 1024px) {
    .finax-window {
        width: 30%;
        min-width: 20%;
    }
}

/* ===== Responsive - Mobile (below 1133px) ===== */
@media screen and (max-width: 1133px) {
    /* Auto-hide chat window on mobile - slide from bottom */
    .finax-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: 100dvh !important;
        height: 100vh !important; /* Fallback for older browsers */
        margin: 0;
        padding: 0;
        overflow: hidden;
        box-sizing: border-box;
        /* Mobile: slide from bottom */
        transform: translateY(100%);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.3s ease;
        opacity: 0;
        pointer-events: none;
    }

    /* Show chat in full screen when opened via button - slide in from bottom */
    .finax-window.mobile-open {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    /* Override slide-in animation for mobile */
    .finax-window.mobile-open.slide-in {
        animation: finaxMobileSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    }

    @keyframes finaxMobileSlideIn {
        0% {
            transform: translateY(100%);
            opacity: 0.5;
        }
        100% {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* Reset desktop hidden state on mobile */
    .finax-window.hidden {
        transform: translateY(100%);
        pointer-events: none;
    }

    /* Hide resize handle on mobile */
    .finax-resize-handle {
        display: none !important;
    }

    /* Hide minimize/maximize button, only show hide button */
    #finax-toggle-size {
        display: none !important;
    }

    /* Ensure chat wrap fills available space without overflow */
    .chat-wrap {
        width: 100% !important;
        height: 100% !important;
        max-width: 100vw;
        max-height: 100dvh;
        padding: 8px;
        margin: 0;
        overflow: hidden;
        box-sizing: border-box;
    }

    /* Chat header fixed height */
    .chat-header {
        flex-shrink: 0;
    }

    /* Prevent horizontal overflow on messages */
    .messages-container {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        flex: 1;
        overflow-x: hidden;
        overflow-y: auto;
        box-sizing: border-box;
    }

    /* Ensure message boxes don't overflow */
    .message-box {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }

    .user-msg {
        max-width: 85%;
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    .finax-msg {
        max-width: calc(100% - 34px); /* Account for icon width + gap */
        min-width: 0;
        word-wrap: break-word;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    /* Ensure compose area fits and stays at bottom */
    .finax-compose-area {
        width: 100%;
        max-width: 100%;
        flex-shrink: 0;
        box-sizing: border-box;
        margin-top: auto;
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    /* Ensure prompt window doesn't overflow */
    .prompt-window {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .text-box {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .prompt-textarea {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* Prevent code blocks from causing horizontal scroll */
    .finax-msg .md-code-block {
        max-width: 100%;
        overflow-x: auto;
        box-sizing: border-box;
    }

    /* Ensure tariff tables don't overflow */
    .customsHStax {
        max-width: 100%;
        overflow-x: auto;
        display: block;
    }

    /* Welcome section adjustments */
    .finax-welcome {
        max-width: 100%;
        padding: 6px 8px 0 8px;
    }

    .finax-prompt-chips {
        max-width: 100%;
        padding: 0 4px;
    }

    .finax-chip {
        max-width: calc(50% - 8px);
        font-size: 11px;
        padding: 6px 8px;
    }

    /* Ensure menu fits mobile screen */
    .finax-menu {
        width: 85%;
        max-width: 320px;
        height: 100%;
    }

    /* File preview area */
    .file-preview-area {
        max-width: 100%;
        box-sizing: border-box;
    }

    .file-preview-item {
        max-width: calc(50% - 4px);
    }

    /* Tools bar */
    .tools-bar {
        flex-shrink: 0;
    }

    /* Disclaimer - smaller on mobile */
    .finax-disclaimer {
        font-size: 10px;
        margin: 4px 0 0 0;
    }

    /* When keyboard is open, ensure proper scroll behavior */
    .chat-wrap:focus-within .messages-container {
        scroll-behavior: smooth;
    }

    /* Ensure welcome mode works properly with keyboard */
    .chat-wrap.is-welcome .finax-compose-area {
        margin-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* ===== Responsive - Small Mobile ===== */
@media screen and (max-width: 768px) {
    .user-msg {
        max-width: 90%;
    }

    .hsCodeDigit {
        font-size: 16px;
    }

    .customsHStax {
        font-size: 13px;
    }

    .agreementFlag {
        width: 20px;
        height: 20px;
    }
    
    /* Asimunim balance - mobile */
    .asimunim-balance {
        padding: 3px 8px;
        gap: 4px;
    }
    
    .asimunim-balance i {
        font-size: 12px;
    }
    
    .asimunim-value {
        font-size: 12px;
    }
}

/* =============================================
   DRAG AND DROP OVERLAY
   ============================================= */

.finax-drag-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(59, 130, 246, 0.15);
    border: 3px dashed #3b82f6;
    border-radius: 12px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.finax-drag-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.finax-drag-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: #3b82f6;
    text-align: center;
}

.finax-drag-overlay-content i {
    font-size: 48px;
    animation: bounce 1s ease infinite;
}

.finax-drag-overlay-content span {
    font-size: 18px;
    font-weight: 600;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */

.finax-toast {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1f2937;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    text-align: right;
}

.finax-toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.finax-toast-error {
    background: #dc2626;
}

.finax-toast-error i {
    color: #fecaca;
}

.finax-toast-success {
    background: #16a34a;
}

.finax-toast-success i {
    color: #bbf7d0;
}

.finax-toast i {
    font-size: 18px;
}

.finax-toast span {
    font-size: 14px;
    line-height: 1.4;
}

/* =============================================
   FEATURES POPUP (WHAT'S NEW)
   ============================================= */

#features-popup {
    backdrop-filter: blur(8px);
    background-color: rgba(0, 0, 0, 0.7);
}

.features-popup-container {
    background-color: #1b1c1d;
    border-radius: 20px;
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: featuresPopupIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes featuresPopupIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Slides Wrapper */
.features-slides-wrapper {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.features-slides {
    display: flex;
    transition: transform 0.4s ease-in-out;
    height: 100%;
}

.features-slide {
    min-width: 100%;
    display: flex;
    flex-direction: row;
    padding: 40px;
    gap: 40px;
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.features-slide.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

/* Slide Image */
.features-slide-image {
    flex: 0 0 45%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2a2b2d 0%, #1b1c1d 100%);
    border-radius: 16px;
    padding: 24px;
    overflow: hidden;
}

.features-slide-image img {
    max-width: 100%;
    max-height: 350px;
    object-fit: contain;
    border-radius: 8px;
}

/* Slide Content */
.features-slide-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: right;
}

.features-slide-title {
    font-size: 26px;
    font-family: "Rubik", sans-serif;
    font-weight: 600;
    color: #fff;
    margin: 0 0 20px 0;
    line-height: 1.4;
}

.features-slide-text {
    font-size: 16px;
    font-family: "Rubik", sans-serif;
    color: #b0b0b0;
    line-height: 1.8;
    margin: 0;
}

/* Navigation Dots */
.features-dots {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px 0;
}

.features-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #3a3b3d;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.features-dot:hover {
    background-color: #5a5b5d;
}

.features-dot.active {
    background-color: #741ea9;
    transform: scale(1.2);
}

/* Buttons */
.features-buttons {
    display: flex;
    justify-content: space-between;
    padding: 0 40px 30px 40px;
    gap: 16px;
}

.features-btn {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-family: "Rubik", sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.features-btn:active {
    transform: scale(0.98);
}

.features-btn-close {
    background-color: #3a3b3d;
    color: #d0d0d0;
}

.features-btn-close:hover {
    background-color: #4a4b4d;
}

.features-btn-next {
    background-color: #741ea9;
    color: #fff;
    min-width: 120px;
}

.features-btn-next:hover {
    background-color: #8a2bc4;
}

/* Features Close Dialog Customization */
.features-dialog-icon {
    background-color: rgba(116, 30, 169, 0.15) !important;
}

.features-dialog-icon i {
    color: #741ea9 !important;
}

.features-close-buttons {
    flex-direction: column;
    gap: 10px;
}

.features-close-buttons .finax-dialog-btn {
    flex: none;
    width: 100%;
}

#features-close-never {
    background-color: #741ea9;
}

#features-close-never:hover {
    background-color: #8a2bc4;
}

/* ===== Features Popup - Responsive - Tablet ===== */
@media screen and (max-width: 1024px) {
    .features-popup-container {
        max-width: 95%;
    }

    .features-slide {
        padding: 30px;
        gap: 30px;
    }

    .features-slide-image {
        flex: 0 0 40%;
    }

    .features-slide-title {
        font-size: 22px;
    }

    .features-slide-text {
        font-size: 15px;
    }

    .features-buttons {
        padding: 0 30px 24px 30px;
    }
}

/* ===== Features Popup - Responsive - Mobile ===== */
@media screen and (max-width: 768px) {
    .features-popup-container {
        width: 95%;
        max-height: 85vh;
        border-radius: 16px;
    }

    .features-slide {
        flex-direction: column;
        padding: 24px;
        gap: 20px;
        overflow-y: auto;
    }

    .features-slide-image {
        flex: 0 0 auto;
        height: 180px;
        padding: 16px;
    }

    .features-slide-image img {
        max-height: 150px;
    }

    .features-slide-content {
        flex: 1;
    }

    .features-slide-title {
        font-size: 20px;
        margin-bottom: 16px;
    }

    .features-slide-text {
        font-size: 14px;
        line-height: 1.7;
    }

    .features-dots {
        padding: 16px 0;
    }

    .features-buttons {
        padding: 0 24px 20px 24px;
        gap: 12px;
    }

    .features-btn {
        padding: 12px 24px;
        font-size: 15px;
    }
}

/* ===== Features Popup - Responsive - Small Mobile ===== */
@media screen and (max-width: 480px) {
    .features-popup-container {
        width: 98%;
        max-height: 90vh;
    }

    .features-slide {
        padding: 20px;
        gap: 16px;
    }

    .features-slide-image {
        height: 150px;
        padding: 12px;
    }

    .features-slide-image img {
        max-height: 120px;
    }

    .features-slide-title {
        font-size: 18px;
        margin-bottom: 12px;
    }

    .features-slide-text {
        font-size: 13px;
    }

    .features-buttons {
        padding: 0 20px 16px 20px;
        flex-direction: column-reverse;
    }

    .features-btn {
        width: 100%;
    }

    .features-btn-next {
        min-width: auto;
    }
}

/* =============================================
   MESSAGE LIMIT PROMPTS
   ============================================= */

.finax-limit-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 28px 24px;
    background: linear-gradient(145deg, #2a2b2d 0%, #1f2022 100%);
    border: 1px solid rgba(116, 30, 169, 0.35);
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    animation: limitPromptIn 0.4s cubic-bezier(0.2, 0.9, 0.2, 1);
    max-width: 100%;
}

@keyframes limitPromptIn {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.finax-limit-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(116, 30, 169, 0.25) 0%, rgba(116, 30, 169, 0.12) 100%);
    border-radius: 50%;
    flex-shrink: 0;
}

.finax-limit-icon i {
    font-size: 28px;
    color: #ab2ff7;
}

.finax-tokens-prompt .finax-limit-icon {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.25) 0%, rgba(255, 193, 7, 0.12) 100%);
}

.finax-tokens-prompt .finax-limit-icon i {
    color: #ffc107;
}

.finax-limit-message {
    font-size: 15px;
    font-family: "Rubik", sans-serif;
    font-weight: 400;
    color: #e0e0e0;
    line-height: 1.7;
    max-width: 320px;
}

.finax-limit-buttons {
    display: flex;
    flex-direction: row;
    gap: 12px;
    margin-top: 4px;
}

.finax-limit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    font-size: 14px;
    font-family: "Rubik", sans-serif;
    font-weight: 500;
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    min-width: 120px;
}

.finax-limit-btn-login {
    background-color: #741ea9;
    color: #fff;
}

.finax-limit-btn-login:hover {
    background-color: #8a2bc4;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(116, 30, 169, 0.35);
}

.finax-limit-btn-register {
    background-color: transparent;
    color: #ab2ff7;
    border: 1px solid rgba(171, 47, 247, 0.5);
}

.finax-limit-btn-register:hover {
    background-color: rgba(171, 47, 247, 0.1);
    border-color: #ab2ff7;
    transform: translateY(-1px);
}

/* ===== Limit Prompts - Responsive ===== */
@media screen and (max-width: 768px) {
    .finax-limit-prompt {
        padding: 24px 20px;
        gap: 14px;
    }

    .finax-limit-icon {
        width: 56px;
        height: 56px;
    }

    .finax-limit-icon i {
        font-size: 24px;
    }

    .finax-limit-message {
        font-size: 14px;
    }

    .finax-limit-buttons {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }

    .finax-limit-btn {
        width: 100%;
        padding: 12px 20px;
    }
}

@media screen and (max-width: 480px) {
    .finax-limit-prompt {
        padding: 20px 16px;
        gap: 12px;
        border-radius: 12px;
    }

    .finax-limit-icon {
        width: 48px;
        height: 48px;
    }

    .finax-limit-icon i {
        font-size: 20px;
    }

    .finax-limit-message {
        font-size: 13px;
        max-width: 280px;
    }
}