/* ============================================
   AI Chat Panel — Subworkit AI
   Glassmorphism chat panel for Subworkit3D globe
   Author: Bernard + GitHub Copilot
   Date: March 4, 2026
   ============================================ */

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes atlasFadeIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes atlasFadeOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(30px); }
}
@keyframes atlasPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.4); }
    50%      { box-shadow: 0 0 0 10px rgba(0, 212, 255, 0); }
}
@keyframes atlasDot {
    0%, 80%, 100% { transform: scale(0); }
    40%           { transform: scale(1); }
}
@keyframes atlasGlow {
    0%, 100% { opacity: 0.7; }
    50%      { opacity: 1; }
}
@keyframes atlasBubbleIn {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes atlasMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 100, 100, 0.5); }
    50%      { box-shadow: 0 0 0 12px rgba(255, 100, 100, 0); }
}

/* ============================================
   FLOATING CHAT BUBBLE (when panel is closed)
   ============================================ */
.atlas-chat-bubble {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4361ee, #a855f7);
    border: 2px solid rgba(168, 85, 247, 0.6);
    color: white;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: var(--z-panel, 300);
    box-shadow: 0 4px 20px rgba(67, 97, 238, 0.5);
    transition: all 0.3s ease;
    animation: atlasPulse 3s infinite;
}
.atlas-chat-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(67, 97, 238, 0.7);
}
.atlas-chat-bubble .atlas-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: var(--color-green, #22c55e);
    border-radius: 50%;
    border: 2px solid var(--bg-dark, #0a0a1a);
    animation: atlasGlow 2s infinite;
}

/* ============================================
   CHAT PANEL (slide-out)
   ============================================ */
.atlas-panel {
    position: fixed;
    top: var(--total-header-height, 110px);
    right: 0;
    width: 380px;
    bottom: 0;
    background: rgba(10, 10, 30, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid rgba(168, 85, 247, 0.25);
    z-index: var(--z-panel, 300);
    display: flex;
    flex-direction: column;
    font-family: var(--font-main, 'Segoe UI', system-ui, sans-serif);
    animation: atlasFadeIn 0.3s ease-out;
    box-shadow: -4px 0 30px rgba(0, 0, 0, 0.5);
}
.atlas-panel.closing {
    animation: atlasFadeOut 0.25s ease-in forwards;
}
.atlas-panel.hidden {
    display: none;
}

/* ============================================
   HEADER
   ============================================ */
.atlas-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 15, 35, 0.6);
    flex-shrink: 0;
}
.atlas-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4361ee, #a855f7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 10px;
    flex-shrink: 0;
}
.atlas-header-info {
    flex: 1;
}
.atlas-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.3px;
}
.atlas-header-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 4px;
}
.atlas-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-green, #22c55e);
    animation: atlasGlow 2s infinite;
}
.atlas-status-dot.offline {
    background: var(--color-red, #ff6464);
    animation: none;
}
.atlas-header-actions {
    display: flex;
    gap: 4px;
}
.atlas-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.atlas-header-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.atlas-header-btn.active {
    background: rgba(0, 212, 255, 0.15);
    color: var(--color-cyan, #00D4FF);
    border-color: rgba(0, 212, 255, 0.3);
}

/* ============================================
   QUICK ACTIONS (pill buttons)
   ============================================ */
.atlas-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.atlas-pill {
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.25);
    color: rgba(255, 255, 255, 0.8);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}
.atlas-pill:hover {
    background: rgba(168, 85, 247, 0.25);
    color: #fff;
    border-color: var(--color-purple, #a855f7);
}
.atlas-pill .pill-icon {
    margin-right: 4px;
}

/* ============================================
   MESSAGE AREA
   ============================================ */
.atlas-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.atlas-messages::-webkit-scrollbar {
    width: 4px;
}
.atlas-messages::-webkit-scrollbar-track {
    background: transparent;
}
.atlas-messages::-webkit-scrollbar-thumb {
    background: rgba(168, 85, 247, 0.3);
    border-radius: 4px;
}

/* Message bubbles */
.atlas-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    animation: atlasBubbleIn 0.25s ease-out;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.atlas-msg.ai {
    align-self: flex-start;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.2);
    color: rgba(255, 255, 255, 0.92);
    border-bottom-left-radius: 4px;
}
.atlas-msg.user {
    align-self: flex-end;
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.25);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.atlas-msg .msg-meta {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 4px;
}
.atlas-msg.ai .msg-actions {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.atlas-msg .msg-action-btn {
    padding: 3px 8px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.atlas-msg .msg-action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* Typing indicator */
.atlas-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 18px;
    background: rgba(168, 85, 247, 0.1);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
}
.atlas-typing .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(168, 85, 247, 0.6);
    animation: atlasDot 1.4s ease-in-out infinite both;
}
.atlas-typing .dot:nth-child(2) { animation-delay: 0.16s; }
.atlas-typing .dot:nth-child(3) { animation-delay: 0.32s; }

/* Welcome message */
.atlas-welcome {
    text-align: center;
    padding: 24px 16px;
    color: rgba(255, 255, 255, 0.5);
}
.atlas-welcome-icon {
    font-size: 40px;
    margin-bottom: 8px;
    display: block;
}
.atlas-welcome-title {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 4px;
}
.atlas-welcome-text {
    font-size: 12px;
    line-height: 1.5;
}

/* ============================================
   INPUT BAR
   ============================================ */
.atlas-input-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 15, 35, 0.6);
    flex-shrink: 0;
}
.atlas-input-field {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 10px 16px;
    color: #fff;
    font-size: 13px;
    font-family: var(--font-main, 'Segoe UI', system-ui, sans-serif);
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
}
.atlas-input-field::placeholder {
    color: rgba(255, 255, 255, 0.3);
}
.atlas-input-field:focus {
    border-color: rgba(168, 85, 247, 0.5);
}
.atlas-input-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}
.atlas-send-btn {
    background: linear-gradient(135deg, #4361ee, #a855f7);
    color: white;
}
.atlas-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 12px rgba(67, 97, 238, 0.4);
}
.atlas-send-btn:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}
.atlas-mic-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.6);
}
.atlas-mic-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}
.atlas-mic-btn.listening {
    background: rgba(255, 100, 100, 0.2);
    border-color: rgba(255, 100, 100, 0.5);
    color: var(--color-red, #ff6464);
    animation: atlasMicPulse 1.5s infinite;
}

/* ============================================
   MUSIC PLAYER (collapsible section)
   ============================================ */
.atlas-music {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}
.atlas-music.expanded {
    max-height: 200px;
}
.atlas-music-inner {
    padding: 12px 16px;
}
.atlas-music-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.atlas-music-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}
.atlas-music-now {
    font-size: 11px;
    color: var(--color-cyan, #00D4FF);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Genre buttons */
.atlas-genres {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.atlas-genre-btn {
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.atlas-genre-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.atlas-genre-btn.active {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.5);
    color: var(--color-purple, #a855f7);
}

/* Player controls */
.atlas-player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.atlas-player-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.atlas-player-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}
.atlas-player-btn.playing {
    background: rgba(168, 85, 247, 0.25);
    border-color: rgba(168, 85, 247, 0.5);
    color: var(--color-purple, #a855f7);
}
.atlas-volume-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}
.atlas-volume-icon {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
}
.atlas-volume-slider {
    flex: 1;
    -webkit-appearance: none;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.15);
    outline: none;
}
.atlas-volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-purple, #a855f7);
    cursor: pointer;
}
.atlas-volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-purple, #a855f7);
    cursor: pointer;
    border: none;
}

/* ============================================
   AUDIO MODE SWITCHER (3-state: Music / Talk / Mute)
   ============================================ */
.atlas-audio-mode {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(10, 10, 30, 0.4);
    flex-shrink: 0;
}
.atlas-audio-mode-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.35);
    margin-right: 6px;
    font-weight: 600;
}
.atlas-mode-btn {
    flex: 1;
    padding: 6px 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
    letter-spacing: 0.3px;
}
.atlas-mode-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}
.atlas-mode-btn.active-music {
    background: rgba(168, 85, 247, 0.2);
    border-color: rgba(168, 85, 247, 0.5);
    color: var(--color-purple, #a855f7);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.15);
}
.atlas-mode-btn.active-talk {
    background: rgba(0, 212, 255, 0.15);
    border-color: rgba(0, 212, 255, 0.4);
    color: var(--color-cyan, #00D4FF);
    box-shadow: 0 0 12px rgba(0, 212, 255, 0.15);
}
.atlas-mode-btn.active-mute {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.5);
}
.atlas-mode-icon {
    font-size: 14px;
    display: block;
    margin-bottom: 2px;
}

/* Speaking indicator overlay on bubble */
.atlas-chat-bubble.speaking {
    animation: atlasPulse 1.2s infinite;
    border-color: rgba(0, 212, 255, 0.8);
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.5);
}

/* Narrator flight banner (shows at top during auto-narration) */
.atlas-narrator-banner {
    position: fixed;
    top: calc(var(--total-header-height, 110px) + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 10, 30, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 212, 255, 0.3);
    border-radius: 24px;
    padding: 8px 20px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    font-family: var(--font-main, 'Segoe UI', system-ui, sans-serif);
    z-index: calc(var(--z-panel, 300) + 1);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: atlasBubbleIn 0.3s ease-out;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    max-width: 90%;
    pointer-events: none;
}
.atlas-narrator-banner.hidden {
    display: none;
}
.atlas-narrator-pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-cyan, #00D4FF);
    animation: atlasGlow 1.5s infinite;
    flex-shrink: 0;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .atlas-panel {
        width: 100%;
        top: 0;
        border-left: none;
    }
    .atlas-chat-bubble {
        bottom: 70px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }
}
@media (max-width: 480px) {
    .atlas-quick-actions {
        padding: 8px 12px;
    }
    .atlas-messages {
        padding: 12px;
    }
    .atlas-input-bar {
        padding: 10px 12px;
    }
}

/* ============================================
   TAB BAR
   ============================================ */

.atlas-tab-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0;
    flex-shrink: 0;
}

.atlas-tab {
    flex: 1;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    font-weight: 500;
    padding: 10px 6px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
    font-family: inherit;
}

.atlas-tab:hover {
    color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.04);
}

.atlas-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background: rgba(96, 165, 250, 0.08);
}

/* ============================================
   TAB CONTENT
   ============================================ */

.atlas-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.atlas-tab-content.active {
    display: flex;
}

.atlas-tab-loading {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 40px;
}

.atlas-tab-loading .dot {
    width: 8px;
    height: 8px;
    background: #60a5fa;
    border-radius: 50%;
    animation: atlasDotPulse 1.4s ease-in-out infinite;
}

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

.atlas-tab-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    color: rgba(255, 255, 255, 0.5);
}

/* ============================================
   SERVICE & REQUEST CARDS
   ============================================ */

.atlas-services-list,
.atlas-requests-list {
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.atlas-service-card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 14px;
    transition: all 0.2s;
}

.atlas-service-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(96, 165, 250, 0.3);
}

.atlas-service-card.request {
    border-left: 3px solid #f59e0b;
}

.svc-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 4px;
}

.svc-card-title {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.svc-card-badge {
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex-shrink: 0;
}

.svc-card-badge.subworkit {
    background: rgba(96, 165, 250, 0.2);
    color: #60a5fa;
}

.svc-card-badge.google {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
}

.svc-card-urgency {
    font-size: 11px;
    flex-shrink: 0;
}

.svc-card-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}

.svc-card-rating {
    font-size: 12px;
    color: #fbbf24;
    margin-bottom: 4px;
}

.svc-card-desc {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
}

.svc-card-actions {
    margin-top: 8px;
    display: flex;
    gap: 6px;
}

.atlas-pill.small {
    font-size: 11px;
    padding: 4px 10px;
}

.atlas-section-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 11px;
    margin: 8px 0;
}

.atlas-section-divider::before,
.atlas-section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

@keyframes atlasDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}
