/* app/mosimo-box/mosimo-box.css */

/* --- Custom Variables & Theme Integrations --- */
.mosimo-theme {
    --orb-size: 110px;
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.12);
    --cell-blur: blur(5px);
}

:root.dark .mosimo-theme {
    --glass-bg: rgba(26, 32, 44, 0.65);
    --glass-border: rgba(74, 85, 104, 0.4);
}

.Lora-font {
    font-family: 'Lora', 'Noto Sans JP', serif;
}

/* --- Layout Grid --- */
.mosimo-container {
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

.mosimo-workspace-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 1.5rem;
    min-height: calc(100vh - 140px);
}

@media (max-width: 1024px) {
    .mosimo-workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Glassmorphic Panels --- */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--kamos-radius-lg, 16px);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Input Area Custom Stylings --- */
.presets-container .preset-btn {
    background: rgba(104, 211, 145, 0.08);
    border: 1px solid rgba(104, 211, 145, 0.25);
    color: var(--kamos-primary-color, #48BB78);
    cursor: pointer;
    transition: all 0.2s ease;
}

.presets-container .preset-btn:hover {
    background: rgba(104, 211, 145, 0.18);
    border-color: var(--kamos-primary-color, #48BB78);
    transform: translateY(-1px);
}

.presets-container .preset-btn:active {
    transform: translateY(0);
}

.mosimo-textarea {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--kamos-border-color-default, #4A5568);
    border-radius: 8px;
    color: var(--kamos-text-color-default, #E2E8F0);
    outline: none;
    resize: none;
    transition: border-color 0.2s ease;
}

.mosimo-textarea:focus {
    border-color: var(--kamos-primary-color, #48BB78);
    box-shadow: 0 0 0 2px rgba(104, 211, 145, 0.2);
}

.generate-btn {
    background: linear-gradient(135deg, var(--kamos-primary-color, #48BB78) 0%, #319795 100%);
    color: #ffffff;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 14px rgba(72, 187, 120, 0.3);
    transition: all 0.2s ease;
}

.generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(72, 187, 120, 0.4);
}

.generate-btn:active {
    transform: translateY(0);
}

/* --- Kamos Audio-Reactive Orb --- */
.orb-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 150px;
    height: 150px;
    position: relative;
}

.mosimo-orb {
    width: var(--orb-size);
    height: var(--orb-size);
    border-radius: 50%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.5s ease;
}

.orb-core {
    width: calc(var(--orb-size) - 30px);
    height: calc(var(--orb-size) - 30px);
    border-radius: 50%;
    background: radial-gradient(circle, #38A169 0%, #1A202C 100%);
    z-index: 5;
    box-shadow: inset 0 4px 12px rgba(255, 255, 255, 0.15);
}

.orb-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(72, 187, 120, 0.45) 0%, rgba(72, 187, 120, 0) 70%);
    filter: blur(10px);
    z-index: 2;
    transition: all 0.5s ease;
}

.orb-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(104, 211, 145, 0.35);
    z-index: 3;
}

.ring-1 {
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    animation: rotateRing 8s linear infinite;
}

.ring-2 {
    top: -16px; left: -16px; right: -16px; bottom: -16px;
    border-style: dashed;
    animation: rotateRingCounter 12s linear infinite;
}

/* --- Orb Animations according to states --- */

/* State: Idle */
.orb-idle {
    animation: floatOrb 4s ease-in-out infinite;
}
.orb-idle .orb-glow {
    opacity: 0.5;
}

/* State: Analyzing */
.orb-analyzing {
    animation: spinPulse 1.2s ease-in-out infinite alternate;
}
.orb-analyzing .orb-core {
    background: radial-gradient(circle, var(--kamos-accent-blue, #3182ce) 0%, #1A202C 100%);
}
.orb-analyzing .orb-glow {
    background: radial-gradient(circle, rgba(66, 153, 225, 0.75) 0%, rgba(66, 153, 225, 0) 70%);
    animation: orbPulse 0.5s ease-in-out infinite alternate;
}
.orb-analyzing .orb-ring {
    border-color: rgba(66, 153, 225, 0.6);
    border-width: 2px;
}

/* State: Speaking */
.orb-speaking {
    animation: voiceVibe 0.2s ease-in-out infinite alternate;
}
.orb-speaking .orb-core {
    background: radial-gradient(circle, var(--kamos-vitamin-pink, #d53f8c) 0%, #1a202c 100%);
}
.orb-speaking .orb-glow {
    background: radial-gradient(circle, rgba(237, 100, 166, 0.8) 0%, rgba(237, 100, 166, 0) 70%);
    transform: scale(1.3);
}
.orb-speaking .orb-ring {
    border-color: rgba(237, 100, 166, 0.7);
    border-width: 1.5px;
}

@keyframes rotateRing {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes rotateRingCounter {
    from { transform: rotate(360deg); }
    to { transform: rotate(0deg); }
}

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

@keyframes orbPulse {
    from { transform: scale(0.95); opacity: 0.6; }
    to { transform: scale(1.15); opacity: 1; }
}

@keyframes spinPulse {
    0% { transform: scale(1) rotate(0deg); }
    100% { transform: scale(1.1) rotate(180deg); }
}

@keyframes voiceVibe {
    0% { transform: scale(1) skewX(-2deg); }
    100% { transform: scale(1.08) skewX(2deg) translateY(-2px); }
}

/* --- Voice Controls --- */
.voice-select-dropdown {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--kamos-border-color-default, #4A5568);
    color: var(--kamos-text-color-default, #E2E8F0);
    outline: none;
    max-width: 130px;
}

.voice-control-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--kamos-border-color-default, #4A5568);
    color: var(--kamos-text-color-default, #E2E8F0);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.voice-control-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--kamos-primary-color, #48BB78);
    color: var(--kamos-primary-color, #48BB78);
}

.voice-control-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- Interactive Panels & Tabs --- */
.tab-btn {
    background: transparent;
    border: none;
    color: var(--kamos-text-color-light, #CBD5E0);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.tab-btn.active {
    color: var(--kamos-primary-color, #48BB78);
    border-bottom-color: var(--kamos-primary-color, #48BB78);
    opacity: 1;
}

/* --- Narrative Story Elements --- */
.story-script-area {
    padding: 0.5rem;
}

.story-paragraph {
    margin-bottom: 1.25rem;
    font-size: 14px;
    line-height: 1.8;
    color: var(--kamos-text-color-light, #CBD5E0);
    transition: all 0.3s ease;
    opacity: 0.6;
}

.story-paragraph.speaking-highlight {
    opacity: 1;
    color: #ffffff;
    font-weight: 500;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.15);
    border-left: 2px solid var(--kamos-vitamin-pink, #F687B3);
    padding-left: 8px;
    transform: translateX(2px);
}

/* --- Dialogue Chat Bubbles --- */
.chat-history-log {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    border: 1px solid var(--kamos-border-color-light, #2D3748);
    height: 420px; /* Fixed height for message log */
    overflow-y: scroll; /* Force vertical scrollbar */
}

.chat-bubble {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
    align-items: flex-start;
}

.chat-bubble.assistant {
    align-self: flex-start;
}

.chat-bubble.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-bubble .avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(104, 211, 145, 0.15);
    border: 1px solid var(--kamos-primary-color, #48BB78);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--kamos-primary-color, #48BB78);
}

.chat-bubble.user .avatar {
    background: rgba(99, 179, 237, 0.15);
    border-color: var(--kamos-accent-blue, #63B3ED);
    color: var(--kamos-accent-blue, #63B3ED);
}

.chat-bubble .message-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    color: var(--kamos-text-color-default, #E2E8F0);
    line-height: 1.5;
}

.chat-bubble.user .message-content {
    background: rgba(99, 179, 237, 0.1);
    border: 1px solid rgba(99, 179, 237, 0.2);
}

.chat-bubble.assistant .message-content {
    background: rgba(104, 211, 145, 0.05);
    border: 1px solid rgba(104, 211, 145, 0.15);
}

/* --- Chat Input Custom Stylings --- */
.chat-text-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--kamos-border-color-default, #4A5568);
    color: var(--kamos-text-color-default, #E2E8F0);
    outline: none;
}

.chat-text-input:focus {
    border-color: var(--kamos-primary-color, #48BB78);
}

.chat-text-input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-chat-btn {
    background: var(--kamos-primary-color, #48BB78);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.send-chat-btn:hover:not(:disabled) {
    background: var(--kamos-primary-darker, #38a169);
}

.send-chat-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- Detail Modal Box --- */
.kamos-modal-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(6px);
}

.kamos-modal-content {
    width: 90%;
    max-width: 500px;
    animation: modalIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.kamos-hidden {
    display: none !important;
}

.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Live State Visual Highlights --- */
.live-active {
    background: rgba(229, 62, 62, 0.2) !important;
    border-color: #E53E3E !important;
    color: #E53E3E !important;
    animation: livePulse 2s infinite alternate;
}

.live-error {
    background: rgba(155, 44, 44, 0.4) !important;
    border-color: #E53E3E !important;
    color: #feb2b2 !important;
}

@keyframes livePulse {
    0% {
        box-shadow: 0 0 4px rgba(229, 62, 62, 0.2);
    }
    100% {
        box-shadow: 0 0 12px rgba(229, 62, 62, 0.6);
    }
}

/* Red stop button highlight when live session is active */
.voice-control-btn#speakStopBtn:not(:disabled) {
    background: rgba(229, 62, 62, 0.25);
    border-color: #E53E3E;
    color: #E53E3E;
    animation: buttonPulse 2.5s infinite;
}

.voice-control-btn#speakStopBtn:hover:not(:disabled) {
    background: #E53E3E;
    color: #ffffff;
    box-shadow: 0 0 10px rgba(229, 62, 62, 0.6);
}

@keyframes buttonPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}
