/* 
   Explyra CRM — AI assistant premium styles
   Designed for high-performance CRM interactions.
*/

:root {
    --crm-ai-primary: #0070f3;
    --crm-ai-bg: #ffffff;
    --crm-ai-item-bg: #f9f9f9;
    --crm-ai-text: #000000;
    --crm-ai-border: #eaeaea;
    --crm-ai-shadow: 0 4px 14px 0 rgba(0,0,0,0.1);
}

.dark {
    --crm-ai-primary: #0070f3;
    --crm-ai-bg: #000000;
    --crm-ai-item-bg: #111111;
    --crm-ai-text: #ffffff;
    --crm-ai-border: #333333;
    --crm-ai-shadow: 0 4px 14px 0 rgba(0,0,0,0.39);
}

.crm-ai-panel-toggle {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 32px;
    height: 100px;
    background: var(--crm-ai-primary);
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 12px 0 0 12px;
    z-index: 1001;
    box-shadow: -2px 0 10px rgba(0,0,0,0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-ai-panel-toggle:hover {
    width: 40px;
    background: #0060df;
}

.crm-ai-panel-toggle i {
    font-size: 0.9rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 2px;
    margin-top: 5px;
}

.crm-ai-window {
    position: fixed;
    top: 0;
    right: -450px; /* Initially hidden */
    width: 450px;
    height: 100vh;
    background: var(--crm-ai-bg);
    border-left: 1px solid var(--crm-ai-border);
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    z-index: 1000;
    overflow: hidden;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.crm-ai-window.open {
    right: 0;
}

@keyframes crmAiPop {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.crm-ai-header {
    padding: 1rem 1.25rem;
    background: var(--crm-ai-bg);
    border-bottom: 1px solid var(--crm-ai-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crm-ai-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--crm-ai-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

.crm-ai-title h4 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--crm-ai-text);
}

.crm-ai-title p {
    font-size: 0.7rem;
    color: #888;
}

.crm-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--crm-ai-border) transparent;
}

.crm-ai-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    border-radius: 12px;
    position: relative;
    word-wrap: break-word;
}

.crm-ai-msg.ai {
    align-self: flex-start;
    background: var(--crm-ai-item-bg);
    color: var(--crm-ai-text);
    border: 1px solid var(--crm-ai-border);
    border-bottom-left-radius: 2px;
}

.crm-ai-msg.user {
    align-self: flex-end;
    background: var(--crm-ai-primary);
    color: #fff;
    border-bottom-right-radius: 2px;
}

.crm-ai-input-area {
    padding: 1.25rem;
    border-top: 1px solid var(--crm-ai-border);
    background: var(--crm-ai-bg);
    display: flex;
    gap: 10px;
}

.crm-ai-input {
    flex: 1;
    background: var(--crm-ai-item-bg);
    border: 1px solid var(--crm-ai-border);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    font-size: 0.85rem;
    color: var(--crm-ai-text);
    outline: none;
    transition: border-color 0.2s;
}

.crm-ai-input:focus {
    border-color: var(--crm-ai-primary);
}

.crm-ai-send {
    background: var(--crm-ai-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: opacity 0.2s;
}

.crm-ai-send:hover { opacity: 0.9; }

.crm-ai-close {
    cursor: pointer;
    color: #888;
    font-size: 1.2rem;
    transition: color 0.2s;
}

.crm-ai-close:hover { color: var(--crm-ai-text); }

/* Quick Actions */
.crm-ai-quick {
    display: flex;
    gap: 8px;
    padding: 0 1.25rem 0.75rem;
    flex-wrap: wrap;
}

.crm-ai-quick::-webkit-scrollbar { display: none; }

.quick-btn {
    white-space: nowrap;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--crm-ai-border);
    background: var(--crm-ai-item-bg);
    color: var(--crm-ai-text);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    border-color: var(--crm-ai-primary);
    color: var(--crm-ai-primary);
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: var(--crm-ai-item-bg);
    border-radius: 12px;
    align-self: flex-start;
}

.dot {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: crmDot 1.4s infinite ease-in-out both;
}

@keyframes crmDot {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

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

/* Tab Mode Overrides */
.crm-ai-window.tab-mode {
    position: relative;
    right: 0;
    width: 100%;
    height: 100%;
    border-left: none;
    box-shadow: none;
    max-height: calc(100vh - 8rem);
}

/* Quick Create Dropdown */
.crm-ai-dropdown {
    position: relative;
    display: inline-block;
}

.crm-ai-dropbtn {
    background: var(--crm-ai-primary);
    color: white;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

.crm-ai-dropdown-content {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: var(--crm-ai-bg);
    min-width: 140px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    z-index: 1005;
    border: 1px solid var(--crm-ai-border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.crm-ai-dropdown-content button {
    color: var(--crm-ai-text);
    padding: 10px 14px;
    text-decoration: none;
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.crm-ai-dropdown-content button:hover {
    background: var(--crm-ai-item-bg);
}

.crm-ai-dropdown:hover .crm-ai-dropdown-content {
    display: block;
}

/* Responsive */
@media (max-width: 480px) {
    .crm-ai-window {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }
}
