/* Chatbot & Assistant Global Styles */
:root {
    --ai-bubble-bg: rgba(255, 255, 255, 0.05);
    --user-bubble-bg: rgba(255, 203, 5, 0.1);
    --ai-accent: #ffcb05;
    --card-bg: rgba(14, 14, 18, 0.7);
    --radius-md: 20px;
    --transition-smooth: 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- WIDGET MODE (Floating) --- */
#tm-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ai-accent);
    color: #000;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(255, 203, 5, 0.3);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#tm-chat-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 15px 30px rgba(255, 203, 5, 0.5);
}

/* --- ANNOTATION TOOLTIP --- */
#tm-chat-annotation {
    position: fixed;
    bottom: 40px;
    right: 105px;
    background: rgba(13, 13, 15, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 203, 5, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    color: #fff;
    font-size: 14px;
    width: 240px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 10000;
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#tm-chat-annotation.visible {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
    animation: pulseAnnotation 2s infinite alternate;
}

#tm-chat-annotation::after {
    content: "";
    position: absolute;
    top: 50%;
    right: -6px;
    transform: translateY(-50%);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 6px solid rgba(255, 203, 5, 0.3);
}

.tm-annotation-close {
    position: absolute;
    top: -8px;
    left: -8px;
    background: #ff3b3b;
    color: #fff;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

@keyframes pulseAnnotation {
    from { box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
    to { box-shadow: 0 10px 40px rgba(255, 203, 5, 0.2); }
}

#tm-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    background: rgba(13, 13, 15, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    z-index: 9998;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

#tm-chat-widget.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.tm-chat-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    background: var(--ai-accent);
    color: #000;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.tm-chat-header-info h4 { margin: 0; font-size: 1rem; }
.tm-chat-header-info p { margin: 0; font-size: 0.75rem; color: var(--text-muted); }

/* --- MESSAGING SYSTEM --- */
#tm-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.tm-msg-wrapper {
    display: flex;
    gap: 12px;
    max-width: 95%;
    position: relative;
    margin-bottom: 20px;
}  

.tm-msg-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.tm-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.tm-msg-wrapper.ai .tm-msg-avatar {
    background: var(--ai-accent);
    color: #000;
}

.tm-msg-bubble {
    padding: 12px 18px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    word-wrap: break-word;
    color: #e0e0e0;
}

.tm-msg-wrapper.ai .tm-msg-bubble {
    background: var(--ai-bubble-bg);
    width: 100%;
}

.tm-msg-wrapper.user .tm-msg-bubble {
    background: var(--user-bubble-bg);
    border: 1px solid rgba(255, 203, 5, 0.2);
    cursor: default;
}

.tm-chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    margin-bottom: 10px;
    display: block;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tm-chat-text {
    line-height: 1.6;
}

/* --- EDITABLE MESSAGES --- */
.tm-edit-btn {
    position: absolute;
    bottom: -22px;
    right: 5px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0.7; /* Always visible */
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
}

.tm-msg-wrapper.user:hover .tm-edit-btn {
    opacity: 0.9;
}

.tm-edit-btn:hover {
    opacity: 1 !important;
    color: var(--ai-accent);
    background: rgba(255, 255, 255, 0.05);
}

.tm-edit-area {
    width: 100%;
    min-height: 60px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ai-accent);
    border-radius: 8px;
    color: #fff;
    padding: 10px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    outline: none;
    margin-bottom: 10px;
}

.tm-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.tm-btn-small {
    padding: 5px 12px;
    font-size: 0.75rem;
    border-radius: 6px;
    font-weight: 600;
}

/* --- PRODUCT GRID & CARDS (Professional Luxe) --- */
.tm-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin: 30px 0;
    width: 100%;
}

.tm-product-card {
    background: rgba(255, 255, 255, 0.02) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 30px !important;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    cursor: pointer;
    transition: all 0.5s var(--transition-smooth) !important;
    backdrop-filter: blur(5px);
}

.tm-product-card:hover {
    transform: translateY(-10px) scale(1.02);
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: var(--ai-accent) !important;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
}

.tm-card-media {
    position: relative;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
}

.tm-card-media::after {
    content: "";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.6));
    z-index: 1;
}

.tm-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tm-software-pill {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #000;
    color: #fff;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 900;
    z-index: 5;
}

.tm-card-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tm-type-badge {
    color: var(--ai-accent);
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 14px;
    background: rgba(255, 203, 5, 0.08);
    border-radius: 100px;
    width: fit-content;
}

.tm-card-content h5 {
    font-size: 1.4rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
}

.tm-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.tm-price-tag {
    color: var(--ai-accent);
    font-size: 1.6rem;
    font-weight: 800;
}

.tm-view-details-btn {
    background: var(--ai-accent);
    color: #000;
    padding: 12px 25px;
    border-radius: 100px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.tm-view-details-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

/* --- UI POLISH --- */
.tm-copy-btn {
    position: absolute;
    top: 5px;
    right: 15px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.tm-msg-bubble:hover .tm-copy-btn { opacity: 1; }

.tm-typing {
    display: flex;
    gap: 4px;
    padding: 15px 20px !important;
}

.tm-typing span {
    width: 6px;
    height: 6px;
    background: var(--ai-accent);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

.tm-chat-input-container {
    padding: 15px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.tm-input-wrapper {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#tm-chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 10px 0;
    font-size: 0.95rem;
}

#tm-chat-input:focus { outline: none; }

.tm-chat-actions { display: flex; gap: 5px; }

.tm-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 1.1rem;
    transition: color 0.3s;
}

.tm-action-btn:hover { color: var(--accent-primary); }

#tm-upload-preview {
    display: none;
    padding: 10px;
    position: relative;
    width: 60px;
}

#tm-upload-preview img {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    object-fit: cover;
}

.tm-remove-upload {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ff3b3b;
    color: #fff;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* --- SIDEBAR ENHANCEMENTS --- */
.history-item {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px !important;
    margin-bottom: 5px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    color: #ccc;
    position: relative;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.history-item.active {
    background: rgba(255, 203, 5, 0.1) !important;
    border-right: 2px solid var(--ai-accent);
    color: #fff;
}

.history-item-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.history-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.history-item:hover .history-actions {
    opacity: 1;
}

.history-action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    padding: 4px;
    border-radius: 4px;
}

.history-action-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.history-action-btn.delete:hover {
    color: #ff4444;
}

.title-edit-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--ai-accent);
    color: #fff;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    width: 100%;
    outline: none;
}

/* --- CUSTOM MODAL SYSTEM --- */
.tm-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tm-modal-overlay.active {
    display: flex;
    opacity: 1;
}

.tm-modal-card {
    background: #121215;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    width: 90%;
    max-width: 400px;
    padding: 30px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.tm-modal-overlay.active .tm-modal-card {
    transform: scale(1);
}

.tm-modal-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 203, 5, 0.1);
    color: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 20px;
}

.tm-modal-header h4 {
    margin: 0 0 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.tm-modal-body p {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 25px;
}

.tm-modal-footer {
    display: flex;
    gap: 12px;
}

.tm-modal-footer button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.9rem;
}

.tm-modal-footer .btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.tm-modal-footer .btn-primary {
    background: var(--accent-primary);
    border: none;
    color: #000;
}

.tm-modal-footer button:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.history-label-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 5px;
}

.clear-all-btn {
    font-size: 0.65rem;
    color: #ff4444;
    cursor: pointer;
    background: rgba(255, 68, 68, 0.1);
    padding: 4px 10px;
    border-radius: 100px;
    transition: all 0.3s;
    border: 1px solid rgba(255, 68, 68, 0.2);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.clear-all-btn:hover {
    background: #ff4444;
    color: #fff;
    transform: scale(1.05);
}
