/* Floating chatbox styles */
.cai-chatbox {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.cai-toggle-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00ff00 0%, #00cc00 100%);
    box-shadow: 0 4px 12px rgba(0, 255, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.cai-toggle-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 255, 0, 0.4);
}

.cai-toggle-button.hidden {
    display: none;
}

.cai-toggle-button .cai-icon {
    width: 32px;
    height: 32px;
    stroke: #000;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cai-chatbox-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 600px;
    background: #1a1a1a;
    border: 2px solid #00ff00;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.cai-chatbox-window.open {
    display: flex;
}

.cai-header {
    background: #000;
    border-bottom: 2px solid #00ff00;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cai-header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #00ff00;
    font-weight: 600;
    font-size: 16px;
}

.cai-header-icon {
    width: 24px;
    height: 24px;
    stroke: #00ff00;
    fill: none;
    stroke-width: 2;
}

.cai-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Authentication Status Badge */
.cai-auth-status {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid;
    transition: all 0.3s ease;
}

.cai-auth-status.authenticated {
    background: rgba(0, 255, 0, 0.2);
    color: #00ff00;
    border-color: #00ff00;
}

.cai-auth-status.guest {
    background: rgba(255, 165, 0, 0.2);
    color: #ffa500;
    border-color: #ffa500;
}

.cai-canvas-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 4px;
}

.cai-canvas-toggle:hover {
    background: rgba(0, 255, 0, 0.1);
}

.cai-canvas-toggle svg {
    width: 20px;
    height: 20px;
    stroke: #00ff00;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cai-close-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.cai-close-button:hover {
    transform: rotate(90deg);
}

.cai-close-button svg {
    width: 20px;
    height: 20px;
    stroke: #00ff00;
    stroke-width: 2;
}

.cai-waveform-container {
    background: #000;
    border-bottom: 1px solid #00ff00;
    padding: 10px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.4s ease, opacity 0.4s ease, padding 0.4s ease;
}

.cai-waveform-container.active {
    max-height: 80px;
    opacity: 1;
    padding: 10px;
}

#cai-waveform-canvas {
    width: 100%;
    height: 60px;
    background: #000;
}

/* Canvas Wrapper */
.cai-canvas-wrapper {
    background: #1e1e1e;
    border-top: 1px solid #00ff00;
    border-bottom: 1px solid #00ff00;
    position: relative;
    flex-shrink: 0;
}

.cai-canvas-header {
    background: rgba(0, 255, 0, 0.1);
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 255, 0, 0.2);
}

.cai-canvas-title {
    color: #00ff00;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cai-visualizer {
    width: 100%;
    height: 100px;
    background-color: #000;
    display: block;
}

.cai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #1a1a1a;
}

.cai-messages::-webkit-scrollbar {
    width: 8px;
}

.cai-messages::-webkit-scrollbar-track {
    background: #000;
}

.cai-messages::-webkit-scrollbar-thumb {
    background: #00ff00;
    border-radius: 4px;
}

.cai-welcome-message {
    background: #002200;
    color: #00ff00;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #00ff00;
}

.cai-message {
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
    animation: cai-fadeIn 0.3s ease;
}

@keyframes cai-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cai-message.user {
    background: #003300;
    color: #00ff00;
    margin-left: auto;
    border: 1px solid #00ff00;
}

.cai-message.assistant {
    background: #002200;
    color: #00ff00;
    border: 1px solid #00ff00;
}

.cai-message img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 4px;
    border: 1px solid #00ff00;
    margin-top: 8px;
    display: block;
}

.cai-typing-indicator {
    padding: 10px 15px;
    background: #002200;
    margin: 0 15px 15px 15px;
    border-radius: 8px;
    display: none;
    border: 1px solid #00ff00;
}

.cai-typing-indicator.show {
    display: block;
}

.cai-dots {
    display: flex;
    gap: 4px;
}

.cai-dot {
    width: 8px;
    height: 8px;
    background: #00ff00;
    border-radius: 50%;
    animation: cai-pulse 1.5s infinite;
}

.cai-dot:nth-child(2) {
    animation-delay: 0.5s;
}

.cai-dot:nth-child(3) {
    animation-delay: 1s;
}

@keyframes cai-pulse {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

.cai-input-area {
    border-top: 2px solid #00ff00;
    padding: 15px;
    background: #000;
    display: flex;
    gap: 10px;
    align-items: center;
}

#cai-text-input {
    flex: 1;
    background: #1a1a1a;
    border: 2px solid #00ff00;
    color: #00ff00;
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    outline: none;
}

#cai-text-input:focus {
    border-color: #00ff00;
    box-shadow: 0 0 0 2px rgba(0, 255, 0, 0.2);
}

#cai-text-input::placeholder {
    color: #00ff00;
    opacity: 0.5;
}

.cai-input-area button {
    background: #000;
    border: 2px solid #00ff00;
    color: #00ff00;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.cai-input-area button:hover {
    background: #003300;
    border-width: 3px;
}

.cai-input-area button svg {
    width: 20px;
    height: 20px;
    stroke: #00ff00;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cai-input-area button svg.fill-icon {
    fill: #00ff00;
    stroke: none;
}

.cai-calibration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999999;
}

.cai-calibration-overlay.show {
    display: flex;
}

.cai-calibration-content {
    background: #1a1a1a;
    border: 2px solid #00ff00;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    color: #00ff00;
}

.cai-calibration-content h3 {
    margin-top: 0;
    color: #00ff00;
}

.cai-calibration-meter {
    width: 100%;
    height: 20px;
    background: #000;
    border: 1px solid #00ff00;
    margin: 20px 0;
    overflow: hidden;
    border-radius: 4px;
}

.cai-calibration-level {
    height: 100%;
    background: #00ff00;
    width: 0%;
    transition: width 0.1s;
}

.cai-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 15px 25px;
    border-radius: 6px;
    font-size: 14px;
    z-index: 99999999;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 400px;
}

.cai-toast.show {
    display: block;
}

.cai-toast.error {
    background: #f44336;
    color: white;
}

.cai-toast.warning {
    background: #ffd700;
    color: black;
}

.cai-toast.info {
    background: #2196F3;
    color: white;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .cai-chatbox {
        z-index: 9994;
    }
    
    .cai-chatbox-window {
        z-index: 9995;
    }
}

/* Mobile responsive - UPDATED TO MATCH OLD CHAT */
@media (max-width: 767px) {
    .cai-chatbox {
        right: 10px;
        bottom: 70px;
    }
    
    .cai-chatbox-window {
        width: 100vw;
        height: calc(100vh - 164px);
        right: 0;
        top: auto;
        bottom: 60px;
        left: 0;
        border-radius: 0;
    }
    
    .cai-message {
        max-width: 90%;
    }
}

/* Desktop */
@media (min-width: 768px) and (max-width: 1024px) {
    .cai-chatbox-window {
        width: 380px;
        z-index: 10000;
    }
    
    .cai-chatbox {
        z-index: 10000;
    }
}