/**
 * simili.ai Mobile Experience
 *
 * Full-screen chat UI for mobile devices.
 * Completely separate from desktop layout.
 */

/* ── Mobile Login Overrides ───────────────────────────────── */

@media (max-width: 768px) {
    .login-card {
        max-width: 100%;
        padding: 40px 24px;
        border-radius: 0;
        box-shadow: none;
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .login-overlay {
        align-items: stretch;
    }

    .login-brand-icon {
        width: 56px;
        height: 56px;
    }

    .login-title {
        font-size: 32px;
    }

    .login-subtitle {
        font-size: 15px;
    }

    .login-input {
        padding: 16px 20px;
        font-size: 17px;
        border-radius: 12px;
        /* Prevent iOS zoom on focus */
        font-size: 16px;
    }

    .login-btn {
        padding: 16px 24px;
        font-size: 17px;
        border-radius: 12px;
        min-height: 56px;
    }

    .login-hint {
        font-size: 14px;
    }

    .login-beta-info {
        font-size: 14px;
    }

    /* Hide the old "desktop only" warning on mobile — we now have a real mobile experience */
    .login-mobile-warning {
        display: none !important;
    }

    .login-sent-icon {
        font-size: 56px;
    }

    .login-sent-text {
        font-size: 17px;
    }

    .login-link-btn {
        font-size: 15px;
        padding: 12px;
    }
}


/* ── Mobile App Layout ────────────────────────────────────── */

.mobile-app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    background: #f8f9fa;
    overflow: hidden;
}

.mobile-app.hidden {
    display: none;
}


/* ── Mobile Header ────────────────────────────────────────── */

.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #18365A;
    color: white;
    flex-shrink: 0;
    /* Safe area for notch */
    padding-top: max(12px, env(safe-area-inset-top));
}

.mobile-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mobile-brand-icon {
    width: 28px;
    height: 28px;
}

.mobile-brand {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.mobile-new-case {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.mobile-new-case:hover,
.mobile-new-case:active {
    background: rgba(255, 255, 255, 0.25);
}

.mobile-new-case svg {
    width: 14px;
    height: 14px;
}


/* ── Chat Messages Area ───────────────────────────────────── */

.mobile-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    -webkit-overflow-scrolling: touch;
}


/* ── Chat Bubbles ─────────────────────────────────────────── */

.mobile-bubble {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: mobileFadeIn 0.2s ease-out;
}

.mobile-bubble p {
    margin: 0;
}

.mobile-bubble p + p {
    margin-top: 8px;
}

/* System bubbles — left */
.mobile-bubble-system {
    align-self: flex-start;
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* User bubbles — right */
.mobile-bubble-user {
    align-self: flex-end;
    background: #18365A;
    color: white;
    border-bottom-right-radius: 4px;
}

.mobile-hint {
    font-size: 13px;
    color: #64748b;
    margin-top: 8px !important;
}

.mobile-bubble-user .mobile-hint {
    color: rgba(255, 255, 255, 0.7);
}

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


/* ── Loading Animation ────────────────────────────────────── */

.mobile-loading-container {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 24px;
}

.mobile-loading-text {
    color: #64748b;
    font-size: 14px;
}

.mobile-loading-timer {
    color: #94a3b8;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.mobile-loading-bounce {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.mobile-loading-bounce span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: mobileBounce 1.4s ease-in-out infinite;
}

.mobile-loading-bounce span:nth-child(1) { animation-delay: 0s; }
.mobile-loading-bounce span:nth-child(2) { animation-delay: 0.16s; }
.mobile-loading-bounce span:nth-child(3) { animation-delay: 0.32s; }

@keyframes mobileBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-8px); opacity: 1; }
}


/* ── Results Cards ────────────────────────────────────────── */

.mobile-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    animation: mobileFadeIn 0.3s ease-out;
}

.mobile-remedy-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}

.mobile-remedy-card.expanded {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.mobile-remedy-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-remedy-rank {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
    min-width: 24px;
}

.mobile-remedy-name {
    font-size: 16px;
    font-weight: 700;
    color: #18365A;
}

.mobile-remedy-fullname {
    font-size: 13px;
    color: #64748b;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-remedy-stars {
    font-size: 14px;
    color: #f59e0b;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.mobile-remedy-chevron {
    width: 16px;
    height: 16px;
    color: #94a3b8;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.mobile-remedy-card.expanded .mobile-remedy-chevron {
    transform: rotate(180deg);
}

.mobile-remedy-detail {
    padding: 0 16px 14px;
    font-size: 14px;
    color: #334155;
    line-height: 1.6;
    border-top: 1px solid #f1f5f9;
}

.mobile-remedy-detail.hidden {
    display: none;
}

.mobile-remedy-detail p {
    margin: 8px 0 0;
}

.mobile-remedy-essence {
    font-style: italic;
    color: #475569;
}

.mobile-remedy-keynotes {
    margin: 4px 0 0;
    padding-left: 20px;
}

.mobile-remedy-keynotes li {
    margin-bottom: 4px;
    font-size: 13px;
    color: #475569;
}

.mobile-remedy-loading {
    color: #94a3b8;
    font-size: 13px;
}

.mobile-remedy-section {
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

.mobile-remedy-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.mobile-remedy-section p {
    margin: 4px 0;
}


/* ── Report Button ────────────────────────────────────────── */

.mobile-report-container {
    display: flex;
    justify-content: center;
    padding: 8px 0;
    animation: mobileFadeIn 0.3s ease-out;
}

.mobile-report-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 320px;
    padding: 14px 24px;
    background: #18365A;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-report-btn:hover {
    background: #2B60A1;
}

.mobile-report-btn:active {
    transform: scale(0.98);
}

.mobile-report-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.mobile-report-btn.sent {
    background: #059669;
}

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


/* ── Desktop Upsell ───────────────────────────────────────── */

.mobile-desktop-upsell {
    font-size: 13px !important;
    color: #64748b !important;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.mobile-desktop-upsell svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}


/* ── Input Area ───────────────────────────────────────────── */

.mobile-input-area {
    flex-shrink: 0;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: white;
    border-top: 1px solid #e2e8f0;
}

.mobile-input-area.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.mobile-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f5f9;
    border-radius: 16px;
    padding: 8px 8px 8px 16px;
    border: 1px solid #e2e8f0;
    transition: border-color 0.15s;
}

.mobile-input-wrapper:focus-within {
    border-color: #2B60A1;
}

.mobile-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.4;
    color: #1e293b;
    resize: none;
    outline: none;
    min-height: 24px;
    max-height: 150px;
    padding: 4px 0;
    /* Prevent iOS zoom */
    font-size: 16px;
}

.mobile-chat-input::placeholder {
    color: #94a3b8;
}

.mobile-chat-input:disabled {
    color: #94a3b8;
}

.mobile-input-buttons {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.mobile-mic-btn,
.mobile-send-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-mic-btn {
    background: transparent;
    color: #64748b;
}

.mobile-mic-btn:hover,
.mobile-mic-btn:active {
    background: #e2e8f0;
}

.mobile-mic-btn.recording {
    background: #ef4444;
    color: white;
    animation: micPulse 1.5s ease-in-out infinite;
}

.mobile-mic-btn.processing {
    background: #f59e0b;
    color: white;
}

.mobile-mic-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.mobile-send-btn {
    background: #18365A;
    color: white;
}

.mobile-send-btn:hover {
    background: #2B60A1;
}

.mobile-send-btn:active {
    transform: scale(0.95);
}

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

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

@keyframes micPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}


/* ── Spin animation for loader icon ──────────────────────── */

.mobile-report-btn .spin,
.mobile-bubble .spin {
    animation: spinAnim 1s linear infinite;
}

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


/* ── New Case Prompt (after report sent) ──────────────────── */

.mobile-new-case-prompt {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.mobile-new-case-prompt p {
    font-size: 14px;
    color: #64748b;
    margin: 0 0 10px;
}

.mobile-new-case-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    background: #18365A;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.mobile-new-case-inline:active {
    transform: scale(0.97);
}

.mobile-new-case-inline svg {
    width: 16px;
    height: 16px;
}


/* ── Hide desktop elements when mobile is active ──────────── */

body.mobile-active .header,
body.mobile-active .main-container,
body.mobile-active .mobile-banner,
body.mobile-active .panel-overlay,
body.mobile-active .panel {
    display: none !important;
}
