/**
 * Merlin AI 3D Card - Integrated Reference Design CSS
 * Exact styling from reference with GemBot functionality
 */

/* Reset for card scope */
#merlin-ai-card-integrated * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Main Card Container */
.merlin-card-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 640px;
    perspective: 1000px;
    z-index: 500;
    font-family: 'Cinzel', 'Georgia', serif;
}

/* Magical Background - subtle stars and nebula */
.magical-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse 1200px 600px at 50% 100%, rgba(20, 20, 35, 0.3) 0%, transparent 80%),
        radial-gradient(ellipse 800px 400px at 20% 50%, rgba(25, 15, 30, 0.2) 0%, transparent 70%);
    animation: subtle-pulse 12s ease-in-out infinite alternate;
    z-index: -1;
    pointer-events: none;
}

@keyframes subtle-pulse {
    0% { opacity: 0.6; }
    100% { opacity: 0.8; }
}

/* Flip Container */
.card-container {
    perspective: 1000px;
    position: relative;
    width: 100%;
    height: 100%;
}

.card-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.card-container.flipped .card-flip-inner {
    transform: rotateY(180deg);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 15px;
    background: linear-gradient(180deg, #0a0a0f 0%, #151520 30%, #1a1a25 70%, #0f0f1a 100%);
}

.card-front {
    transform: rotateY(0deg);
    z-index: 2;
}

.card-back {
    transform: rotateY(180deg);
    z-index: 1;
}

/* Glass Blocker - prevents bleed-through */
.glass-blocker {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(ellipse at 30% 20%, rgba(15, 15, 25, 0.8) 0%, transparent 60%),
        radial-gradient(ellipse at 70% 80%, rgba(20, 15, 25, 0.7) 0%, transparent 60%),
        rgba(10, 10, 20, 0.9);
    border-radius: 15px;
    z-index: 0;
}

/* Card Glow Effect */
.card-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 15px;
    background: linear-gradient(
        135deg, 
        rgba(255,255,255,0.08) 0%, 
        transparent 30%, 
        transparent 70%, 
        rgba(255,255,255,0.04) 100%
    );
    z-index: 2;
    pointer-events: none;
}

/* Card Frame - main glass effect */
.card-frame {
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 20% 20%, rgba(255,255,255,0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255,255,255,0.02) 0%, transparent 50%),
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 1px,
            rgba(255,255,255,0.01) 1px,
            rgba(255,255,255,0.01) 2px
        ),
        linear-gradient(145deg, 
            rgba(20, 25, 40, 0.6) 0%, 
            rgba(30, 35, 55, 0.7) 25%,
            rgba(25, 30, 50, 0.65) 50%, 
            rgba(20, 25, 40, 0.7) 75%,
            rgba(15, 20, 35, 0.75) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(12px) saturate(180%);
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.1),
        inset 1px 0 0 rgba(255,255,255,0.05),
        inset 0 -1px 0 rgba(0,0,0,0.1),
        inset -1px 0 0 rgba(0,0,0,0.05),
        0 8px 32px rgba(0,0,0,0.4),
        0 2px 8px rgba(0,0,0,0.2);
    z-index: 1;
}

.card-frame::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255,255,255,0.1) 0%,
        transparent 20%,
        transparent 80%,
        rgba(255,255,255,0.05) 100%
    );
    border-radius: 15px;
    pointer-events: none;
    z-index: 2;
}

.card-frame::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.02) 0%, transparent 20%),
        radial-gradient(circle at 70% 70%, rgba(255,255,255,0.015) 0%, transparent 25%),
        radial-gradient(circle at 50% 80%, rgba(255,255,255,0.01) 0%, transparent 30%);
    border-radius: 15px;
    pointer-events: none;
    z-index: 2;
}

/* User Info Header */
#merlin-user-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px 0 18px;
    z-index: 15;
}

#merlin-user-name {
    font-weight: bold;
    font-size: 1.1em;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.8), 2px 2px 4px rgba(0,0,0,0.8);
}

#merlin-user-level {
    font-size: 1.1em;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.8), 2px 2px 4px rgba(0,0,0,0.8);
}

/* Level XP Bar */
.level-xp-bar {
    position: absolute;
    top: 30px;
    left: 15px;
    right: 15px;
    height: 35px;
    background: 
        radial-gradient(ellipse at 30% 30%, rgba(255,255,255,0.15) 0%, transparent 40%),
        radial-gradient(ellipse, rgba(147, 51, 234, 0.3) 0%, rgba(107, 33, 168, 0.4) 100%),
        rgba(25, 15, 35, 0.8);
    border: 1px solid rgba(147, 51, 234, 0.8);
    border-radius: 22px;
    display: flex;
    align-items: center;
    backdrop-filter: blur(8px) saturate(150%);
    box-shadow: 
        0 0 20px rgba(147, 51, 234, 0.6),
        0 0 40px rgba(147, 51, 234, 0.3),
        inset 0 1px 0 rgba(255,255,255,0.3),
        inset 1px 0 0 rgba(255,255,255,0.2),
        0 4px 15px rgba(0,0,0,0.4);
    z-index: 10;
    overflow: hidden;
}

.level-xp-bar::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    right: 2px;
    bottom: 2px;
    background: linear-gradient(
        135deg,
        rgba(255,255,255,0.4) 0%,
        transparent 30%,
        transparent 70%,
        rgba(255,255,255,0.1) 100%
    );
    border-radius: 20px;
    pointer-events: none;
}

.level-xp-bar::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    background: transparent;
    border: 1px solid rgba(147, 51, 234, 0.4);
    border-radius: 23px;
    animation: level-neon-pulse 3s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes level-neon-pulse {
    0% { 
        box-shadow: 0 0 5px rgba(147, 51, 234, 0.4);
        opacity: 0.6;
    }
    100% { 
        box-shadow: 0 0 15px rgba(147, 51, 234, 0.8);
        opacity: 1;
    }
}

.level-section {
    display: flex;
    align-items: center;
    padding-left: 8px;
    flex-shrink: 0;
}

.level-number {
    color: rgba(255, 255, 255, 0.95);
    font-weight: bold;
    font-size: 15px;
    text-shadow: 
        0 0 10px rgba(147, 51, 234, 0.8),
        2px 2px 4px rgba(0,0,0,0.8);
    margin-right: 6px;
    white-space: nowrap;
}

.xp-section {
    flex: 1;
    height: 18px;
    margin: 0 8px 0 3px;
    position: relative;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 9px;
    overflow: hidden;
    border: 1px solid rgba(147, 51, 234, 0.3);
    min-width: 60px;
}

.xp-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(
        90deg,
        rgba(147, 51, 234, 0.9) 0%,
        rgba(168, 85, 247, 0.8) 50%,
        rgba(147, 51, 234, 0.7) 100%
    );
    border-radius: 7px;
    box-shadow: 
        0 0 8px rgba(147, 51, 234, 0.6),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    transition: width 0.6s ease-out;
}

@keyframes xp-flash {
    0% { box-shadow: 0 0 6px rgba(147, 51, 234, 0.4); }
    50% { box-shadow: 0 0 20px rgba(147, 51, 234, 1); }
    100% { box-shadow: 0 0 8px rgba(147, 51, 234, 0.6); }
}

.xp-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 9px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    white-space: nowrap;
    z-index: 2;
    text-align: center;
}

.xp-text-full {
    display: inline;
}

.xp-text-short {
    display: none;
}

@media (max-width: 350px) {
    .xp-text-full { display: none; }
    .xp-text-short { display: inline; }
}

/* Card Art with 3D Canvas */
.card-art {
    margin: 70px 15px 5px 15px;
    height: 200px;
    position: relative;
    border-radius: 10px;
    overflow: visible;
    z-index: 5;
}

#merlin3dCanvas {
    width: 100%;
    height: 100%;
    border-radius: 10px;
}

/* Draggable Gemstone */
.merlin-gem-draggable {
    position: absolute;
    left: 70%;
    top: 62%;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 100;
    pointer-events: all;
}

.merlin-gem-draggable:active {
    cursor: grabbing;
}

.merlin-gemstone {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 0 15px var(--gem-color, #a855f7));
    animation: gem-pulse 2s ease-in-out infinite;
}

@keyframes gem-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.08); opacity: 0.95; }
}

/* Card Name / Title */
.card-name {
    margin: 15px 20px 10px 20px;
    text-align: center;
    z-index: 10;
    position: relative;
}

.card-name h2 {
    color: rgba(255, 255, 255, 0.95);
    font-size: 1.3em;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.8), 2px 2px 6px rgba(0,0,0,0.9);
    margin-bottom: 5px;
}

.merlin-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9em;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 10px #10b981;
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Progress Section */
.merlin-progress-section {
    margin: 10px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    position: relative;
}

.progress-stat {
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-icon {
    font-size: 20px;
    width: 25px;
    text-align: center;
}

.progress-bar-container {
    flex: 1;
    height: 20px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    border-radius: 9px;
    transition: width 0.6s ease-out;
    position: relative;
}

.heart-fill {
    background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.star-fill {
    background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.progress-bar-fill.glowing {
    animation: progress-glow 2s ease-in-out infinite;
}

@keyframes progress-glow {
    0%, 100% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 0 10px currentColor; }
    50% { box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 20px currentColor; }
}

.progress-bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 10px;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    z-index: 2;
}

/* Chat Messages */
.merlin-chat-messages {
    margin: 10px 20px;
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10;
    position: relative;
}

.message {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.9em;
    word-wrap: break-word;
}

.user-message {
    background: rgba(59, 130, 246, 0.3);
    color: white;
    align-self: flex-end;
    border: 1px solid rgba(59, 130, 246, 0.5);
}

.merlin-message {
    background: rgba(147, 51, 234, 0.3);
    color: white;
    align-self: flex-start;
    border: 1px solid rgba(147, 51, 234, 0.5);
}

/* Chat Input */
.merlin-input-container {
    margin: 10px 20px 60px 20px;
    display: flex;
    gap: 8px;
    z-index: 10;
    position: relative;
}

.merlin-input {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(147, 51, 234, 0.5);
    background: rgba(0, 0, 0, 0.4);
    color: white;
    font-family: inherit;
    font-size: 0.9em;
    resize: none;
    backdrop-filter: blur(8px);
}

.merlin-input:focus {
    outline: none;
    border-color: rgba(147, 51, 234, 0.8);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.5);
}

/* Voice Button */
.merlin-voice-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(147, 51, 234, 0.5);
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.merlin-voice-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.6);
}

.merlin-voice-btn.listening {
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    animation: voicePulse 1s ease-in-out infinite;
    border-color: #ff6b6b;
}

@keyframes voicePulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 10px rgba(255, 107, 107, 0.5); }
    50% { transform: scale(1.15); box-shadow: 0 0 25px rgba(255, 107, 107, 0.8); }
}

/* Voice Status Indicator */
.voice-status {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 107, 107, 0.9);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeInUp 0.3s ease;
    z-index: 20;
}

.voice-indicator {
    animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Speaking Animation for Avatar */
.merlin-avatar.speaking {
    animation: speakBounce 0.3s ease-in-out infinite;
}

@keyframes speakBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.merlin-send-btn {
    padding: 10px 20px;
    border-radius: 10px;
    border: 1px solid rgba(147, 51, 234, 0.8);
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.6), rgba(107, 33, 168, 0.8));
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.merlin-send-btn:hover {
    background: linear-gradient(135deg, rgba(147, 51, 234, 0.8), rgba(107, 33, 168, 1));
    box-shadow: 0 0 20px rgba(147, 51, 234, 0.8);
    transform: translateY(-2px);
}

/* Card Controls */
.card-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    display: flex;
    gap: 8px;
    z-index: 20;
}

.card-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.card-btn:hover {
    background: rgba(147, 51, 234, 0.6);
    border-color: rgba(147, 51, 234, 0.8);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.6);
}

/* Border Decorations */
.border-decoration {
    position: absolute;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(147, 51, 234, 0.6) 50%,
        transparent 100%
    );
    pointer-events: none;
    z-index: 15;
}

.border-decoration.top {
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 15px 15px 0 0;
}

.border-decoration.bottom {
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    border-radius: 0 0 15px 15px;
}

.border-decoration.left {
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(147, 51, 234, 0.6) 50%,
        transparent 100%
    );
    border-radius: 15px 0 0 15px;
}

.border-decoration.right {
    right: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: linear-gradient(
        180deg,
        transparent 0%,
        rgba(147, 51, 234, 0.6) 50%,
        transparent 100%
    );
    border-radius: 0 15px 15px 0;
}

/* Control Panel (Back Side) */
.merlin-advice-banner {
    margin: 20px 15px 10px 15px;
    padding: 12px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(147, 51, 234, 0.3));
    border: 1px solid rgba(168, 85, 247, 0.5);
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(8px);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.3);
    animation: advice-pulse 2s ease-in-out infinite;
}

@keyframes advice-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(168, 85, 247, 0.3); }
    50% { box-shadow: 0 0 30px rgba(168, 85, 247, 0.6); }
}

.advice-icon {
    font-size: 24px;
    filter: drop-shadow(0 0 8px rgba(168, 85, 247, 0.8));
}

.advice-text {
    flex: 1;
    color: white;
    font-size: 0.9em;
    font-weight: 500;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

.control-panel-grid {
    margin: 10px 15px 60px 15px;
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-section {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(147, 51, 234, 0.3);
    border-radius: 10px;
    padding: 12px;
}

.control-section h3 {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1em;
    margin-bottom: 10px;
    text-shadow: 0 0 10px rgba(147, 51, 234, 0.8);
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-btn {
    width: 100%;
    padding: 10px;
    margin-bottom: 6px;
    border-radius: 8px;
    border: 1px solid rgba(147, 51, 234, 0.4);
    background: rgba(20, 20, 35, 0.6);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    backdrop-filter: blur(8px);
}

.control-btn:hover {
    background: rgba(147, 51, 234, 0.4);
    border-color: rgba(147, 51, 234, 0.7);
    transform: translateX(5px);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.5);
}

.control-btn:active {
    transform: translateX(5px) scale(0.98);
}

.btn-icon {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
}

.btn-label {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

/* Highlighted button (Merlin's suggestion) */
.control-btn.highlighted {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.6), rgba(147, 51, 234, 0.7));
    border: 2px solid rgba(168, 85, 247, 1);
    box-shadow: 
        0 0 25px rgba(168, 85, 247, 0.8),
        inset 0 0 20px rgba(255, 255, 255, 0.1);
    transform: translateX(8px) scale(1.05);
    z-index: 10;
}

.control-btn.pulsing {
    animation: btn-pulse 1.5s ease-in-out infinite;
}

@keyframes btn-pulse {
    0%, 100% {
        box-shadow: 0 0 25px rgba(168, 85, 247, 0.8);
        transform: translateX(8px) scale(1.05);
    }
    50% {
        box-shadow: 0 0 40px rgba(168, 85, 247, 1);
        transform: translateX(8px) scale(1.08);
    }
}

.back-btn {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 10px;
}

/* Custom Scrollbar */
.merlin-chat-messages::-webkit-scrollbar,
.control-panel-grid::-webkit-scrollbar {
    width: 6px;
}

.merlin-chat-messages::-webkit-scrollbar-track,
.control-panel-grid::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 3px;
}

.merlin-chat-messages::-webkit-scrollbar-thumb,
.control-panel-grid::-webkit-scrollbar-thumb {
    background: rgba(147, 51, 234, 0.6);
    border-radius: 3px;
}

.merlin-chat-messages::-webkit-scrollbar-thumb:hover,
.control-panel-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(147, 51, 234, 0.8);
}

/* Responsive */
@media (max-width: 400px) {
    .merlin-card-container {
        width: 320px;
        height: 580px;
        bottom: 10px;
        right: 10px;
    }
    
    .card-art {
        height: 180px;
    }
    
    .merlin-chat-messages {
        max-height: 120px;
    }
}

/* ═══════════════════════════════════════════════════════════════════════════
   QUICK ACTIONS BAR
   ═══════════════════════════════════════════════════════════════════════════ */

.merlin-quick-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent);
}

.quick-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(168, 85, 247, 0.5);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(59, 130, 246, 0.3));
    color: white;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quick-action-btn:hover {
    transform: scale(1.15);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.6), rgba(59, 130, 246, 0.6));
    box-shadow: 0 0 15px rgba(168, 85, 247, 0.6);
    border-color: rgba(168, 85, 247, 0.8);
}

.quick-action-btn:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════════════════════════════════════════
   CONTEXT TOOLTIPS
   ═══════════════════════════════════════════════════════════════════════════ */

.merlin-tooltips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 15px;
    justify-content: center;
}

.merlin-tooltip-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid rgba(168, 85, 247, 0.4);
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(59, 130, 246, 0.2));
    color: white;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    animation: tooltip-fade-in 0.3s ease forwards;
    opacity: 0;
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.merlin-tooltip-btn:hover {
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.5), rgba(59, 130, 246, 0.5));
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
    transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════════════════════
   SPEAKING INDICATOR
   ═══════════════════════════════════════════════════════════════════════════ */

.merlin-speaking-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.3), rgba(59, 130, 246, 0.3));
    border-radius: 20px;
    margin: 5px 15px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
}

.speaking-wave {
    display: flex;
    gap: 3px;
    height: 16px;
    align-items: center;
}

.speaking-wave::before,
.speaking-wave::after,
.speaking-wave span {
    content: '';
    width: 3px;
    height: 8px;
    background: linear-gradient(to top, #a855f7, #3b82f6);
    border-radius: 2px;
    animation: speaking-wave 0.6s ease-in-out infinite;
}

.speaking-wave::before {
    animation-delay: 0s;
}

.speaking-wave span {
    animation-delay: 0.2s;
}

.speaking-wave::after {
    animation-delay: 0.4s;
}

@keyframes speaking-wave {
    0%, 100% {
        height: 4px;
    }
    50% {
        height: 16px;
    }
}

/* Speaking animation for avatar */
.card-art.speaking,
.merlin-avatar.speaking {
    animation: avatar-speaking 0.5s ease-in-out infinite;
}

@keyframes avatar-speaking {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(168, 85, 247, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(168, 85, 247, 1));
    }
}

/* Quick Actions Bar */
.merlin-quick-actions {
    display: flex;
    gap: 8px;
    padding: 8px 15px;
    justify-content: center;
    border-top: 1px solid rgba(147, 51, 234, 0.3);
    margin-top: 5px;
}

.quick-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(147, 51, 234, 0.5);
    background: rgba(147, 51, 234, 0.2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.3s ease;
}

.quick-action-btn:hover {
    background: rgba(147, 51, 234, 0.5);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(147, 51, 234, 0.6);
}

.quick-action-btn:active {
    transform: scale(0.95);
}

/* Context Tooltips */
.merlin-tooltips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 15px;
    justify-content: center;
}

.merlin-tooltip-btn {
    padding: 6px 12px;
    border-radius: 15px;
    border: 1px solid rgba(59, 130, 246, 0.5);
    background: rgba(59, 130, 246, 0.2);
    color: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    animation: tooltip-fade-in 0.3s ease-out forwards;
    opacity: 0;
}

.merlin-tooltip-btn:hover {
    background: rgba(59, 130, 246, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.4);
}

@keyframes tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Highlighted control button */
.control-btn.highlighted {
    animation: btn-highlight 1.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    border-color: gold !important;
}

@keyframes btn-highlight {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 40px rgba(255, 215, 0, 1);
    }
}
