/* ============================================================
   POPh-EYE | style.css
   Global styles, layout, components, chat Q&A, and responsive
   ============================================================ */

/* --- CSS Variables --- */
:root {
    --gemini-bg: #f0f4f9;
    --gemini-gradient: linear-gradient(135deg, #0052D4 0%, #1a73e8 50%, #00d2ff 100%);
    --text-main: #1f1f1f;
    --text-muted: #5f6368;
    --accent-blue: #0052D4;
    --deep-blue: #1a73e8;
    --card-bg: #ffffff;
    --shadow-bold: 0 10px 30px rgba(0, 0, 0, 0.08);
}

/* --- Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Google Sans', sans-serif;
}

/* --- Body --- */
body {
    background-color: var(--gemini-bg);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(0, 82, 212, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(26, 115, 232, 0.08) 0%, transparent 40%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 5vh;
}

/* ============================================================
   Top Controls
   ============================================================ */
.top-controls {
    position: fixed;
    top: 25px;
    right: 30px;
    display: flex;
    gap: 12px;
    z-index: 1000;
}

.action-btn {
    background: white;
    padding: 10px 22px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #eee;
    color: var(--text-main);
    transition: 0.3s;
}

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

.new-chat-btn {
    display: flex !important;
    align-items: center;
    gap: 7px;
    background: var(--accent-blue) !important;
    color: white !important;
    border-color: var(--accent-blue) !important;
}

.new-chat-btn:hover {
    background: #003fa8 !important;
    color: white !important;
}

/* ============================================================
   Header & Logo
   ============================================================ */
.header-section {
    width: 100%;
    max-width: 1100px;
    padding: 0 25px;
    transition: opacity 0.3s, transform 0.3s;
}

.header-section.hidden {
    display: none;
}

.logo {
    font-size: 5.5rem;
    font-weight: 800;
    background: var(--gemini-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 20px;
    letter-spacing: -2px;
    filter: drop-shadow(0 2px 4px rgba(0, 82, 212, 0.1));
}

.greeting {
    margin-bottom: 60px;
    padding-left: 25px;
    border-left: 6px solid var(--accent-blue);
}

#greet1 {
    font-size: 1.2rem;
    color: #5f6368;
    font-weight: 700;
    margin-bottom: 5px;
}

#greet2 {
    font-size: 3.2rem;
    color: var(--text-main);
    font-weight: 700;
    line-height: 1.2;
}

/* ============================================================
   Suggestion Grid & Cards
   ============================================================ */
.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 180px;
}

.card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 24px;
    min-height: 200px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid transparent;
    box-shadow: var(--shadow-bold);
}

.card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-blue);
    box-shadow: 0 15px 35px rgba(0, 82, 212, 0.15);
}

.card p {
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.5;
    font-weight: 500;
}

.card b {
    color: var(--deep-blue);
    font-weight: 700;
}

.stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 700;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.card i {
    align-self: flex-end;
    background: #f0f7ff;
    padding: 14px;
    border-radius: 12px;
    color: var(--accent-blue);
    font-size: 1.3rem;
}

/* ============================================================
   Lyrics Animation
   ============================================================ */
.lyrics-wrap {
    width: 100%;
    text-align: center;
    margin-bottom: 25px;
    min-height: 24px;
}

#lyrics-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: #80868b;
    letter-spacing: 0.5px;
}

/* ============================================================
   Bottom Container & Input
   ============================================================ */
.bottom-container {
    position: fixed;
    bottom: 0;
    width: 100%;
    background: linear-gradient(to top, #ffffff 85%, rgba(255, 255, 255, 0) 100%);
    padding: 20px 20px 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
}

.prompt-wrapper {
    width: 100%;
    max-width: 850px;
    position: relative;
}

/* --- Mode Selector --- */
.mode-selector {
    position: absolute;
    top: -35px;
    right: 5px;
    display: flex;
    background: #e2e8f0;
    padding: 3px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.mode-btn {
    padding: 4px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: 0.3s;
    color: #64748b;
}

.mode-btn.active {
    background: white;
    color: var(--accent-blue);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* --- Input Box --- */
.input-box {
    width: 100%;
    background: #fff;
    border-radius: 18px;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.06);
}

.input-box:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 4px rgba(0, 82, 212, 0.15), 0 10px 25px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.15rem;
    color: var(--text-main);
    font-weight: 500;
    background: transparent;
}

.actions {
    display: flex;
    gap: 20px;
    color: #5f6368;
    font-size: 1.4rem;
}

.actions i:hover {
    color: var(--accent-blue);
    cursor: pointer;
}

.disclaimer {
    font-size: 0.8rem;
    color: #70757a;
    margin-top: 15px;
    font-weight: 500;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 28px;
    max-width: 620px;
    width: 90%;
    position: relative;
}

.modal-content .dev-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 25px;
    color: var(--accent-blue);
}

.modal-content .dev-list {
    list-style: none;
    margin-bottom: 25px;
    line-height: 2.2;
    font-size: 1.1rem;
    color: var(--text-main);
}

.modal-content .dev-affiliations {
    font-size: 0.95rem;
    color: #5f6368;
    border-top: 2px solid #f0f0f0;
    padding-top: 20px;
    line-height: 1.8;
}

.close-btn {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--accent-blue);
}

/* ============================================================
   Chat Q&A Styles
   ============================================================ */
.chat-container {
    display: none;
    width: 100%;
    max-width: 850px;
    padding: 0 25px;
    flex-direction: column;
    padding-bottom: 220px;
    padding-top: 50px;
}

.chat-container.visible {
    display: flex;
}

.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    max-height: calc(100vh - 260px);
    padding-right: 4px;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: #d0d7e2;
    border-radius: 10px;
}

/* --- Individual message --- */
.chat-message {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

.chat-message.animate-in {
    opacity: 1;
    transform: translateY(0);
}

/* User messages align right */
.user-message {
    flex-direction: row-reverse;
    opacity: 1;
    transform: none;
}

/* --- Bubbles --- */
.message-bubble {
    padding: 14px 18px;
    border-radius: 18px;
    font-size: 1rem;
    line-height: 1.65;
    max-width: 100%;
}

.user-bubble {
    background: var(--accent-blue);
    color: white;
    border-bottom-right-radius: 6px;
    max-width: 72%;
    font-weight: 500;
}

.ai-bubble {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.07);
    border: 1px solid #eef0f5;
}

.ai-bubble strong {
    color: var(--accent-blue);
}

.ai-bubble ul {
    padding-left: 20px;
    margin: 8px 0;
}

.ai-bubble li {
    margin-bottom: 5px;
}

/* Table inside AI bubble */
.ai-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.9rem;
}

.ai-table td {
    padding: 8px 12px;
    border: 1px solid #e8edf5;
}

.ai-table tr:first-child td {
    background: #f0f4fb;
    font-weight: 700;
    color: var(--accent-blue);
}

.ai-table tr:hover td {
    background: #f8faff;
}

/* --- AI Avatar --- */
.ai-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--gemini-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    flex-shrink: 0;
    box-shadow: 0 3px 10px rgba(0, 82, 212, 0.25);
}

/* --- AI Message content wrapper --- */
.message-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ai-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.ai-name {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--accent-blue);
}

/* --- Mode badge --- */
.mode-badge {
    font-size: 0.72rem;
    padding: 2px 9px;
    border-radius: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}

.patient-badge {
    background: #e8f5e9;
    color: #2e7d32;
}

.doctor-badge {
    background: #e3f2fd;
    color: #1565c0;
}

/* --- Message action buttons --- */
.message-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
}

.ai-message:hover .message-actions {
    opacity: 1;
}

.message-actions button {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
    color: #888;
    font-size: 0.8rem;
    transition: 0.2s;
}

.message-actions button:hover,
.message-actions button.active-action {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: #f0f4fb;
}

/* --- Streaming cursor blink --- */
.cursor-blink {
    display: inline-block;
    color: var(--accent-blue);
    font-weight: 400;
    animation: cursor-blink 0.7s steps(1) infinite;
    margin-left: 1px;
    vertical-align: baseline;
    line-height: 1;
}

@keyframes cursor-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* Bubble while streaming — disable pointer events on actions */
.ai-bubble.streaming {
    border-color: rgba(0, 82, 212, 0.2);
    box-shadow: 0 2px 12px rgba(0, 82, 212, 0.08);
}

/* --- Thinking / Waiting Indicator --- */
.thinking-bubble {
    background: white;
    border: 1px solid #eef0f5;
    box-shadow: 0 2px 16px rgba(0, 82, 212, 0.07);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 11px;
    min-width: 280px;
    max-width: 420px;
    position: relative;
    overflow: hidden;
}

/* Shimmer sweep across the whole card */
.thinking-bubble::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        100deg,
        transparent 20%,
        rgba(255, 255, 255, 0.72) 50%,
        transparent 80%
    );
    transform: translateX(-100%);
    animation: thinking-shimmer 1.7s ease-in-out infinite;
}
@keyframes thinking-shimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(160%); }
}

/* Animated "Thinking…" label */
.thinking-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-blue);
    opacity: 0.9;
}
.thinking-label i {
    font-size: 0.85rem;
    animation: spin-slow 2.4s linear infinite;
}
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* Animated dots after the label */
.thinking-dots span {
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent-blue);
    margin-left: 2px;
    animation: dot-bounce 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(1) { animation-delay: 0s;    }
.thinking-dots span:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes dot-bounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: 0.35; }
    40%           { transform: translateY(-5px); opacity: 1;    }
}

/* Skeleton lines */
.sk-line {
    height: 11px;
    border-radius: 6px;
    background: linear-gradient(
        90deg,
        #e9eef6 25%,
        #d5dded 50%,
        #e9eef6 75%
    );
    background-size: 300% 100%;
    animation: sk-wave 1.7s ease-in-out infinite;
}
@keyframes sk-wave {
    0%   { background-position: 100% center; }
    100% { background-position: -100% center; }
}
.sk-line.w-90 { width: 90%; }
.sk-line.w-75 { width: 75%; }
.sk-line.w-55 { width: 55%; }
.sk-line.w-40 { width: 40%; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 900px) {
    .suggestion-grid { grid-template-columns: repeat(2, 1fr); }
    #greet2 { font-size: 2.2rem; }
    .logo { font-size: 4rem; }
}

@media (max-width: 600px) {
    .suggestion-grid { grid-template-columns: 1fr; }
    .top-controls { top: 15px; right: 15px; gap: 8px; }
    .action-btn { padding: 8px 14px; font-size: 0.85rem; }
}