/* =========================================================================
   MindMate - Style Sheet
   A clean, calming, and responsive design for mental wellness.
   ========================================================================= */

/* --- Variables & Theming --- */
:root {
    /* Color Palette: Soft Pastels */
    --bg-primary: #F0F4F8; /* Soft blueish gray */
    --bg-card: #FFFFFF;
    --primary-color: #8b5cf6; /* Soft Violet */
    --primary-light: #DDD6FE;
    --text-main: #334155; /* Slate 700 */
    --text-muted: #64748B; /* Slate 500 */
    
    /* Layout */
    --border-radius-lg: 16px;
    --border-radius-md: 12px;
    --border-radius-sm: 8px;
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 30px rgba(139, 92, 246, 0.15);
    
    /* Transitions */
    --transition: all 0.3s ease;
}

/* --- Dark Theme Overrides --- */
body.dark-theme {
    --bg-primary: #0F172A; /* Slate 900 */
    --bg-card: #1E293B; /* Slate 800 */
    --text-main: #F1F5F9; /* Slate 100 */
    --text-muted: #94A3B8; /* Slate 400 */
    --primary-color: #A78BFA; /* Lighter Violet for dark mode */
    --primary-light: #312E81; /* Deep Indigo for active tracking */
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-hover: 0 8px 30px rgba(167, 139, 250, 0.2);
}

/* --- Base Reset & Typography --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* --- Layout Structure --- */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* --- Header --- */
.app-header {
    text-align: center;
    padding: 2rem 0 1.5rem;
    position: relative;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-muted);
}

.icon-btn:hover {
    background-color: rgba(139, 92, 246, 0.1);
    transform: scale(1.05);
}

.theme-btn {
    position: absolute;
    top: 1rem;
    right: 0;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 1.5rem;
}

.logo h1 {
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* --- Navigation --- */
.app-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--bg-card);
    padding: 0.5rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-soft);
}

.nav-btn {
    flex: 1;
    max-width: 150px;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--border-radius-md);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.nav-btn:hover {
    background-color: var(--bg-primary);
}

.nav-btn.active {
    background-color: var(--primary-light);
    color: var(--primary-dark-text, #5b21b6);
}

body.dark-theme {
    --primary-dark-text: #E0E7FF;
}

/* --- Main Content Area --- */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* View Toggling */
.view {
    display: block;
    animation: fadeIn 0.4s ease forwards;
}

.view.hidden {
    display: none;
}

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

/* --- Shared Components --- */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-soft);
}

.card h2, .card h3 {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Action Button */
.action-btn {
    width: 100%;
    padding: 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 1rem;
}

.action-btn:hover:not(:disabled) {
    background: #7c3aed;
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.action-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- Home / Mood Tracker --- */
.greeting-card {
    background: var(--greeting-bg, linear-gradient(rgba(240, 244, 248, 0.7), rgba(240, 244, 248, 0.9)), url('bg.png'));
    background-size: cover;
    background-position: center;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

body.dark-theme {
    --greeting-bg: linear-gradient(rgba(15, 23, 42, 0.75), rgba(30, 41, 59, 0.9)), url('bg.png');
}

.mood-selector {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.mood-btn {
    flex: 1;
    min-width: 60px;
    background: var(--bg-primary);
    border: 2px solid transparent;
    border-radius: var(--border-radius-md);
    padding: 1rem 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.mood-btn font-size {
    font-size: 2rem;
}

.mood-btn span {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.mood-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-soft);
}

.mood-btn.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.mood-btn.selected span {
    color: #5b21b6;
}

/* History List */
.history-list {
    margin-top: 1rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

body.dark-theme {
    --border-color: #334155;
}

.history-item:last-child {
    border-bottom: none;
}

.history-mood {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.history-date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.empty-state {
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
    padding: 1rem 0;
    font-size: 0.9rem;
}

/* --- Chat View --- */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 70vh;
    padding: 0; /* Override card padding */
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: var(--bg-primary);
}

body.dark-theme .chat-header {
    border-bottom-color: #334155;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
}

.status {
    font-size: 0.8rem;
    color: #10b981; /* Emerald green */
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: var(--bg-card);
}

.message {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: fadeIn 0.3s ease;
}

.ai-message {
    align-self: flex-start;
    background: var(--bg-primary);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
}

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

.chat-input-area {
    display: flex;
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: var(--bg-primary);
    gap: 0.5rem;
    align-items: center;
}

body.dark-theme .chat-input-area {
    border-top-color: #334155;
}

.mic-btn.active {
    color: #ef4444; /* Red for recording */
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.chat-input {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    background: var(--bg-card);
    color: var(--text-main);
}
body.dark-theme .chat-input {
    border-color: #334155;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.send-btn {
    padding: 0 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.send-btn:hover {
    background: #7c3aed;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-self: flex-start;
    padding: 1rem 1.25rem;
    background: var(--bg-primary);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}


/* --- Wellness View --- */
.wellness-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 600px) {
    .wellness-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.wellness-card {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.wellness-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.wellness-card .w-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

.wellness-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.wellness-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Soft color variations for wellness borders */
.wellness-card.type-breathing { border-left-color: #3b82f6; } /* Blue */
.wellness-card.type-affirmation { border-left-color: #10b981; } /* Green */
.wellness-card.type-exercise { border-left-color: #f59e0b; } /* Amber */

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Responsive constraints */
@media (max-width: 480px) {
    .app-container {
        padding: 0.5rem;
    }
    .card {
        padding: 1.25rem;
    }
    .mood-selector {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }
    .mood-btn {
        min-width: 65px;
    }
}

/* --- New Feature Additions --- */
.daily-quote {
    font-style: italic;
    font-weight: 500;
    color: var(--primary-color);
    margin-top: 0.5rem;
    font-size: 1.05rem;
    line-height: 1.4;
}

/* Mood Stats */
.mood-stats {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

.stat-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.stat-label {
    width: 60px;
}

.stat-bar-bg {
    flex: 1;
    height: 10px;
    background: var(--bg-primary);
    border-radius: 5px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 5px;
    width: 0%; /* Set via JS */
    transition: width 1s ease-out;
}

.stat-percent {
    width: 35px;
    text-align: right;
    color: var(--text-muted);
}

/* Box Breathing Widget */
.breathing-app {
    margin-bottom: 2rem;
}

.breathing-circle-container {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1.5rem 0;
}

.breathing-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.2rem;
    box-shadow: var(--shadow-hover);
    transition: transform 0.5s ease;
}

.breathing-circle.animating {
    animation: boxBreathe 16s infinite linear;
}

/* 4s Inhale, 4s Hold, 4s Exhale, 4s Hold (16s total) */
@keyframes boxBreathe {
    0%   { transform: scale(1); }
    25%  { transform: scale(1.6); } /* Inhale (0-4s) */
    50%  { transform: scale(1.6); } /* Hold (4-8s) */
    75%  { transform: scale(1); }   /* Exhale (8-12s) */
    100% { transform: scale(1); }   /* Hold (12-16s) */
}
