/**
 * Mstimaj AI Chat Interface Styles
 * Custom cyberpunk-themed AI chat experience
 */

/* ==========================================================================
   AI Chat Container
   ========================================================================== */

.mstimaj-ai-chat {
    position: fixed;
    z-index: 9999;
    font-family: var(--font-main);
}

/* ==========================================================================
   Floating AI Avatar Button
   ========================================================================== */

.ai-avatar-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    cursor: pointer;
    z-index: 10000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar-button:hover {
    transform: scale(1.1);
}

.ai-avatar-container {
    position: relative;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #00cc7a);
    padding: 3px;
    box-shadow: 0 8px 25px rgba(0, 255, 157, 0.3);
    animation: ai-float 3s ease-in-out infinite;
}

.ai-avatar-image {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-avatar-image img {
    width: 45px;
    height: 45px;
    object-fit: contain;
    filter: brightness(1.2);
}

.ai-pulse-ring {
    position: absolute;
    top: -10px;
    left: -10px;
    width: 90px;
    height: 90px;
    border: 2px solid var(--accent);
    border-radius: 50%;
    animation: ai-pulse 2s ease-out infinite;
    opacity: 0;
}

.ai-status-indicator {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid var(--primary);
}

.ai-status-indicator.online {
    background: #00ff00;
    box-shadow: 0 0 8px #00ff00;
}

.ai-avatar-tooltip {
    position: absolute;
    bottom: 80px;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: var(--text);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--accent);
    min-width: 200px;
    text-align: center;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.ai-avatar-button:hover .ai-avatar-tooltip {
    opacity: 1;
    transform: translateY(0);
}

.ai-avatar-tooltip span {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: var(--accent);
}

.ai-avatar-tooltip small {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* ==========================================================================
   Chat Window
   ========================================================================== */

.ai-chat-window {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 380px;
    height: 560px;
    background: linear-gradient(160deg, rgba(12, 12, 18, 0.98), rgba(18, 18, 28, 0.98));
    border: 1px solid rgba(0, 255, 157, 0.3);
    border-radius: 20px;
    display: none;
    flex-direction: column;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(0, 255, 157, 0.08);
    backdrop-filter: blur(16px);
    transform: scale(0.8) translateY(50px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
}

.ai-chat-window.open {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* Removed scanning line animation - was causing unwanted top border */

/* ==========================================================================
   Chat Header
   ========================================================================== */

.ai-chat-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0, 255, 157, 0.15);
    background: transparent;
    border-radius: 19px 19px 0 0;
}

.ai-chat-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #00cc7a);
    padding: 2px;
    margin-right: 12px;
    flex-shrink: 0;
}

.ai-chat-avatar img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    object-fit: contain;
    padding: 6px;
}

.ai-online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #00ff00;
    border: 2px solid var(--primary);
    border-radius: 50%;
    box-shadow: 0 0 6px #00ff00;
}

.ai-chat-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    font-family: var(--font-mono);
    line-height: 1.2;
}

.ai-chat-subtitle {
    margin: 2px 0 0 0;
    font-size: 12px;
    color: var(--accent);
    font-style: italic;
}

.ai-clear-chat {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0;
    margin-left: auto;
    opacity: 0.6;
}

.ai-clear-chat:hover {
    background: rgba(255, 165, 0, 0.1);
    color: #ffa500;
    opacity: 1;
}

.ai-chat-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
}

.ai-chat-close:hover {
    background: rgba(255, 68, 68, 0.1);
    color: #ff4444;
    opacity: 1;
}

/* ==========================================================================
   Messages Area
   ========================================================================== */

.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.ai-message {
    display: flex;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.ai-message.visible {
    opacity: 1;
    transform: translateY(0);
}

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

.ai-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.ai-message.user .ai-message-content {
    background: linear-gradient(135deg, var(--accent), #00cc7a);
    color: var(--primary);
    border-bottom-right-radius: 6px;
}

.ai-message.ai .ai-message-content {
    background: rgba(0, 0, 0, 0.6);
    color: var(--text);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-bottom-left-radius: 6px;
}

.ai-message-text {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
}

/* AI Message Links - High Visibility */
.ai-message.ai .ai-message-text a {
    color: var(--accent) !important;
    text-decoration: none;
    font-weight: 600;
    background: rgba(0, 255, 157, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid rgba(0, 255, 157, 0.3);
    transition: all 0.3s ease;
    display: inline-block;
    margin: 0 2px;
}

.ai-message.ai .ai-message-text a:hover {
    background: rgba(0, 255, 157, 0.2);
    border-color: var(--accent);
    color: #ffffff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 255, 157, 0.3);
}

.ai-message-time {
    font-size: 11px;
    opacity: 0.7;
    text-align: right;
}

.ai-message.ai .ai-message-time {
    color: var(--text-secondary);
}

.ai-message.user .ai-message-time {
    color: rgba(10, 10, 15, 0.7);
}

/* ==========================================================================
   Typing Indicator
   ========================================================================== */

.ai-typing-indicator {
    display: none;
    align-items: center;
    padding: 12px 20px;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
    margin-right: 8px;
}

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

.ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ==========================================================================
   Quick Actions
   ========================================================================== */

.ai-quick-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px 0;
    flex-wrap: wrap;
}

.ai-quick-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(0, 255, 157, 0.15);
    color: rgba(255, 255, 255, 0.7);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.ai-quick-btn:hover {
    background: rgba(0, 255, 157, 0.1);
    border-color: rgba(0, 255, 157, 0.4);
    color: var(--accent);
}

/* ==========================================================================
   Input Area
   ========================================================================== */

.ai-chat-input-container {
    border-top: 1px solid rgba(0, 255, 157, 0.1);
    background: transparent;
    border-radius: 0 0 19px 19px;
}

.ai-chat-form {
    padding: 14px 16px 16px;
}

.ai-input-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(0, 255, 157, 0.2);
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: all 0.3s ease;
}

.ai-input-wrapper:focus-within {
    border-color: rgba(0, 255, 157, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

/* Input field - NO rectangle border inside oval wrapper */
.ai-chat-input,
.ai-chat-input[type="text"],
input.ai-chat-input,
.ai-input-wrapper input,
.ai-input-wrapper input[type="text"] {
    flex: 1;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    border-width: 0 !important;
    border-style: none !important;
    border-color: transparent !important;
    color: var(--text);
    padding: 8px 0 !important;
    font-size: 14px;
    outline: none !important;
    outline-width: 0 !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    border-radius: 0 !important;
    margin: 0;
    min-width: 0;
}

.ai-chat-input:focus,
.ai-chat-input:active,
.ai-chat-input:hover,
.ai-chat-input[type="text"]:focus,
.ai-input-wrapper input:focus,
.ai-input-wrapper input:active,
.ai-input-wrapper input:hover {
    outline: none !important;
    outline-width: 0 !important;
    border: none !important;
    border-width: 0 !important;
    box-shadow: none !important;
    background: none !important;
    background-color: transparent !important;
}

.ai-chat-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.ai-send-button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: var(--primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.ai-send-button:hover {
    background: #00cc7a;
    transform: scale(1.1);
}

.ai-send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   Chat Overlay
   ========================================================================== */

.ai-chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 10000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-chat-overlay.open {
    opacity: 1;
}

/* ==========================================================================
   Animations
   ========================================================================== */

@keyframes ai-float {
    0%, 100% { 
        transform: translateY(0px); 
    }
    50% { 
        transform: translateY(-8px); 
    }
}

@keyframes ai-pulse {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    50% {
        opacity: 0.8;
    }
    100% {
        opacity: 0;
        transform: scale(1.4);
    }
}

@keyframes ai-scan {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}

@keyframes ai-typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ==========================================================================
   Custom Confirmation Dialog
   ========================================================================== */

.ai-confirm-dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 20, 0.95);
    backdrop-filter: blur(10px);
    z-index: 10002;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ai-confirm-dialog.show {
    opacity: 1;
}

.ai-confirm-content {
    background: var(--bg-secondary);
    border: 1px solid var(--accent);
    border-radius: 12px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 0 30px rgba(0, 255, 157, 0.3),
                0 0 60px rgba(0, 255, 157, 0.1);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.ai-confirm-dialog.show .ai-confirm-content {
    transform: scale(1);
}

.ai-confirm-icon {
    margin-bottom: 1.5rem;
}

.ai-confirm-icon svg {
    stroke: var(--accent);
    filter: drop-shadow(0 0 10px rgba(0, 255, 157, 0.5));
}

.ai-confirm-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ai-confirm-message {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
}

.ai-confirm-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.ai-confirm-cancel,
.ai-confirm-delete {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
}

.ai-confirm-cancel {
    background: var(--bg-hover);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-confirm-cancel:hover {
    background: var(--bg-primary);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.ai-confirm-delete {
    background: linear-gradient(135deg, #ff3366, #ff6b6b);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.3);
}

.ai-confirm-delete:hover {
    background: linear-gradient(135deg, #ff1a4d, #ff5252);
    box-shadow: 0 6px 20px rgba(255, 51, 102, 0.4);
    transform: translateY(-2px);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .ai-chat-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        border-radius: 0;
        border: none;
        border-top: 2px solid var(--accent);
    }

    .ai-chat-window::before {
        border-radius: 0;
    }

    .ai-chat-header {
        border-radius: 0;
        padding: 20px;
        padding-top: 30px; /* Add extra top padding to clear iPhone status bar */
    }

    .ai-chat-info h3 {
        font-size: 14px; /* Slightly smaller on mobile */
    }

    .ai-chat-subtitle {
        font-size: 11px; /* Slightly smaller on mobile */
    }

    .ai-avatar-button {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }

    .ai-avatar-container {
        width: 60px;
        height: 60px;
    }

    .ai-avatar-image {
        width: 54px;
        height: 54px;
    }

    .ai-avatar-tooltip {
        display: none;
    }

    .ai-quick-actions {
        padding: 12px 16px 0;
    }

    .ai-chat-form {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .ai-message-content {
        max-width: 90%;
    }

    .ai-quick-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
}