/* ===================================================================
   Make Me a Site — Chat Widget
   Dark theme matching the main site aesthetic
   =================================================================== */

/* --- Reset scoped to widget --- */
.mmas-chat *, .mmas-chat *::before, .mmas-chat *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --- Floating Bubble --- */
.mmas-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 100%);
    border: none;
    cursor: pointer;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(74, 144, 217, 0.4), 0 2px 8px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.mmas-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 32px rgba(74, 144, 217, 0.5), 0 4px 12px rgba(0,0,0,0.4);
}
.mmas-chat-bubble:active {
    transform: scale(0.95);
}
.mmas-chat-bubble svg {
    width: 28px;
    height: 28px;
    fill: white;
}
/* Notification dot */
.mmas-chat-bubble-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #ff4757;
    border-radius: 50%;
    border: 2px solid #050508;
    animation: mmas-pulse 2s infinite;
}
@keyframes mmas-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}

/* --- Chat Panel --- */
.mmas-chat-panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* dynamic viewport height — shrinks with keyboard */
    background: #0a0a10;
    border: none;
    border-radius: 0;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: none;
    opacity: 0;
    transform: scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.mmas-chat-panel.open {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

/* --- Header --- */
.mmas-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(74, 144, 217, 0.12) 0%, transparent 100%);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}
.mmas-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.mmas-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a90d9, #357abd);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    font-weight: 700;
    flex-shrink: 0;
}
.mmas-chat-header-info h4 {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}
.mmas-chat-header-info span {
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 12px;
    color: #6b6b80;
    display: flex;
    align-items: center;
    gap: 5px;
}
.mmas-chat-status-dot {
    width: 7px;
    height: 7px;
    background: #2ecc71;
    border-radius: 50%;
    display: inline-block;
}
.mmas-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.mmas-chat-close,
.mmas-chat-new-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #6b6b80;
    padding: 4px;
    border-radius: 8px;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mmas-chat-close:hover,
.mmas-chat-new-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}
.mmas-chat-close svg,
.mmas-chat-new-btn svg {
    width: 20px;
    height: 20px;
}

/* --- Messages Area --- */
.mmas-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.mmas-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.mmas-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.mmas-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

/* --- Message Bubbles --- */
.mmas-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: mmas-fadeIn 0.2s ease;
}
@keyframes mmas-fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.mmas-msg-user {
    background: #4a90d9;
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.mmas-msg-assistant {
    background: #16161e;
    color: #d0d0dc;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.04);
}
.mmas-msg-assistant a {
    color: #4a90d9;
    text-decoration: underline;
}
.mmas-msg-system {
    align-self: center;
    background: none;
    color: #6b6b80;
    font-size: 12px;
    padding: 4px 8px;
}

/* --- File upload badge inside messages --- */
.mmas-msg-file {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.06);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 12px;
    color: #8888a0;
    margin-top: 4px;
}
.mmas-msg-file svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* --- Typing Indicator --- */
.mmas-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    align-self: flex-start;
}
.mmas-typing-dot {
    width: 7px;
    height: 7px;
    background: #4a90d9;
    border-radius: 50%;
    animation: mmas-typingBounce 1.2s infinite;
}
.mmas-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.mmas-typing-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes mmas-typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Input Area --- */
.mmas-chat-input-area {
    padding: 12px 16px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: #0c0c14;
    flex-shrink: 0;
}
.mmas-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #16161e;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.2s;
}
.mmas-chat-input-row:focus-within {
    border-color: rgba(74, 144, 217, 0.5);
}
.mmas-chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: #e0e0e8;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 20px;
    line-height: 1.5;
    padding: 6px 0;
}
.mmas-chat-input::placeholder {
    color: #4a4a5c;
}

/* Buttons */
.mmas-chat-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.mmas-chat-btn svg {
    width: 20px;
    height: 20px;
}
.mmas-chat-upload-btn {
    color: #6b6b80;
}
.mmas-chat-upload-btn:hover {
    color: #8888a0;
    background: rgba(255,255,255,0.06);
}
.mmas-chat-send-btn {
    background: #4a90d9;
    color: white;
    border-radius: 8px;
}
.mmas-chat-send-btn:hover {
    background: #5a9ee6;
}
.mmas-chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* --- Voice button --- */
.mmas-chat-voice-btn {
    color: #a0a0b8;
}
.mmas-chat-voice-btn:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.06);
}
.mmas-chat-voice-btn.mmas-voice-active {
    color: #ff4757;
    background: rgba(255, 71, 87, 0.12);
    animation: mmas-voicePulse 1.5s ease-in-out infinite;
}
.mmas-chat-voice-btn.mmas-voice-speaking {
    color: #2ecc71;
    background: rgba(46, 204, 113, 0.12);
    animation: mmas-voicePulse 0.8s ease-in-out infinite;
}
@keyframes mmas-voicePulse {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    50% { box-shadow: 0 0 0 4px rgba(255, 71, 87, 0.2); }
}
.mmas-voice-active.mmas-voice-speaking {
    animation-name: mmas-voiceSpeaking;
}
@keyframes mmas-voiceSpeaking {
    0%, 100% { box-shadow: 0 0 0 0 transparent; }
    50% { box-shadow: 0 0 0 4px rgba(46, 204, 113, 0.2); }
}

/* Hidden file input */
.mmas-chat-file-input {
    display: none;
}

/* --- Powered-by footer --- */
.mmas-chat-powered {
    text-align: center;
    padding: 6px 0 2px;
    font-family: 'Inter', -apple-system, sans-serif;
    font-size: 11px;
    color: #3a3a4c;
}
.mmas-chat-powered a {
    color: #4a4a5c;
    text-decoration: none;
}
.mmas-chat-powered a:hover {
    color: #6b6b80;
}

/* ===================================================================
   Mobile Responsive
   =================================================================== */
@media (max-width: 480px) {
    .mmas-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
    .mmas-chat-input-area {
        padding: 8px 8px 10px;
    }
    .mmas-chat-input-row {
        padding: 4px 4px 4px 8px;
        overflow: hidden;
    }
    .mmas-chat-input {
        font-size: 16px; /* prevent iOS zoom on focus */
        min-width: 0; /* allow flex shrink */
    }
    .mmas-chat-btn {
        padding: 6px;
        flex-shrink: 0;
    }
    .mmas-chat-btn svg {
        width: 18px;
        height: 18px;
    }
    .mmas-chat-bubble {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }
    .mmas-chat-bubble svg {
        width: 24px;
        height: 24px;
    }
}

/* Subagent connected badge */
.mmas-subagent-badge {
  display: none;
  background: #10b981;
  color: white;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  animation: mmas-badge-pulse 2s ease-in-out infinite;
  font-weight: 600;
  letter-spacing: 0.3px;
}
@keyframes mmas-badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Fix mobile keyboard covering input */
.mmas-chat-input-area {
    padding-bottom: env(safe-area-inset-bottom, 8px);
}
