/* --- VARIABLES & THEME --- */
:root {
    /* Default is DARK MODE now */
    --primary: #88B04B;
    --primary-dark: #9bc758;
    --primary-light: #2c3e18;
    --bg-app: #121212;
    --bg-card: #1e1e1e;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --border: #333333;
    --shadow: 0 4px 20px rgba(0,0,0,0.3);
    
    --nav-height: 80px;
    --header-height: 60px;
    --radius-xl: 24px;
    --radius-l: 16px;
    
    --mood-1: #ff6b6b;
    --mood-2: #ff9f43;
    --mood-3: #feca57;
    --mood-4: #9fd356;
    --mood-5: #6bff6b;
}

[data-theme="light"] {
    --primary: #88B04B;
    --primary-dark: #6e8f3d;
    --primary-light: #eef6e0;
    --bg-app: #f2f4f7;
    --bg-card: #ffffff;
    --text-main: #1c1c1e;
    --text-muted: #8e8e93;
    --border: #e5e5ea;
    --shadow: 0 4px 20px rgba(0,0,0,0.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden; /* Prevent body scroll */
    transition: background 0.3s ease, color 0.3s ease;
}

#app {
    display: flex; flex-direction: column; height: 100%;
    max-width: 600px; margin: 0 auto;
    background: var(--bg-app); position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.1);
}

/* --- LOGIN SCREEN REDESIGN --- */
.auth-screen {
    background: var(--bg-app);
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px;
    position: relative;
    z-index: 1000;
}
.auth-content {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}
.logo-area {
    text-align: center;
    margin-bottom: 40px;
}
.app-logo {
    font-size: 60px; margin-bottom: 10px;
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.logo-area h1 { color: var(--primary); font-size: 36px; margin: 0; font-weight: 800; }
.logo-area p { color: var(--text-muted); font-size: 16px; margin-top: 5px; }

.auth-card {
    border: none;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    padding: 0; overflow: hidden;
}
.auth-footer {
    text-align: center; margin-top: 40px; color: var(--text-muted); font-size: 12px; line-height: 1.5;
}
.auth-footer span {
    color: var(--primary); font-weight: 700; cursor: pointer; text-decoration: underline;
}

/* --- MANAGERS --- */
.manager-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex; justify-content: space-between; align-items: center;
}
.manager-item-info { font-weight: 700; font-size: 15px; }
.manager-actions { display: flex; gap: 10px; }
.btn-icon {
    width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--bg-app); display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-main);
}
.input-row-modern {
    display: flex; gap: 10px;
    width: 100%;
}
.input-row-modern input {
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 25px;
    padding: 12px 15px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}
.input-row-modern input#new-item-icon {
    width: 80px; /* Wider for placeholder */
    text-align: center;
    flex-shrink: 0;
}
.input-row-modern input#new-item-label {
    flex: 1;
    min-width: 0; /* Prevents overflow in flex container */
}

.input-row-modern input:focus { border-color: var(--primary); }
.modern-input {
    width: 100%; padding: 12px 20px; border-radius: 25px; 
    border: 1px solid var(--border); background: var(--bg-app); color: var(--text-main);
    font-size: 16px; outline: none;
}

/* Header */
header {
    flex-shrink: 0; height: var(--header-height); padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-app); z-index: 10;
}
.header-title { font-size: 20px; font-weight: 800; }
.header-btn {
    background: none; border: none; cursor: pointer; color: var(--text-main);
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}

/* Main */
main { flex: 1; overflow-y: auto; padding-bottom: 0; scrollbar-width: none; }
main::-webkit-scrollbar { display: none; }

.screen { display: none; padding: 20px; padding-bottom: calc(var(--nav-height) + 40px); animation: fadeIn 0.3s; }
.screen.active { display: block; }

/* FIX: Chat Screen Layout - No scroll on container */
.screen.full-height-screen { 
    padding: 0; 
    height: calc(100vh - var(--nav-height)); /* Full viewport minus nav */
    display: none; 
    flex-direction: column; 
    overflow: hidden; /* Container doesn't scroll */
}
.screen.full-height-screen.active { display: flex; }

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

/* Cards & Components */
.card { background: var(--bg-card); border-radius: var(--radius-l); padding: 20px; margin-bottom: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); }

/* AI Card */
.ai-card { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; position: relative; overflow: hidden; }
.ai-title { font-size: 12px; font-weight: 800; text-transform: uppercase; margin-bottom: 8px; opacity: 0.9; }
.ai-content { font-size: 15px; line-height: 1.5; font-weight: 600; }

/* Detail View */
.entry-detail-card { border: 1px solid var(--border); background: var(--bg-card); border-radius: var(--radius-l); padding: 25px 20px; }
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 25px; }
.detail-mood { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 22px; }
.detail-photo { width: 100%; height: 220px; border-radius: 16px; background-size: cover; background-position: center; margin-bottom: 25px; border: 1px solid var(--border); }
.detail-note { font-size: 16px; line-height: 1.6; margin-bottom: 25px; padding: 20px; background: var(--bg-app); border-radius: 16px; font-style: italic; border: 1px solid var(--border); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 25px; }
.detail-stat { background: var(--bg-app); padding: 12px 16px; border-radius: 16px; display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; border: 1px solid var(--border); color: var(--text-muted); }

/* Updated Chip Styles for Spacing */
.tag-group { margin-bottom: 16px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 5px; }
.detail-chip { background: var(--bg-app); border: 1px solid var(--border); border-radius: 20px; padding: 8px 16px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
[data-theme="light"] .detail-chip { background: #e0e0e0; }

.action-row { display: flex; gap: 12px; margin-top: 30px; }
.btn-action { height: 50px; border-radius: 25px; display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; border: none; flex: 1; }
.btn-edit { background: transparent; border: 2px solid var(--border); color: var(--text-muted); }
.btn-delete { width: 50px; flex: none; background: #ffe5e5; color: #ff6b6b; font-size: 18px; }
[data-theme="dark"] .btn-delete { background: #3a1c1c; }

/* Elements */
.streak-badge { background: #ffecd1; color: #d35400; font-weight: 800; padding: 8px 16px; border-radius: 30px; font-size: 14px; display: flex; gap: 5px; }
[data-theme="dark"] .streak-badge { background: #4a2810; color: #ff9f43; }

input, textarea, select { background: var(--bg-app); color: var(--text-main); border: 1px solid var(--border); }
[data-theme="light"] input, [data-theme="light"] textarea { background-color: #ffffff; color: #1c1c1e; border-color: #e5e5ea; }

.mood-row-container { display: flex; justify-content: space-between; padding: 10px 0; }
.mood-btn { font-size: 32px; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; border-radius: 50%; cursor: pointer; border: 3px solid transparent; }
.mood-btn.selected { transform: scale(1.15); box-shadow: 0 4px 15px rgba(0,0,0,0.1); }

.category-title { margin: 24px 0 12px 0; font-weight: 800; color: var(--text-muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; }
.chip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 10px; }
.select-chip { background: var(--bg-app); border: 1px solid transparent; padding: 12px 5px; border-radius: 16px; text-align: center; cursor: pointer; font-size: 12px; font-weight: 700; display: flex; flex-direction: column; align-items: center; gap: 5px; color: var(--text-muted); }
.select-chip.selected { background: var(--primary); color: white; border-color: var(--primary-dark); }
.select-chip span { font-size: 22px; }

/* Specific style for chips in Manager (boxed) */
.manager-chip {
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    color: var(--text-main);
    font-weight: 700;
    font-size: 12px;
}
.manager-chip span { font-size: 22px; }

textarea.note-input { width: 100%; height: 120px; border-radius: var(--radius-l); padding: 16px; font-family: inherit; font-size: 16px; resize: none; outline: none; }
textarea.note-input:focus { border-color: var(--primary); }

.photo-btn { background: var(--bg-app); border: 1px solid var(--border); padding: 10px 20px; border-radius: 12px; font-weight: 700; font-size: 14px; cursor: pointer; }
.photo-preview { margin-top: 10px; width: 100px; height: 100px; border-radius: 12px; background-size: cover; border: 1px solid var(--border); }

/* Calendar */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 10px; }
.weekday-header { text-align: center; font-size: 12px; color: var(--text-muted); font-weight: 700; padding-bottom: 10px; }
.day-cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 14px; font-weight: 700; cursor: pointer; border: 1px solid transparent; color: var(--text-main); }
.day-cell.today { border-color: var(--primary); color: var(--primary); }

/* Stats */
.stat-row { display: flex; gap: 15px; margin-bottom: 20px; }
.stat-box { flex: 1; background: var(--bg-card); padding: 20px; border-radius: var(--radius-l); text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-num { display: block; font-size: 28px; font-weight: 800; margin-bottom: 4px; }
.stat-lbl { font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.chart-bar-container { display: flex; align-items: flex-end; justify-content: space-between; height: 150px; padding-top: 20px; }
.chart-col { display: flex; flex-direction: column; align-items: center; flex: 1; }
.bar { width: 12px; border-radius: 6px; background: var(--border); min-height: 6px; }
.correlation-graph { height: 150px; display: flex; justify-content: space-around; align-items: flex-end; padding-bottom: 20px; border-bottom: 1px solid var(--border); margin-top: 20px; }
.corr-col { width: 30%; background: var(--primary-light); border-radius: 8px 8px 0 0; display: flex; justify-content: center; align-items: flex-end; position: relative; }
.corr-col[data-mood="low"] { background: #ffe0e0; }
.corr-col[data-mood="mid"] { background: #fff4e0; }
.corr-col[data-mood="high"] { background: #e0ffe0; }

/* Chat */
.chat-container-main { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}
.chat-body { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 15px; 
    padding-bottom: 20px; /* Space above footer */
}
.chat-msg { padding: 10px 15px; border-radius: 18px; max-width: 80%; font-size: 15px; line-height: 1.4; }
.chat-msg.bot { background: var(--bg-card); border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.user { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-footer-main { 
    padding: 15px; 
    background: var(--bg-card); 
    border-top: 1px solid var(--border); 
    display: flex; gap: 10px; flex-shrink: 0; 
}
#chat-input { flex: 1; border-radius: 20px; padding: 10px 15px; }
#chat-send { background: var(--primary); border: none; color: white; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; }

/* Typing Indicator */
.chat-typing { 
    align-self: flex-start; 
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.typing-dot {
    width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
@keyframes typingBounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }


/* History List Item */
.chat-history-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
}
.chat-history-item .date { font-size: 10px; color: var(--text-muted); text-transform: uppercase; font-weight: 700; }
.chat-history-item .preview { font-size: 14px; font-weight: 600; margin-top: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Popups */
.mood-popup-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 300; display: flex; align-items: flex-end; backdrop-filter: blur(5px); }
.mood-popup-content { background: var(--bg-card); width: 100%; border-top-left-radius: 24px; border-top-right-radius: 24px; padding: 30px 20px 50px 20px; text-align: center; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.popup-mood-grid { display: flex; justify-content: space-around; margin-top: 30px; }
.popup-emoji { font-size: 40px; cursor: pointer; transition: transform 0.2s; }
.popup-emoji:active { transform: scale(1.3); }

/* Nav */
.bottom-nav { position: fixed; bottom: 0; width: 100%; max-width: 600px; height: var(--nav-height); background: var(--bg-card); border-top: 1px solid var(--border); display: flex; justify-content: space-around; align-items: center; z-index: 100; border-top-left-radius: 20px; border-top-right-radius: 20px; box-shadow: 0 -5px 20px rgba(0,0,0,0.03); }
.nav-item { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-muted); cursor: pointer; font-size: 10px; font-weight: 700; width: 60px; }
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 24px; height: 24px; stroke-width: 2.5px; }
.fab-container { position: relative; top: -25px; }
.fab { width: 56px; height: 56px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(136, 176, 75, 0.5); cursor: pointer; color: white; }

/* Components */
.btn { width: 100%; padding: 16px; border: none; border-radius: 30px; font-size: 16px; font-weight: 700; cursor: pointer; background: var(--primary); color: white; margin-top: 20px; }
.btn-outline { background: transparent; border: 2px solid var(--border); color: var(--text-muted); box-shadow: none; border-radius: 25px; } /* Added radius */
.auth-tabs { display: flex; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.auth-tab { flex: 1; text-align: center; padding: 15px; font-weight: 700; color: var(--text-muted); cursor: pointer; }
.auth-tab.active { color: var(--primary); border-bottom: 2px solid var(--primary); }
.input-group { margin-bottom: 15px; text-align: left; }
.input-group label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 5px; color: var(--text-muted); text-transform: uppercase; }
.input-group input { width: 100%; padding: 12px; border-radius: 12px; font-size: 16px; }
.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.avatar { width: 80px; height: 80px; background: linear-gradient(135deg, #FF9966, #FF5E62); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; color: white; }
.setting-item { display: flex; justify-content: space-between; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--border); }
.setting-item:last-child { border-bottom: none; }
.setting-label { font-size: 16px; font-weight: 600; }
.switch { position: relative; display: inline-block; width: 50px; height: 28px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(22px); }

/* Utility */
.hidden { display: none !important; }
