/* ===== SandBox AI+ERP Custom Styles ===== */

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #0a0a0f; }
::-webkit-scrollbar-thumb { background: #1e1e30; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #2a2a40; }
.scrollbar-thin::-webkit-scrollbar { width: 4px; }

/* Gradient text animation */
@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.animate-gradient { animation: gradient 4s ease infinite; }

@keyframes glow { from { box-shadow: 0 0 20px rgba(0,212,255,0.1); } to { box-shadow: 0 0 40px rgba(0,212,255,0.2); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Navbar scroll state */
#navbar { transition: background-color 0.3s, backdrop-filter 0.3s, border-color 0.3s; }
#navbar.scrolled {
    background-color: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ========================================================= */
/* ===== CINEMATIC MORPH PRELOADER =========================  */
/* ========================================================= */

#preloader {
    position: fixed; inset: 0; z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(ellipse at center, #0c1220 0%, #070b12 70%);
    transition: opacity 0.8s cubic-bezier(0.4,0,0.2,1), visibility 0.8s;
    overflow: hidden;
}
#preloader.fade-out {
    opacity: 0; visibility: hidden; pointer-events: none;
}
body.loading { overflow: hidden; }

/* Scanline sweep */
.morph-scanline {
    position: absolute; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #2ea6d480, #c9a84c60, transparent);
    animation: scanlineMove 3s ease-in-out infinite;
    z-index: 1;
    opacity: 0.4;
}
@keyframes scanlineMove {
    0% { top: 10%; opacity: 0; }
    10% { opacity: 0.4; }
    90% { opacity: 0.4; }
    100% { top: 90%; opacity: 0; }
}

/* Stage container */
.morph-stage {
    position: relative; z-index: 10;
    display: flex; flex-direction: column; align-items: center;
    gap: 24px;
}

/* SVG container */
.morph-container {
    width: 240px; height: 240px;
    position: relative;
    transition: transform 0.1s linear;
    will-change: transform;
}
.morph-container svg {
    width: 100%; height: 100%;
    overflow: visible;
}

/* Phase label */
.morph-phase-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 4px;
    color: #c9a84c;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.3s ease;
    min-height: 16px;
}

/* Progress bar */
.morph-progress-track {
    width: 200px;
    height: 2px;
    background: rgba(255,255,255,0.06);
    border-radius: 1px;
    overflow: hidden;
    position: relative;
}
.morph-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2ea6d4, #c9a84c, #c0392b);
    border-radius: 1px;
    transition: width 0.15s linear;
    position: relative;
}
.morph-progress-fill::after {
    content: '';
    position: absolute;
    right: 0; top: -3px;
    width: 8px; height: 8px;
    background: #c9a84c;
    border-radius: 50%;
    box-shadow: 0 0 12px #c9a84c80, 0 0 24px #c9a84c40;
}

/* Status text */
.morph-status {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #6b7280;
    transition: opacity 0.3s ease, transform 0.3s ease;
    min-height: 18px;
}

/* HUD corners */
.hud-corner { position: absolute; }
.hud-tl { top: 20px; left: 20px; }
.hud-tr { top: 20px; right: 20px; }
.hud-bl { bottom: 20px; left: 20px; }
.hud-br { bottom: 20px; right: 20px; }

/* Responsive */
@media (max-width: 480px) {
    .morph-container { width: 180px; height: 180px; }
    .morph-progress-track { width: 160px; }
    .morph-phase-label { font-size: 9px; letter-spacing: 3px; }
}

/* ========================================================= */
/* ===== AI CHAT WIDGET ==================================== */
/* ========================================================= */

#ai-chat-fab {
    position: fixed; bottom: 24px; right: 24px; z-index: 9998;
    width: 60px; height: 60px; border-radius: 16px;
    background: linear-gradient(135deg, #a855f7, #00d4ff);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0,212,255,0.3), 0 0 0 0 rgba(168,85,247,0.4);
    transition: all 0.3s ease;
    animation: fabPulse 3s ease-in-out infinite;
}
#ai-chat-fab:hover { transform: scale(1.1); box-shadow: 0 12px 40px rgba(0,212,255,0.4); }
#ai-chat-fab .fab-icon { font-size: 24px; color: white; transition: transform 0.3s; }
#ai-chat-fab.open .fab-icon { transform: rotate(90deg); }
#ai-chat-fab .fab-badge {
    position: absolute; top: -4px; right: -4px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #10b981; border: 2px solid #0a0a0f;
    display: flex; align-items: center; justify-content: center;
}
#ai-chat-fab .fab-badge::after {
    content: ''; width: 6px; height: 6px;
    background: white; border-radius: 50%; animation: pulse 2s infinite;
}
@keyframes fabPulse {
    0%, 100% { box-shadow: 0 8px 32px rgba(0,212,255,0.3), 0 0 0 0 rgba(168,85,247,0.4); }
    50% { box-shadow: 0 8px 32px rgba(0,212,255,0.3), 0 0 0 12px rgba(168,85,247,0); }
}

#ai-chat-panel {
    position: fixed; bottom: 100px; right: 24px; z-index: 9999;
    width: 400px; max-width: calc(100vw - 32px); max-height: calc(100vh - 140px);
    border-radius: 20px;
    background: rgba(15, 15, 26, 0.95);
    backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 24px 80px rgba(0,0,0,0.6), 0 0 60px rgba(0,212,255,0.05);
    display: flex; flex-direction: column; overflow: hidden;
    transform: translateY(20px) scale(0.95); opacity: 0; visibility: hidden;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#ai-chat-panel.open { transform: translateY(0) scale(1); opacity: 1; visibility: visible; }

.chat-header {
    padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.05);
    background: rgba(10, 10, 15, 0.5);
    display: flex; align-items: center; gap: 12px;
}
.chat-header-avatar {
    width: 40px; height: 40px; border-radius: 12px;
    background: linear-gradient(135deg, #a855f7, #00d4ff);
    display: flex; align-items: center; justify-content: center;
    position: relative; flex-shrink: 0;
}
.chat-header-avatar .online-dot {
    position: absolute; bottom: -2px; right: -2px;
    width: 12px; height: 12px; background: #10b981;
    border-radius: 50%; border: 2px solid #0f0f1a;
}
.chat-header-info h4 { font-size: 14px; font-weight: 600; color: white; }
.chat-header-info p { font-size: 11px; color: #10b981; display: flex; align-items: center; gap: 4px; }
.chat-minimize {
    margin-left: auto; width: 32px; height: 32px; border-radius: 8px;
    background: rgba(255,255,255,0.05); border: none; color: #9ca3af;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s;
}
.chat-minimize:hover { background: rgba(255,255,255,0.1); color: white; }

.chat-messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 16px;
    min-height: 300px; max-height: 400px;
}
.chat-msg { display: flex; gap: 10px; animation: slideUp 0.3s ease-out; }
.chat-msg.user { flex-direction: row; }
.chat-msg.bot { flex-direction: row-reverse; justify-content: flex-start; }
.chat-msg .avatar {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; font-size: 12px;
}
.chat-msg.user .avatar { background: rgba(0,212,255,0.15); color: #00d4ff; }
.chat-msg.bot .avatar { background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(0,212,255,0.2)); color: #a855f7; }
.chat-msg .bubble {
    max-width: 85%; padding: 12px 16px; border-radius: 16px;
    font-size: 13px; line-height: 1.5; color: #e5e7eb;
}
.chat-msg.user .bubble {
    background: rgba(30, 30, 48, 0.6); border: 1px solid rgba(255,255,255,0.05);
    border-top-left-radius: 4px;
}
.chat-msg.bot .bubble {
    background: linear-gradient(135deg, rgba(168,85,247,0.1), rgba(0,212,255,0.1));
    border: 1px solid rgba(168,85,247,0.15); border-top-right-radius: 4px;
}
.chat-msg.bot .bubble strong { color: white; }
.chat-msg.bot .bubble .metric-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 12px; }
.chat-msg.bot .bubble .metric-row .val { font-family: 'JetBrains Mono', monospace; color: #10b981; }

.typing-indicator { display: flex; align-items: center; gap: 4px; padding: 4px 0; }
.typing-indicator span {
    width: 7px; height: 7px; border-radius: 50%; background: #a855f7;
    animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.chat-suggestions { padding: 0 20px 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.chat-suggestions button {
    padding: 6px 12px; font-size: 11px;
    background: rgba(30, 30, 48, 0.5); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 20px; color: #9ca3af; cursor: pointer; transition: all 0.2s; white-space: nowrap;
}
.chat-suggestions button:hover { color: #00d4ff; border-color: rgba(0,212,255,0.3); background: rgba(0,212,255,0.05); }

.chat-input-area { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.05); background: rgba(10, 10, 15, 0.3); }
.chat-input-wrap {
    display: flex; align-items: center; gap: 10px;
    background: rgba(30, 30, 48, 0.5); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px; padding: 8px 12px; transition: border-color 0.2s;
}
.chat-input-wrap:focus-within { border-color: rgba(168,85,247,0.3); }
.chat-input-wrap input { flex: 1; background: transparent; border: none; outline: none; color: #e5e7eb; font-size: 13px; }
.chat-input-wrap input::placeholder { color: #4b5563; }
.chat-send-btn {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, #a855f7, #00d4ff);
    border: none; color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; flex-shrink: 0;
}
.chat-send-btn:hover { transform: scale(1.05); box-shadow: 0 4px 16px rgba(0,212,255,0.3); }

@media (max-width: 480px) {
    #ai-chat-panel { right: 8px; left: 8px; bottom: 90px; width: auto; max-height: calc(100vh - 120px); }
    #ai-chat-fab { bottom: 16px; right: 16px; width: 52px; height: 52px; }
}

/* Language Toggle */
.lang-toggle { cursor: pointer; transition: all 0.3s ease; }
.lang-toggle:hover { background: rgba(201, 168, 76, 0.1) !important; border-color: rgba(201, 168, 76, 0.3) !important; transform: scale(1.05); }
.lang-toggle:active { transform: scale(0.95); }
