/* ============================================================
   Maya AI Web — Stylesheet
   Dark theme with neon blue accents
   ============================================================ */

/* ==================== VARIABLES ==================== */
:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(20, 20, 50, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-glow: rgba(0, 168, 255, 0.3);

    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555570;

    --accent: #00a8ff;
    --accent-bright: #00cfff;
    --accent-dim: #0060aa;
    --accent-glow: rgba(0, 168, 255, 0.4);
    --accent-glow-strong: rgba(0, 168, 255, 0.7);

    --success: #00e676;
    --warning: #ffab00;
    --error: #ff5252;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 50%;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);
}

/* ==================== RESET ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--accent-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.hidden { display: none !important; }

/* ==================== BACKGROUND EFFECTS ==================== */
body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 30% 20%, rgba(0, 80, 180, 0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 70% 80%, rgba(0, 120, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ==================== MODAL ==================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
}

.modal-content {
    position: relative;
    z-index: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(0, 100, 255, 0.1);
    animation: modalIn 0.5s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-gif-wrapper {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    border-radius: var(--radius-full);
    overflow: hidden;
    border: 2px solid var(--accent);
    box-shadow: var(--shadow-glow);
}

.modal-gif {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-bright), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 4px;
}

.modal-version {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 24px;
}

/* ==================== PERMISSIONS ==================== */
.permissions-section {
    margin-bottom: 28px;
}

.permissions-title {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 14px;
}

.permission-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.permission-card.granted {
    border-color: var(--success);
    background: rgba(0, 230, 118, 0.05);
}

.permission-card.denied {
    border-color: var(--error);
    background: rgba(255, 82, 82, 0.05);
}

.permission-icon-wrap {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 168, 255, 0.1);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.permission-icon {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.permission-card.granted .permission-icon { color: var(--success); }
.permission-card.denied .permission-icon { color: var(--error); }

.permission-info {
    flex: 1;
    text-align: left;
}

.permission-info h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.permission-info p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.perm-btn {
    padding: 8px 18px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.perm-btn:hover { background: var(--accent-bright); transform: translateY(-1px); }
.perm-btn:disabled { cursor: default; transform: none; }

.permission-card.granted .perm-btn {
    background: var(--success);
}

.permission-card.denied .perm-btn {
    background: var(--error);
}

/* Start Button */
.start-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 40px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dim));
    color: #fff;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px var(--accent-glow-strong);
}

.start-btn-icon { font-size: 1.3rem; }

.start-hint {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 12px;
}

/* ==================== APP LAYOUT ==================== */
.app {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ==================== HEADER ==================== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    flex-shrink: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.logo-accent {
    background: linear-gradient(135deg, var(--accent-bright), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    transition: all 0.3s ease;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    transition: background 0.3s ease;
}

.status-badge.online .status-dot { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-badge.listening .status-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse-dot 1.5s infinite; }
.status-badge.processing .status-dot { background: var(--warning); box-shadow: 0 0 8px var(--warning); animation: pulse-dot 0.8s infinite; }
.status-badge.error .status-dot { background: var(--error); }
.status-badge.offline .status-dot { background: var(--text-muted); }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* ==================== AVATAR ==================== */
.avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0 16px;
    flex-shrink: 0;
}

.avatar-wrapper {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-ring {
    position: absolute;
    inset: 0;
    border-radius: var(--radius-full);
    border: 2px solid transparent;
    transition: all 0.5s ease;
}

.avatar-ring.ring-1 {
    border-color: rgba(0, 168, 255, 0.15);
}

.avatar-ring.ring-2 {
    inset: -10px;
    border-color: rgba(0, 168, 255, 0.08);
}

.avatar-ring.ring-3 {
    inset: -20px;
    border-color: rgba(0, 168, 255, 0.04);
}

/* Listening state */
.avatar-wrapper.listening .ring-1 {
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
    animation: ring-pulse 2s ease-in-out infinite;
}

.avatar-wrapper.listening .ring-2 {
    border-color: rgba(0, 168, 255, 0.3);
    animation: ring-pulse 2s ease-in-out 0.3s infinite;
}

.avatar-wrapper.listening .ring-3 {
    border-color: rgba(0, 168, 255, 0.15);
    animation: ring-pulse 2s ease-in-out 0.6s infinite;
}

/* Awake state */
.avatar-wrapper.awake .ring-1 {
    border-color: var(--accent-bright);
    box-shadow: 0 0 30px var(--accent-glow-strong);
    animation: ring-glow 1s ease-in-out infinite;
}

.avatar-wrapper.awake .ring-2 {
    border-color: var(--accent);
    animation: ring-glow 1s ease-in-out 0.2s infinite;
}

/* Processing state */
.avatar-wrapper.processing .ring-1 {
    border-color: var(--warning);
    animation: ring-spin 1.5s linear infinite;
    border-top-color: transparent;
}

@keyframes ring-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.7; }
}

@keyframes ring-glow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 40px var(--accent-glow-strong); }
}

@keyframes ring-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.avatar-core {
    width: 100px;
    height: 100px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--bg-secondary);
    border: 2px solid rgba(0, 168, 255, 0.2);
    box-shadow: var(--shadow-md);
    z-index: 1;
}

.avatar-gif {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.status-text {
    margin-top: 14px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
    text-align: center;
    transition: color 0.3s ease;
    min-height: 1.5em;
}

/* ==================== CHAT AREA ==================== */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    text-align: center;
    gap: 4px;
}

.chat-empty-icon { font-size: 2.5rem; margin-bottom: 8px; }
.chat-empty strong { color: var(--accent); }
.chat-empty-sub { font-size: 0.8rem; }

/* Messages */
.message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: msgIn 0.3s ease;
}

@keyframes msgIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.maya { align-self: flex-start; }
.message.system { align-self: center; max-width: 95%; }

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
}

.msg-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.msg-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message.user .msg-name { text-align: right; }

.msg-bubble {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user .msg-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.maya .msg-bubble {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message.system .msg-bubble {
    background: rgba(255, 171, 0, 0.08);
    border: 1px solid rgba(255, 171, 0, 0.2);
    color: var(--warning);
    text-align: center;
    font-size: 0.85rem;
}

.msg-time {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.message.user .msg-time { text-align: right; }

/* ==================== QUICK COMMANDS ==================== */
.quick-commands {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    overflow-x: auto;
    flex-shrink: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.quick-commands::-webkit-scrollbar { display: none; }

.qcmd {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.qcmd:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(0, 168, 255, 0.05);
    transform: translateY(-2px);
}

.qcmd-icon { font-size: 1.2rem; }

/* ==================== INPUT AREA ==================== */
.input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0 20px;
    flex-shrink: 0;
}

/* Mic Button */
.mic-btn {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-full);
    border: 2px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
    overflow: visible;
}

.mic-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.mic-btn.active {
    border-color: var(--accent);
    background: rgba(0, 168, 255, 0.1);
    color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

.mic-btn.processing {
    border-color: var(--warning);
    color: var(--warning);
}

.mic-svg {
    width: 24px;
    height: 24px;
    position: relative;
    z-index: 1;
}

.mic-ripple {
    position: absolute;
    inset: -4px;
    border-radius: var(--radius-full);
    border: 2px solid var(--accent);
    opacity: 0;
    pointer-events: none;
}

.mic-btn.active .mic-ripple {
    animation: mic-ripple 1.5s ease-out infinite;
}

@keyframes mic-ripple {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* Text Input */
.text-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px 4px 4px 18px;
    transition: border-color 0.3s ease;
}

.text-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(0, 168, 255, 0.1);
}

.text-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    padding: 10px 0;
}

.text-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: none;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    background: var(--accent-bright);
    transform: scale(1.05);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    font-weight: 500;
    color: #fff;
    box-shadow: var(--shadow-md);
    transform: translateX(120%);
    transition: transform 0.3s ease;
    max-width: 360px;
}

.toast.show { transform: translateX(0); }
.toast.info { background: var(--accent); }
.toast.success { background: #1b8a4a; }
.toast.error { background: #c62828; }
.toast.warning { background: #e65100; }

/* ==================== OLLAMA WARNING ==================== */
.ollama-warning {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(230, 81, 0, 0.15);
    border: 1px solid rgba(255, 171, 0, 0.3);
    color: var(--warning);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 100;
    backdrop-filter: blur(10px);
    max-width: 90%;
    white-space: nowrap;
}

.ollama-warning-icon { font-size: 1.1rem; }

.ollama-dismiss {
    background: none;
    border: none;
    color: var(--warning);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 4px;
    margin-left: 8px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 600px) {
    .modal-content {
        padding: 28px 20px;
        border-radius: var(--radius-lg);
    }

    .modal-gif-wrapper {
        width: 90px;
        height: 90px;
    }

    .modal-title { font-size: 1.6rem; }

    .avatar-wrapper {
        width: 110px;
        height: 110px;
    }

    .avatar-core {
        width: 80px;
        height: 80px;
    }

    .avatar-ring.ring-2 { inset: -8px; }
    .avatar-ring.ring-3 { inset: -16px; }

    .message { max-width: 92%; }

    .qcmd {
        padding: 8px 12px;
        font-size: 0.7rem;
    }

    .input-area { gap: 8px; }

    .mic-btn {
        width: 46px;
        height: 46px;
    }

    .ollama-warning {
        bottom: 80px;
        font-size: 0.75rem;
        white-space: normal;
    }
}

@media (max-width: 380px) {
    .app { padding: 0 10px; }
    .avatar-section { padding: 6px 0 10px; }
}
