:root {
    --primary: #00b894;
    --primary-dark: #00896f;
    --primary-glow: rgba(0, 184, 148, 0.3);
    --bg-dark: #09121a;
    --glass-bg: rgba(15, 26, 36, 0.85);
    --glass-border: rgba(0, 184, 148, 0.2);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --bubble-user: linear-gradient(135deg, #00b894, #00cec9);
    --bubble-ai: rgba(255, 255, 255, 0.07);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Background Mesh & Grid */
.background-mesh {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: 
        radial-gradient(circle at 20% 30%, rgba(0, 184, 148, 0.15) 0%, transparent 60%),
        radial-gradient(circle at 80% 70%, rgba(0, 206, 201, 0.12) 0%, transparent 60%),
        radial-gradient(circle at 50% 90%, rgba(15, 23, 42, 0.8) 0%, transparent 70%);
    z-index: 0;
}

/* Backend Status Bar */
#backend-status {
    padding: 5px 24px;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
}

#backend-status.online {
    background: rgba(16, 185, 129, 0.08);
    color: #10b981;
}

#backend-status.offline {
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
}

#backend-status.checking {
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
}

#backend-status .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

#backend-status.online .status-dot {
    box-shadow: 0 0 6px currentColor;
    animation: pulseLive 2s infinite;
}

@keyframes pulseLive {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Modal Name Input */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: #111e29;
    border: 1px solid var(--primary);
    box-shadow: 0 0 30px var(--primary-glow);
    padding: 30px;
    border-radius: 20px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    animation: zoomIn 0.3s ease-out;
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.modal-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.modal-card h2 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    color: #fff;
}

.modal-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.modal-card input {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    outline: none;
    margin-bottom: 20px;
    text-align: center;
}

.modal-card input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: none;
    background: var(--primary);
    color: #09121a;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: #00e6b8;
    transform: translateY(-2px);
}

/* App Container - Super Wide 780px (+50% wider) */
.app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 780px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

@media (min-width: 640px) {
    .app-container {
        height: 92vh;
        border-radius: 20px;
        border: 1px solid var(--glass-border);
    }
}

/* Header */
.app-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(9, 18, 26, 0.8);
    border-bottom: 1px solid var(--glass-border);
}

.doctor-profile {
    display: flex;
    align-items: center;
    gap: 14px;
}

.avatar-container {
    position: relative;
}

.doctor-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border: 2px solid #09121a;
    border-radius: 50%;
}

.doctor-info .title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doctor-info h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
}

.pro-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.doctor-info .subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-header-icon {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-header-icon:hover {
    color: var(--primary);
    border-color: var(--primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-header-download {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.btn-header-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-glow);
    filter: brightness(1.1);
    color: #fff;
}

/* Bar Nama Pasien */
.patient-bar {
    background: rgba(0, 184, 148, 0.1);
    border-bottom: 1px solid rgba(0, 184, 148, 0.2);
    padding: 8px 24px;
    font-size: 0.85rem;
    color: #00cec9;
    display: flex;
    align-items: center;
    gap: 8px;
}

.patient-bar strong {
    color: #fff;
}

/* Paywall Banner */
.paywall-banner {
    background: rgba(245, 158, 11, 0.15);
    border-bottom: 1px solid rgba(245, 158, 11, 0.3);
    padding: 12px 24px;
}
.paywall-banner.hidden { display: none; }

.paywall-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}

.paywall-text {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
}
.paywall-text strong { color: #f59e0b; }
.paywall-text span { color: #cbd5e1; font-size: 0.8rem; }

.btn-pay {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}
.btn-pay:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

/* Chat Area (Dot Matrix Background) */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 16px 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.25s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--glass-border);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-message { align-self: flex-start; }

.ai-message .bubble {
    background: var(--bubble-ai);
    border: 1px solid var(--glass-border);
    border-radius: 4px 18px 18px 18px;
}

.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.user-message .avatar {
    background: var(--primary);
    color: #09121a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

.user-message .bubble {
    background: var(--bubble-user);
    color: #09121a;
    font-weight: 500;
    border-radius: 18px 4px 18px 18px;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.bubble {
    padding: 14px 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.bubble p { margin-bottom: 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble img {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* AI Source Badge */
.ai-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    opacity: 0.75;
}



.ai-source-badge.source-ollama {
    background: rgba(0, 184, 148, 0.15);
    color: #00b894;
    border: 1px solid rgba(0, 184, 148, 0.2);
}



.ai-source-badge.source-fallback {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Streaming text cursor effect */
.streaming-cursor::after {
    content: '|';
    color: var(--primary);
    animation: blinkCursor 0.8s infinite;
}

@keyframes blinkCursor {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 18px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulseDot 1.2s infinite ease-in-out both;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulseDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Input Area */
.input-container {
    padding: 16px 24px;
    background: rgba(9, 18, 26, 0.9);
    border-top: 1px solid var(--glass-border);
}

#imagePreviewContainer {
    position: relative;
    display: inline-block;
    margin-bottom: 12px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    padding: 6px;
    background: rgba(0,0,0,0.4);
}

#imagePreviewContainer.hidden { display: none; }

#imagePreview {
    max-height: 90px;
    border-radius: 6px;
}

#removeImageBtn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ef4444;
    color: white;
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    padding: 6px 12px;
}

.input-row input[type="text"] {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 0.95rem;
    padding: 8px 12px;
    outline: none;
}

.btn-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--primary);
    background: rgba(0, 184, 148, 0.1);
}

.btn-send {
    background: var(--primary);
    color: #09121a;
}

.btn-send:hover {
    background: #00e6b8;
    transform: scale(1.05);
}

.disclaimer-text {
    font-size: 0.72rem;
    color: #64748b;
    margin-top: 10px;
    text-align: center;
}

/* --- Compliance Footer --- */
.app-footer {
    padding: 8px 0 6px;
    text-align: center;
    background: rgba(9, 18, 26, 0.6);
    border-top: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
    text-transform: lowercase;
}

.footer-links, .studio-info {
    pointer-events: auto; /* Tapi link tetap bisa diklik */
}

.footer-links {
    margin-bottom: 4px;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.2);
    text-decoration: none;
    font-size: 0.55rem; /* Mengecilkan ~25% dari sebelumnya */
    transition: color 0.3s;
}

.footer-links a:hover {
    color: var(--primary);
}

.separator {
    color: rgba(255, 255, 255, 0.05);
    margin: 0 5px;
}

.studio-info p {
    color: rgba(255, 255, 255, 0.15);
    font-size: 0.48rem; /* Sangat kecil sesuai permintaan */
    margin: 1px 0;
    font-weight: 300;
}

/* Hide Paywall Banner for Investor Presentation Demo */
#paywall-banner, .paywall-banner {
    display: none !important;
}

.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }
/* Fit the usable viewport and keep the composer visible on phones. */
html { height: 100%; }
body { height: 100dvh; height: var(--visible-height, 100dvh); }
.app-container { height: 100%; min-height: 0; min-width: 0; }
.app-header, .patient-bar, #backend-status, .input-container { flex-shrink: 0; }
.chat-container { min-height: 0; overscroll-behavior: contain; }
.message, .bubble, .doctor-profile, .doctor-info { min-width: 0; }
.bubble { overflow-wrap: anywhere; }
.bubble ul, .bubble ol { padding-left: 20px; }
.input-row input[type="text"] { min-width: 0; font-size: 16px; }
.btn-icon, .btn-header-icon { flex-shrink: 0; }
.modal-overlay { height: var(--visible-height, 100dvh); overflow-y: auto; }
.modal-card { max-height: 100%; overflow-y: auto; }
@media (min-width: 640px) { .app-container { height: 92%; } }
@media (max-width: 639px) {
 .app-container { border: 0; border-radius: 0; padding-top: env(safe-area-inset-top); }
 .app-header { padding: 10px 12px; gap: 8px; }
 .doctor-profile { gap: 8px; flex: 1; }
 .doctor-avatar { width: 40px; height: 40px; }
 .doctor-info h1 { font-size: 1rem; }
 .doctor-info .title-row { gap: 5px; flex-wrap: wrap; }
 .doctor-info .subtitle { font-size: 0.68rem; }
 .pro-badge { font-size: 0.6rem; padding: 2px 5px; }
 .btn-header-download { width: 44px; height: 44px; padding: 0; justify-content: center; }
 .btn-header-download span { display: none; }
 .btn-header-icon { width: 44px; height: 44px; }
 .header-actions { gap: 4px; }
 .patient-bar { padding: 7px 12px; overflow-wrap: anywhere; }
 #backend-status { padding: 5px 12px; font-size: 0.65rem; }
 .chat-container { padding: 14px 10px; gap: 14px; }
 .message { max-width: 95%; gap: 7px; }
 .avatar { width: 28px; height: 28px; }
 .bubble { padding: 12px; font-size: 0.95rem; line-height: 1.55; }
 .input-container { padding: 10px 10px 6px; }
 .input-row { padding: 4px; gap: 2px; }
 .input-row input[type="text"] { padding: 8px 5px; }
 .btn-icon { width: 44px; height: 44px; }
 .disclaimer-text { font-size: 0.65rem; margin-top: 6px; }
 .app-footer { padding: 4px 10px max(5px, env(safe-area-inset-bottom)); }
 .footer-links a { font-size: 0.65rem; display: inline-block; padding: 5px 2px; }
 .studio-info { display: none; }
 .modal-overlay { padding: 16px; }
 .modal-card { padding: 24px 18px; }
 body.keyboard-open .app-footer, body.keyboard-open .disclaimer-text { display: none; }
}
