/* PhilCheck — Health Journal for Phil */
:root {
    --primary: #2E7D5F;
    --primary-light: #4CAF80;
    --primary-dark: #1B5E40;
    --accent: #FF8F00;
    --bg: #F5F7F5;
    --card: #FFFFFF;
    --text: #2C3E2C;
    --text-light: #6B7B6B;
    --border: #D5DDD5;
    --danger: #D32F2F;
    --success: #2E7D32;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 18px;
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    padding: 20px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header h1 {
    font-size: 28px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 12px;
}
.header h1 .heart { color: #FF6B6B; font-size: 32px; }
.header-stats {
    display: flex;
    gap: 24px;
    font-size: 15px;
    opacity: 0.9;
}
.header-stats span { display: flex; align-items: center; gap: 6px; }
.header-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 15px;
}
.user-greeting { font-weight: 600; }
.user-logins { opacity: 0.8; font-size: 13px; }
.btn-logout {
    padding: 6px 16px;
    background: rgba(255,255,255,0.2);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.35); }
.btn-dashboard {
    padding: 6px 16px;
    background: rgba(255,255,255,0.9);
    color: var(--primary-dark);
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 700;
    transition: background 0.2s;
}
.btn-dashboard:hover { background: white; }

/* Navigation */
.nav-tabs {
    display: flex;
    background: white;
    border-bottom: 2px solid var(--border);
    padding: 0 20px;
}
.nav-tab {
    padding: 16px 28px;
    font-size: 17px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.nav-tab:hover { color: var(--primary); }
.nav-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main Content */
.main { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.panel { display: none; }
.panel.active { display: block; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 28px;
    margin-bottom: 20px;
}
.card h2 {
    font-size: 22px;
    margin-bottom: 16px;
    color: var(--primary-dark);
}

/* Drop Zone */
.drop-zone {
    border: 3px dashed var(--border);
    border-radius: var(--radius);
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #FAFFF8;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: #EFF8EE;
}
.drop-zone .icon { font-size: 52px; margin-bottom: 12px; }
.drop-zone p { font-size: 20px; color: var(--text-light); }
.drop-zone .hint { font-size: 15px; color: #999; margin-top: 8px; }

/* Text Input Area */
.text-input-area {
    margin-top: 20px;
}
.text-input-area textarea {
    width: 100%;
    min-height: 180px;
    padding: 16px;
    font-size: 17px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s;
}
.text-input-area textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.text-input-area textarea::placeholder {
    color: #AAA;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 17px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-danger {
    background: transparent;
    color: var(--danger);
    font-size: 14px;
    padding: 6px 12px;
}
.btn-danger:hover { background: #FFEBEE; }
.btn-mic {
    background: #F3E5F5;
    color: #7B1FA2;
    font-size: 18px;
}
.btn-mic:hover { background: #E1BEE7; }
.btn-mic.recording {
    background: #D32F2F;
    color: white;
    animation: pulse 1s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.btn-group { display: flex; gap: 12px; margin-top: 16px; }

/* Chat Interface */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    min-height: 500px;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.chat-message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 16px;
    font-size: 17px;
    line-height: 1.7;
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.chat-message.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-message.assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.chat-message.assistant p { margin-bottom: 10px; }
.chat-message.assistant p:last-child { margin-bottom: 0; }
.chat-message.assistant ul, .chat-message.assistant ol { margin-left: 20px; margin-bottom: 10px; }
.chat-message.assistant strong { color: var(--primary-dark); }
.chat-message .time {
    font-size: 12px;
    opacity: 0.6;
    margin-top: 6px;
}

.chat-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 0 0;
    border-top: 1px solid var(--border);
}
.chat-input-area input {
    flex: 1;
    padding: 16px 20px;
    font-size: 18px;
    border: 2px solid var(--border);
    border-radius: 28px;
    font-family: inherit;
    transition: border-color 0.2s;
}
.chat-input-area input:focus {
    outline: none;
    border-color: var(--primary);
}
.chat-input-area .btn {
    border-radius: 28px;
    padding: 16px 28px;
    font-size: 18px;
}

.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 14px 20px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
}
.typing-indicator.show { display: flex; gap: 6px; }
.typing-indicator span {
    width: 10px; height: 10px;
    background: var(--primary-light);
    border-radius: 50%;
    animation: bounce 1.4s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Welcome message */
.chat-welcome {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}
.chat-welcome .icon { font-size: 64px; margin-bottom: 16px; }
.chat-welcome h3 { font-size: 24px; color: var(--text); margin-bottom: 12px; }
.chat-welcome p { font-size: 17px; max-width: 500px; margin: 0 auto 8px; }
.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 24px;
}
.suggestion {
    padding: 10px 18px;
    background: #EFF8EE;
    border: 1px solid var(--primary-light);
    border-radius: 20px;
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
}
.suggestion:hover {
    background: var(--primary);
    color: white;
}

/* Entry List */
.entry-item {
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 12px;
    transition: background 0.2s;
}
.entry-item:hover { background: #FAFFF8; }
.entry-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-light);
}
.entry-meta .source {
    background: #EFF8EE;
    padding: 2px 10px;
    border-radius: 12px;
    color: var(--primary);
    font-weight: 600;
}
.entry-preview {
    font-size: 16px;
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Upload status */
.upload-status {
    margin-top: 16px;
    display: none;
}
.upload-status.show { display: block; }
.upload-item {
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.upload-item.success { background: #E8F5E9; color: var(--success); }
.upload-item.error { background: #FFEBEE; color: var(--danger); }
.upload-item .spinner {
    width: 18px; height: 18px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 16px 24px;
    background: var(--primary-dark);
    color: white;
    border-radius: 10px;
    font-size: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* Insight Banner */
.insight-banner {
    background: linear-gradient(135deg, #FFF8E1, #FFF3C4);
    border: 2px solid #FFD54F;
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    animation: slideDown 0.5s ease;
    position: relative;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: none; } }
.insight-icon { font-size: 36px; flex-shrink: 0; }
.insight-content { flex: 1; }
.insight-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}
.insight-text {
    font-size: 18px;
    line-height: 1.6;
    color: #5D4037;
}
.insight-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: #BCA;
    cursor: pointer;
}
.insight-close:hover { color: #555; }
.encourage-banner {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border: 2px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    animation: slideDown 0.5s ease;
    position: relative;
}

/* Tab step numbers */
.tab-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--border);
    color: var(--text-light);
    font-size: 14px;
    font-weight: 700;
    margin-right: 6px;
}
.nav-tab.active .tab-step {
    background: var(--primary);
    color: white;
}

/* How it works banner */
.how-it-works {
    background: linear-gradient(135deg, #E3F2FD, #BBDEFB);
    border: 2px solid #90CAF9;
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 20px;
}
.how-it-works-title {
    font-size: 20px;
    font-weight: 700;
    color: #1565C0;
    margin-bottom: 12px;
}
.how-it-works-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.how-step {
    font-size: 18px;
    color: #1A237E;
    display: flex;
    align-items: center;
    gap: 12px;
}
.how-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1565C0;
    color: white;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
}

/* Go Ask Phil nudge */
.go-ask-phil {
    background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
    border: 2px solid var(--primary-light);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 20px;
    text-align: center;
    animation: slideDown 0.5s ease;
}
.go-ask-phil-text {
    font-size: 20px;
    font-weight: 600;
    color: var(--primary-dark);
    margin-bottom: 14px;
}
.btn-lg {
    padding: 16px 36px;
    font-size: 20px;
    border-radius: 12px;
}

/* Responsive */
@media (max-width: 768px) {
    .header { flex-direction: column; gap: 10px; text-align: center; }
    .header-stats { justify-content: center; }
    .nav-tab { padding: 12px 16px; font-size: 15px; }
    .main { padding: 16px 12px; }
    .card { padding: 20px; }
    .drop-zone { padding: 30px 20px; }
    .chat-message { max-width: 95%; }
    .suggestions { flex-direction: column; align-items: center; }
}
