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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-dark);
    transition: background 0.3s ease-in-out;
}

/* --- Dark Mode Styles --- */
body.dark-mode {
    --bg-light: #1e293b;
    --bg-white: #334155;
    --text-dark: #f8fafc;
    --text-light: #94a3b8;
    --border: #475569;
    background: linear-gradient(135deg, #1e2749 0%, #2a1d44 100%);
}

body.dark-mode nav {
    background: rgba(30, 41, 59, 0.9);
}

body.dark-mode .content-card,
body.dark-mode .message.ai,
body.dark-mode .chat-input-container,
body.dark-mode .mood-btn,
body.dark-mode .history-icon,
body.dark-mode .activity-list li,
body.dark-mode .modal-content,
body.dark-mode .profile-card,
body.dark-mode .achievement,
body.dark-mode .goal-item,
body.dark-mode .goal-input-container,
body.dark-mode .avatar-option,
body.dark-mode .mood-chart-bar > div {
    background: var(--bg-white);
}
/* --- End Dark Mode Styles --- */


.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Navigation */
nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    border-radius: 15px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    transition: background 0.3s;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-links {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    color: var(--text-dark);
}

.nav-btn:hover, .nav-btn.active {
    background: var(--primary);
    color: white;
}

/* Page Content */
.page {
    display: none;
    animation: fadeIn 0.5s;
}

.page.active {
    display: block;
}

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

.content-card {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    transition: background 0.3s;
}

.content-card h1 {
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 32px;
}

h2 {
    color: var(--primary);
    margin-bottom: 15px;
    font-size: 24px;
}

h3 {
    color: var(--text-dark);
    margin-bottom: 10px;
    font-size: 18px;
}

/* --- NEW & UPDATED Dashboard Styles --- */
.dashboard-header {
    margin-bottom: 30px;
}
#dynamic-greeting {
    color: var(--bg-white);
    font-size: 36px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.daily-quote {
    color: var(--bg-white);
    opacity: 0.9;
    font-size: 18px;
    margin-top: 10px;
    font-style: italic;
}
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 30px;
}
.dashboard-main-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}
.dashboard-sidebar {
    display: flex;
    flex-direction: column;
    gap: 30px;
}
/* No margin on the last card in sidebar */
.dashboard-sidebar .content-card {
    margin-bottom: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
    color: white;
    padding: 20px;
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 8px 32px 0 rgba(0,0,0,0.1);
}
.stat-icon {
    font-size: 36px;
    background: rgba(255,255,255,0.2);
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-value {
    font-size: 28px;
    font-weight: bold;
    margin: 4px 0;
}
.stat-label {
    font-size: 14px;
    opacity: 0.9;
}
    
#dashboard-plan-content h3 {
    font-size: 18px;
    color: var(--secondary);
    margin: 0 0 15px 0;
}
.dashboard-task-list {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.dashboard-task-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-light);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-dark);
}
.dashboard-task-item.completed {
    opacity: 0.6;
    text-decoration: line-through;
}
.dashboard-task-item .icon {
    font-size: 20px;
}
/* --- END NEW Dashboard Styles --- */

/* Chat Interface */
.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
    background: var(--bg-light);
    border-radius: 15px;
    overflow: hidden;
    transition: background 0.3s;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 70%;
    padding: 15px;
    border-radius: 15px;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.message.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 5px;
}

.message.ai {
    align-self: flex-start;
    background: white;
    color: var(--text-dark);
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: background 0.3s, color 0.3s;
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    transition: background 0.3s, border-color 0.3s;
}

.chat-input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    transition: all 0.3s;
    background: transparent;
    color: var(--text-dark);
}

.chat-input:focus {
    border-color: var(--primary);
}

.send-btn {
    padding: 12px 30px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* Mood Tracker */
.mood-selector {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    flex-wrap: wrap;
    gap: 15px;
}

.mood-btn {
    padding: 15px 25px;
    font-size: 40px;
    background: white;
    border: 3px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mood-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.mood-btn.selected {
    border-color: var(--primary);
    background: var(--primary);
    transform: scale(1.1);
}
    
/* Exercises */
.exercise-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.exercise-card {
    background: var(--bg-light);
    padding: 25px;
    border-radius: 15px;
    border-left: 4px solid var(--primary);
    transition: all 0.3s;
    cursor: pointer;
}

.exercise-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.exercise-card h3 {
    margin-bottom: 10px;
}

.exercise-card p {
    color: var(--text-light);
    line-height: 1.6;
}

/* --- UPDATED Interactive Workout Plan --- */
.day-selector {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.day-btn {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: 600;
    border: 2px solid var(--border);
    background: var(--bg-light);
    color: var(--text-dark);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.day-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.day-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.day-plan {
    display: none;
    animation: fadeIn 0.5s;
}

.day-plan.active {
    display: block;
}

.day-plan h3 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--secondary);
    font-size: 22px;
}

.progress-container {
    margin-bottom: 20px;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 5px;
}

.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border);
    border-radius: 6px;
    overflow: hidden;
}

.progress-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 6px;
    transition: width 0.5s ease-in-out;
}

.interactive-activity-list {
    list-style: none;
    padding: 0;
}

.interactive-activity-list li {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 10px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

body.dark-mode .interactive-activity-list li {
    background: var(--bg-white);
}

.interactive-activity-list li.completed {
    opacity: 0.6;
    border-left-color: var(--success);
}

.interactive-activity-list li.completed label {
    text-decoration: line-through;
    color: var(--text-light);
}

.activity-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
}

.activity-details {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.activity-details label {
    color: var(--text-dark);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.activity-details .icon {
    font-size: 22px;
    margin-right: 10px;
}

.activity-duration {
    font-size: 14px;
    color: var(--text-light);
    background: var(--border);
    padding: 4px 8px;
    border-radius: 6px;
    flex-shrink: 0;
}

body.dark-mode .activity-duration {
    background: #475569;
}

/* History Page */
.history-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 10px 20px;
    background: var(--bg-light);
    border: 2px solid var(--border);
    color: var(--text-dark);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}
    
.filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.history-log {
    display: grid;
    gap: 15px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
    transition: opacity 0.3s ease-in-out;
}

.history-icon {
    font-size: 28px;
    background: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: background 0.3s;
}

.history-details p {
    margin: 0;
}

.history-details .history-timestamp {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

/* --- Updated Profile Page Styles --- */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 30px;
}

.profile-card {
    background: var(--bg-light);
    border-radius: 15px;
    padding: 25px;
}
    
.profile-main {
    text-align: center;
    margin-bottom: 20px;
}

.profile-avatar-wrapper {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    cursor: pointer;
}

.profile-avatar {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    color: white;
    transition: transform 0.3s;
}

.profile-avatar-wrapper:hover .profile-avatar {
    transform: scale(1.05);
}

.profile-avatar-wrapper::after {
    content: '✏';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 30px;
    height: 30px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    opacity: 0;
    transition: opacity 0.3s;
}

.profile-avatar-wrapper:hover::after {
    opacity: 1;
}
    
.editable-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
    
.edit-icon {
    cursor: pointer;
    color: var(--text-light);
    font-size: 16px;
    transition: color 0.3s;
}
    
.edit-icon:hover {
    color: var(--primary);
}
    
.editable-input {
    font-size: inherit;
    font-weight: inherit;
    color: var(--text-dark);
    background: rgba(128, 128, 128, 0.1);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 5px;
    text-align: center;
}
    
#profile-name { font-size: 28px; font-weight: bold; color: var(--text-dark); margin-bottom: 5px; }
#profile-status { font-size: 16px; color: var(--text-light); }

.profile-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}
    
.stat-item {
    text-align: center;
}
    
.stat-item .icon { font-size: 24px; color: var(--primary); }
.stat-item .value { font-size: 20px; font-weight: bold; color: var(--text-dark); }
.stat-item .label { font-size: 12px; color: var(--text-light); }
    
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
}
    
.achievement {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 10px;
}
    
.achievement .icon { font-size: 32px; }
.achievement .label { font-size: 12px; margin-top: 5px; color: var(--text-light); }
.achievement.locked { filter: grayscale(1); opacity: 0.6; }
    
.mood-chart-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    height: 120px;
    padding: 10px;
}
    
.mood-chart-bar {
    width: 30px;
    text-align: center;
}
    
.mood-chart-bar > div {
    background: var(--primary);
    border-radius: 5px 5px 0 0;
    transition: height 0.5s ease-out;
}
    
.mood-chart-bar .label {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 5px;
}

.goal-list { list-style: none; padding: 0; }
.goal-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border-radius: 8px;
}
.goal-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); }
.goal-item label { flex: 1; color: var(--text-dark); }
.goal-item.completed label { text-decoration: line-through; color: var(--text-light); }
.goal-input-container {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}
#newGoalInput {
    flex: 1; padding: 10px; border: 2px solid var(--border);
    border-radius: 8px; background: transparent; color: var(--text-dark);
}
#addGoalBtn {
    padding: 10px 15px; background: var(--primary); color: white; border: none;
    border-radius: 8px; cursor: pointer; font-weight: bold;
}
    
.avatar-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}
    
.avatar-option {
    font-size: 40px;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: transform 0.2s, background-color 0.2s;
}
    
.avatar-option:hover {
    transform: scale(1.2);
    background-color: var(--bg-light);
}
/* --- End Profile Page Styles --- */

/* Settings */
.settings-section {
    margin-bottom: 30px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 10px;
    margin-bottom: 15px;
}

.toggle-switch {
    position: relative;
    width: 60px;
    height: 30px;
    background: var(--border);
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s;
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: all 0.3s;
}

.toggle-switch.active::after {
    left: 33px;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.btn-secondary {
    background: var(--text-light);
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-danger {
    background: var(--danger);
}

.btn-danger:hover {
    background: #dc2626;
}

/* Emergency Contact Button */
.emergency-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 70px;
    height: 70px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 5px 20px rgba(239, 68, 68, 0.4);
    transition: all 0.3s;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emergency-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.6);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 20px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    animation: modalSlideIn 0.3s;
    position: relative;
    transition: background 0.3s;
}
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    border: none;
    background: transparent;
}

@keyframes modalSlideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h2 {
    color: var(--danger);
    margin-bottom: 20px;
}

.contact-list {
    text-align: left;
    margin: 20px 0;
}

.contact-item {
    padding: 15px;
    background: var(--bg-light);
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Breathing Exercise */
.breathing-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    margin: 30px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    font-weight: bold;
    animation: breathe 8s infinite ease-in-out;
}

@keyframes breathe {
    0%, 100% { transform: scale(0.9); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; }
}


.breathing-instruction {
    text-align: center;
    font-size: 20px;
    color: var(--text-dark);
    margin-top: 20px;
    font-weight: bold;
    height: 30px;
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}
    
@media (max-width: 768px) {
    nav {
        justify-content: center;
    }
    .logo {
        width: 100%;
        justify-content: center;
        margin-bottom: 15px;
    }
    .nav-links {
        width: 100%;
        justify-content: center;
        gap: 5px;
    }
    .nav-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    .stats-grid, .profile-grid {
        grid-template-columns: 1fr;
    }
    .mood-selector {
        justify-content: center;
    }
    .message {
        max-width: 85%;
    }
    #dynamic-greeting {
        font-size: 28px;
    }
    .daily-quote {
        font-size: 16px;
    }
}