/* App Container and Base Styles */
:root {
    --primary-color: #4285f4;
    --secondary-color: #34A853;
    --accent-color: #FBBC05;
    --warning-color: #EA4335;
    --neutral-color: #9AA0A6;
    --background-color: #f9f9f9;
    --card-background: #ffffff;
    --text-color: #202124;
    --text-secondary: #5F6368;
    --border-color: #DADCE0;
    --success-color: #34A853;
    --info-color: #4285f4;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition-speed: 0.3s;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
    margin: 0 auto;
    position: relative;
}

/* App Header Styles */
.app-header {
    background-color: var(--card-background);
    padding: 16px 0 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 16px;
}

.back-link {
    color: var(--text-color);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background-color var(--transition-speed);
}

.back-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.app-header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Navigation Tabs */
.app-nav {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE and Edge */
    margin: 0 4px;
}

.app-nav::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.nav-btn {
    flex: 1;
    padding: 12px 16px;
    text-align: center;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-speed);
}

.nav-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Main Content Area */
.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* Screen Management */
.app-screen {
    display: none;
}

.app-screen.active {
    display: block;
}

/* Welcome Section */
.welcome-section {
    text-align: center;
    margin-bottom: 24px;
}

.welcome-section h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.date-display {
    color: var(--text-secondary);
    margin: 4px 0 16px;
}

.progress-overview {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin-top: 16px;
}

.progress-circle {
    position: relative;
    width: 120px;
    height: 120px;
}

.progress-ring-circle-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.progress-ring-circle {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 108.57344; /* Adjusted for 68% completion */
    transform: rotate(-90deg);
    transform-origin: center;
    transition: stroke-dashoffset 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.progress-text .percentage {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.progress-text .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.streak-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.streak-count, .points {
    text-align: center;
    padding: 12px 16px;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.streak-count .number, .points .number {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.streak-count .label, .points .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Sections Styling */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.section-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Task List */
.today-tasks {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 16px;
}

.checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.task-item.completed .checkbox {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

.task-info {
    flex: 1;
}

.task-info h4 {
    margin: 0;
    font-weight: 500;
}

.task-info p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.task-time {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Insights Section */
.insights-section {
    margin-bottom: 24px;
}

.insight-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.insight-card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    gap: 16px;
    box-shadow: var(--shadow-sm);
}

.insight-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.insight-content h4 {
    margin: 0;
    font-weight: 600;
}

.insight-content p {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Daily Quote */
.daily-quote {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 20px;
    position: relative;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.daily-quote blockquote {
    margin: 0;
    font-size: 1rem;
    font-style: italic;
    color: var(--text-color);
}

.quote-author {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: right;
}

/* 7 Pillars Screen */
.screen-header {
    text-align: center;
    margin-bottom: 24px;
}

.screen-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.screen-header p {
    margin: 8px 0 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.pillars-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.pillar-card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 16px;
    position: relative;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pillar-number {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
}

.pillar-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: rgba(66, 133, 244, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.pillar-card h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.pillar-card p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-grow: 1;
}

.pillar-progress-bar {
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}

.pillar-progress-bar .progress {
    height: 100%;
    background-color: var(--primary-color);
    border-radius: 2px;
}

.pillar-progress-text {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

/* Habits Screen */
.habit-calendar {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-header h3 {
    margin: 0;
    font-weight: 600;
    font-size: 1.125rem;
}

.calendar-nav {
    display: flex;
    gap: 8px;
}

.calendar-nav-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-color);
    transition: background-color var(--transition-speed);
}

.calendar-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.day.prev-month, .day.next-month {
    color: var(--neutral-color);
}

.day.completed {
    background-color: rgba(52, 168, 83, 0.1);
    color: var(--success-color);
}

.day.active {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.habits-list {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.add-habit-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.habit-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.habit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.habit-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.habit-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.habit-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.habit-details h4 {
    margin: 0;
    font-weight: 500;
    font-size: 1rem;
}

.habit-details p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

.habit-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.habit-checkbox.checked {
    background-color: var(--success-color);
    border-color: var(--success-color);
    color: white;
}

/* Journal Screen */
.journal-entries {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.new-entry-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-speed);
}

.new-entry-btn:hover {
    background-color: #3b78db;
}

.entry-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.journal-entry {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
}

.entry-date {
    background-color: var(--primary-color);
    color: white;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.entry-date .day {
    font-size: 1.5rem;
    font-weight: 700;
}

.entry-date .month {
    font-size: 0.75rem;
}

.entry-content {
    padding: 16px;
    flex: 1;
}

.entry-content h4 {
    margin: 0;
    font-weight: 600;
}

.entry-content p {
    margin: 8px 0 12px;
    font-size: 0.875rem;
    color: var(--text-color);
}

.entry-mood {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.entry-mood.happy {
    background-color: rgba(52, 168, 83, 0.1);
    color: var(--success-color);
}

.entry-mood.neutral {
    background-color: rgba(251, 188, 5, 0.1);
    color: var(--accent-color);
}

.entry-mood.sad {
    background-color: rgba(234, 67, 53, 0.1);
    color: var(--warning-color);
}

/* Learn Screen */
.learning-modules {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.module-card {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    gap: 16px;
    position: relative;
    padding: 16px;
}

.module-card.featured {
    border: 2px solid var(--primary-color);
}

.module-tag {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
}

.module-image {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.module-content {
    flex: 1;
}

.module-content h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.module-content p {
    margin: 8px 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.module-info {
    display: flex;
    gap: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Achievements Section */
.achievements-section {
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.achievements-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.achievement {
    padding: 12px;
    background-color: rgba(66, 133, 244, 0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.achievement.locked {
    opacity: 0.6;
}

.achievement-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.achievement-info h4 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
}

.achievement-info p {
    margin: 4px 0 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--card-background);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-around;
    padding: 8px 0;
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--text-secondary);
    padding: 8px 0;
    min-width: 64px;
    transition: color var(--transition-speed);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item span {
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Media Queries for Responsive Design */
@media (min-width: 768px) {
    .app-container {
        max-width: 480px;
        box-shadow: var(--shadow-lg);
        height: 100vh;
        margin: 0 auto;
    }
    
    .pillars-grid,
    .achievements-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* iOS specific styling */
@supports (-webkit-touch-callout: none) {
    /* Safe area for notched devices */
    .app-container {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .bottom-nav {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}

/* PWA Install Prompt */
.install-prompt {
    position: fixed;
    bottom: 80px;
    left: 16px;
    right: 16px;
    background-color: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 50;
    animation: slideUp 0.3s ease-out;
}

.install-prompt-content h3 {
    margin: 0;
    font-size: 1rem;
}

.install-prompt-content p {
    margin: 4px 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.install-actions {
    display: flex;
    gap: 8px;
}

.install-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    font-weight: 500;
    cursor: pointer;
}

.dismiss-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 8px;
    cursor: pointer;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Visual Animations */
.task-item, .habit-item, .module-card, .achievement, .insight-card, .journal-entry {
    transition: transform 0.2s ease;
}

.task-item:active, .habit-item:active, .module-card:active, .achievement:active, .insight-card:active, .journal-entry:active {
    transform: scale(0.98);
}

/* Loading States */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(66, 133, 244, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Notification Badge */
.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--warning-color);
    color: white;
    font-size: 0.75rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Form Elements for adding habits, journal entries, etc. */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input, .form-textarea, .form-select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-color);
    transition: border-color var(--transition-speed);
}

.form-input:focus, .form-textarea:focus, .form-select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-speed);
    width: 100%;
}

.btn-primary:hover {
    background-color: #3b78db;
}

/* Accessibility - Focus States */
a:focus, button:focus, input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Darkmode Support (for future implementation) */
@media (prefers-color-scheme: dark) {
    :root {
        --background-color: #121212;
        --card-background: #1e1e1e;
        --text-color: #e8eaed;
        --text-secondary: #9aa0a6;
        --border-color: #3c4043;
    }
}