/* CSS Variables for theming */
:root {
    --primary-color: #6b5b95;
    --primary-light: #9b8dc4;
    --primary-dark: #4a4073;
    --secondary-color: #feb236;
    --secondary-light: #ffc966;
    --accent-color: #d64161;
    --success-color: #45b7a0;
    --background-color: #f8f6f9;
    --card-background: #ffffff;
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e8e4ec;
    --shadow-sm: 0 2px 4px rgba(107, 91, 149, 0.1);
    --shadow-md: 0 4px 12px rgba(107, 91, 149, 0.15);
    --shadow-lg: 0 8px 24px rgba(107, 91, 149, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s ease;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--background-color) 0%, #ebe6f0 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 30px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: var(--radius-lg);
    color: white;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.header h1 {
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 1rem;
    opacity: 0.9;
    margin-top: 4px;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 8px;
    background: var(--card-background);
    padding: 8px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    white-space: nowrap;
}

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

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

/* Main Content */
.main-content {
    flex: 1;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* Prompt Card */
.prompt-card {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--secondary-light) 100%);
    padding: 24px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.prompt-card h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    opacity: 0.8;
}

.prompt-text {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* Entry Form */
.entry-form {
    background: var(--card-background);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.entry-form h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--primary-color);
}

/* Gratitude Inputs */
.gratitude-inputs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.gratitude-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.item-number {
    width: 32px;
    height: 32px;
    background: var(--primary-light);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.gratitude-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
}

.gratitude-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(107, 91, 149, 0.1);
}

/* Reflection Section */
.reflection-section {
    margin-bottom: 20px;
}

.reflection-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

#reflection {
    width: 100%;
    min-height: 100px;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

#reflection:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(107, 91, 149, 0.1);
}

/* Mood Section */
.mood-section {
    margin-bottom: 24px;
}

.mood-section label {
    display: block;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.mood-options {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.mood-btn {
    width: 50px;
    height: 50px;
    font-size: 1.8rem;
    border: 2px solid var(--border-color);
    background: var(--card-background);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

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

.mood-btn.selected {
    border-color: var(--primary-color);
    background: var(--primary-light);
    transform: scale(1.15);
    box-shadow: var(--shadow-md);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--background-color);
    color: var(--primary-color);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--primary-light);
    color: white;
    border-color: var(--primary-light);
}

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

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

/* History Tab */
.history-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.history-header h2 {
    color: var(--primary-color);
}

.history-actions {
    display: flex;
    gap: 12px;
}

.search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Entries List */
.entries-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.entry-card {
    background: var(--card-background);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary-color);
}

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

.entry-date {
    font-weight: 600;
    color: var(--primary-color);
}

.entry-mood {
    font-size: 1.5rem;
}

.entry-gratitudes {
    list-style: none;
    margin-bottom: 12px;
}

.entry-gratitudes li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.entry-gratitudes li:last-child {
    border-bottom: none;
}

.entry-gratitudes li::before {
    content: "✨";
    flex-shrink: 0;
}

.entry-reflection {
    background: var(--background-color);
    padding: 12px;
    border-radius: var(--radius-sm);
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.entry-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.entry-actions button {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    background: var(--card-background);
    border-radius: var(--radius-md);
}

/* Progress Tab */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-background);
    padding: 20px;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
    margin-bottom: 8px;
}

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

/* Mood Chart */
.mood-chart-section {
    background: var(--card-background);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.mood-chart-section h3 {
    color: var(--primary-color);
    margin-bottom: 16px;
}

.mood-chart {
    min-height: 150px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 20px 0;
}

.mood-bar {
    flex: 1;
    min-width: 30px;
    max-width: 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.mood-bar-fill {
    width: 100%;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: height 0.5s ease;
}

.mood-bar-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    max-height: 60px;
    overflow: hidden;
}

/* Activity Calendar */
.calendar-section {
    background: var(--card-background);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.calendar-section h3 {
    color: var(--primary-color);
    margin-bottom: 16px;
}

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

.calendar-day {
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--border-color);
    position: relative;
}

.calendar-day.has-entry {
    background: var(--primary-light);
}

.calendar-day.today {
    border: 2px solid var(--secondary-color);
}

.calendar-day-label {
    position: absolute;
    bottom: 2px;
    right: 4px;
    font-size: 0.6rem;
    color: var(--text-muted);
}

/* Reminders Tab */
.reminder-description {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.reminder-settings {
    background: var(--card-background);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.reminder-toggle {
    margin-bottom: 20px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.toggle-label input {
    display: none;
}

.toggle-switch {
    width: 50px;
    height: 26px;
    background: var(--border-color);
    border-radius: 13px;
    position: relative;
    transition: var(--transition);
}

.toggle-switch::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.toggle-label input:checked + .toggle-switch {
    background: var(--success-color);
}

.toggle-label input:checked + .toggle-switch::before {
    transform: translateX(24px);
}

.time-picker {
    margin-bottom: 20px;
}

.time-picker label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

#reminder-time {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    width: 100%;
    max-width: 200px;
}

#reminder-time:focus {
    outline: none;
    border-color: var(--primary-color);
}

.notification-status {
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.notification-status.granted {
    background: #e8f5e9;
    color: #2e7d32;
}

.notification-status.denied {
    background: #ffebee;
    color: #c62828;
}

.notification-status.default {
    background: #fff3e0;
    color: #ef6c00;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    margin-top: auto;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--accent-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--card-background);
    padding: 24px;
    border-radius: var(--radius-md);
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

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

.export-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.modal-close {
    width: 100%;
}

/* Responsive Design */
@media (max-width: 600px) {
    .app-container {
        padding: 12px;
    }

    .header {
        padding: 20px 16px;
    }

    .header h1 {
        font-size: 1.4rem;
    }

    .logo-img {
        width: 36px;
        height: 36px;
    }

    .nav-tabs {
        padding: 6px;
        gap: 4px;
    }

    .tab-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .prompt-card {
        padding: 16px;
    }

    .prompt-text {
        font-size: 1.1rem;
    }

    .entry-form {
        padding: 16px;
    }

    .gratitude-item {
        gap: 8px;
    }

    .item-number {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

    .mood-options {
        gap: 8px;
    }

    .mood-btn {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-number {
        font-size: 2rem;
    }

    .history-actions {
        flex-direction: column;
    }

    .search-input,
    #export-btn {
        width: 100%;
    }

    .entry-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .entry-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .mood-btn {
        width: 40px;
        height: 40px;
        font-size: 1.3rem;
    }
}

/* Print Styles */
@media print {
    .nav-tabs,
    .btn,
    .footer {
        display: none;
    }

    .tab-content {
        display: block !important;
    }

    .entry-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}
