/* Basic Reset & Typography */
:root {
    --primary-color: #4dd0e1; /* Bright Aqua Blue */
    --primary-dark: #00acc1;
    --secondary-color: #b2ebf2; /* Lighter Aqua Blue */
    --background-light: #f3fcfc; /* Very light, cool white */
    --text-dark: #333;
    --text-light: #f8f8f8;
    --accent-color: #ffca28; /* Amber for highlights */
    --danger-color: #ef5350; /* Softer Red - retained for general danger buttons */

    /* Updated variables for the heart meter */
    --heart-dirty-color: #000000; /* Black for fill */
    --heart-glow-color: rgba(77, 208, 225, 0.2); /* Even lighter, primary-color based glow */
    --heart-red-color: #FF6666; /* Even brighter red for the base heart */


    --border-color: #cfd8dc; /* Light Grey Blue */
    --shadow-color: rgba(0, 0, 0, 0.1);
    --spacing-unit: 1rem;
    --border-radius: 0.75rem;
}

/* Universal Box Sizing for consistent layout */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    height: 100%; /* Ensure html takes full viewport height for body to follow */
    /* Add safe-area-insets for notched devices */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-light);
    color: var(--text-dark);
    line-height: 1.6;
    display: flex;
    justify-content: center;
    min-height: 100vh; /* Ensure it takes full viewport height */
    overflow-x: hidden; /* Prevent horizontal scrolling */
    -webkit-font-smoothing: antialiased; /* Smoother fonts on iOS */
    -moz-osx-osx-font-smoothing: grayscale; /* Smoother fonts on macOS */
    overscroll-behavior: contain; /* Prevents pull-to-refresh on mobile */
}

/* RTL Support */
html[dir="rtl"] body {
    direction: rtl;
    text-align: right;
}

.container {
    background-color: #ffffff;
    max-width: 900px;
    width: 100%;
    box-shadow: 0 10px 25px var(--shadow-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0; /* Remove margin to fill screen on mobile */
    min-height: 100vh; /* Ensure container fills viewport */
}

/* Header */
.header {
    background-color: var(--primary-color);
    color: var(--text-light);
    padding: calc(var(--spacing-unit) * 1) calc(var(--spacing-unit) * 1.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Subtle shadow for depth */
    z-index: 10; /* Ensure it stays on top */
}

.app-title {
    margin: 0;
    font-weight: 600;
    font-size: 1.8rem;
}

.language-switcher {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 0.4rem 0.8rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.lang-btn.active {
    background: var(--text-light);
    color: var(--primary-dark);
    border-color: var(--text-light);
}

.lang-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.3);
}
.lang-btn:active {
    transform: scale(0.95); /* Shrink slightly on tap */
}

/* Navigation Tabs */
.tabs {
    display: flex;
    justify-content: space-around;
    background-color: var(--primary-color);
    padding: 0.5rem 0;
    border-bottom: 2px solid var(--primary-dark);
    flex-wrap: wrap; /* Allow tabs to wrap on smaller screens */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); /* Subtle shadow below tabs */
    z-index: 5;
}

.tab-button {
    flex-grow: 1;
    background-color: transparent;
    color: var(--text-light);
    border: none;
    padding: 0.8rem 0.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    border-radius: 0.5rem;
    margin: 0.2rem;
    min-width: 90px; /* Ensure buttons don't get too small */
    -webkit-tap-highlight-color: transparent;
}

.tab-button:hover {
    background-color: var(--primary-dark);
}

.tab-button.active {
    background-color: var(--secondary-color);
    color: var(--primary-dark);
    font-weight: 600;
    transform: translateY(-2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.tab-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}


/* Main Content Area */
.main-content {
    padding: calc(var(--spacing-unit) * 1.5);
    flex-grow: 1;
    overflow-y: auto; /* Enable scrolling for content if it overflows */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.tab-content {
    display: none;
    padding-bottom: 2rem; /* Extra padding at bottom for content */
}

.tab-content.active {
    display: block;
}

h2, h3 {
    color: var(--primary-dark);
    margin-top: 0;
    margin-bottom: var(--spacing-unit);
    font-weight: 600;
}

p {
    margin-bottom: var(--spacing-unit);
}

/* Form Elements */
.form-group {
    margin-bottom: var(--spacing-unit) * 1.5;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

input[type="text"],
textarea,
input[type="number"],
input[type="time"] { /* Added time type */
    width: 100%; /* Full width */
    padding: 12px; /* Slightly larger padding for touch */
    border: 1px solid var(--border-color);
    border-radius: 0.75rem; /* More rounded */
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    background-color: #ffffff; /* Explicitly white background */
    color: var(--text-dark);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* Subtle inset shadow */
}

input[type="text"]:focus,
textarea:focus,
input[type="number"]:focus,
input[type="time"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(77, 208, 225, 0.3); /* Brighter, more noticeable focus ring */
}

textarea {
    min-height: 120px; /* Slightly taller */
    resize: vertical;
}

input[type="checkbox"] {
    width: 20px;
    height: 20px;
    min-width: 20px; /* Ensure consistent size */
    min-height: 20px;
    accent-color: var(--primary-color);
    cursor: pointer;
    vertical-align: middle; /* Align with text */
    margin-right: 0.5rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.9rem 1.8rem; /* Larger touch target */
    border-radius: var(--border-radius);
    font-size: 1.05rem; /* Slightly larger text */
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
    margin-top: 0.8rem; /* More space above */
    -webkit-tap-highlight-color: transparent;
}

.primary-btn {
    background-color: var(--primary-color);
    color: var(--text-light);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.primary-btn:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}
.primary-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background-color: var(--primary-dark); /* Darken slightly on active */
}

.secondary-btn {
    background-color: #eceff1; /* Light grey */
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    margin-right: calc(var(--spacing-unit) / 2);
}

.secondary-btn:hover {
    background-color: #cfd8dc; /* Slightly darker grey */
    transform: translateY(-1px);
}
.secondary-btn:active {
    transform: translateY(0);
    background-color: #bfcfe3; /* Darken slightly on active */
    box-shadow: none;
}

.danger-btn {
    background-color: var(--danger-color);
    color: var(--text-light);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.danger-btn:hover {
    background-color: #d32f2f;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}
.danger-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    background-color: #d32f2f; /* Darken slightly on active */
}

/* List Containers */
.list-container {
    background-color: #e0f7fa; /* Even lighter aqua */
    border-radius: var(--border-radius);
    padding: var(--spacing-unit);
    min-height: 100px; /* Ensure visibility */
    border: 1px solid var(--secondary-color);
    margin-top: var(--spacing-unit);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* Subtle inset shadow */
}

.list-item {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 0.6rem;
    padding: var(--spacing-unit);
    margin-bottom: var(--spacing-unit);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    word-wrap: break-word; /* Ensure long text wraps */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.list-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    font-size: 0.9rem;
    color: #607d8b; /* Blue grey */
}

.list-item-content {
    font-size: 1.1rem;
    color: var(--text-dark);
}

.list-item-tag {
    background-color: var(--accent-color);
    color: var(--text-dark);
    padding: 0.2rem 0.6rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    font-weight: 500;
    align-self: flex-start;
}

.list-item-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.list-item-actions button {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.list-item-actions button:hover {
    background-color: var(--primary-color);
    color: var(--text-light);
}
.list-item-actions button:active {
    transform: scale(0.98);
}


.good-deed-item {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.good-deed-item .delete-btn {
    background-color: var(--danger-color);
    color: var(--text-light);
    border: none;
    padding: 0.3rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.good-deed-item .delete-btn:hover {
    background-color: #d32f2f;
}
.good-deed-item .delete-btn:active {
    transform: scale(0.98);
}

/* Vault Specific */
.vault-intro {
    background-color: #e0f7fa; /* Lighter shade of aqua */
    border-left: 5px solid var(--primary-color);
    padding: var(--spacing-unit);
    border-radius: 0.75rem;
    font-style: italic;
    color: var(--primary-dark);
    margin-bottom: calc(var(--spacing-unit) * 2);
}

.vault-cleanup {
    background-color: #fffde7; /* Soft yellow for emphasis */
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 1.5);
    margin-top: calc(var(--spacing-unit) * 2);
    text-align: center;
}

.vault-cleanup h3 {
    margin-top: 0;
    color: #f57f17; /* Darker orange */
}

.vault-cleanup p {
    font-size: 1.05rem;
    margin-bottom: var(--spacing-unit);
}

/* Bad Deeds Meter Styles - REVAMPED VISUAL */
.bad-deeds-meter-container {
    margin-bottom: calc(var(--spacing-unit) * 2);
    display: flex; /* Use flexbox for side-by-side alignment */
    align-items: center; /* Vertically center the items (heart and label) */
    width: 100%; /* Take full width to accommodate language-based shifting */
    height: 150px; /* Fixed height to provide space for content */
    gap: 1.5rem; /* Space between heart and label/KPI */
    padding: 0 1.5rem; /* Padding for the container itself */
    box-sizing: border-box; /* Include padding in width */
    /* border: 1px solid rgba(0,255,0,0.5); /* Temporary: for debugging alignment */
}

/* Language-dependent alignment for the overall container */
html[dir="ltr"] .bad-deeds-meter-container {
    flex-direction: row; /* Heart on left, Label/KPI on right */
    justify-content: space-between; /* Push items to opposite ends */
}
html[dir="rtl"] .bad-deeds-meter-container {
    flex-direction: row-reverse; /* Heart on right, Label/KPI on left */
    justify-content: space-between; /* Push items to opposite ends */
}

/* KPI Number and Label Group */
.meter-text-content {
    display: flex;
    flex-direction: column;
    /* Correct text alignment based on document direction */
    align-items: flex-start; /* Default for LTR */
    flex-grow: 1; /* Allow it to take available space */
}

html[dir="rtl"] .meter-text-content {
    align-items: flex-end; /* Align flex children to the right for RTL */
}

.bad-deeds-kpi-number {
    font-size: 3.5rem; /* Even bigger for KPI */
    font-weight: 700;
    color: var(--primary-dark);
    line-height: 1; /* Tighten line height */
    margin-bottom: 0.2rem;
}

.meter-label {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-dark);
    font-weight: 500;
    white-space: nowrap; /* Keep the label on one line */
}


.meter-heart-wrapper {
    position: relative;
    width: 120px; /* Bounding box for the heart SVG */
    height: 120px;
    flex-shrink: 0; /* Prevent it from shrinking in flex container */
    display: flex;
    justify-content: center;
    align-items: center;
}


.animated-heart-svg-container {
    position: relative;
    width: 100px; /* This will be the actual display size of the SVG heart */
    height: 100px; /* Maintain aspect ratio */
    overflow: visible; /* Allow glow to extend */
    filter: drop-shadow(0 0 10px var(--heart-glow-color)) drop-shadow(0 0 20px var(--heart-glow-color));
}

#animated-heart-svg {
    position: relative; /* Not absolute anymore, so it's part of flow inside container */
    width: 100%; /* Fill parent container */
    height: 100%;
    color: var(--heart-red-color); /* Initial red color, will be overridden by JS fill */
    z-index: 1; /* Keep it at a normal layer */
    animation: beat .8s infinite alternate; /* Apply beat animation to the SVG */
    transform-origin: center;
    transition: fill 0.5s ease-out; /* Smooth transition for fill color */
}

/* Heart beat animation - unchanged */
@keyframes beat {
    to { transform: scale(1.1); }
}

/* The heart-fill-overlay is now removed from HTML and CSS as per new requirement */


/* Message Box (Modal) */
.message-box {
    display: none; /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4); /* Dark overlay */
    align-items: center;
    justify-content: center;
}

.message-box.active {
    display: flex;
}

.message-content {
    background-color: #ffffff;
    margin: auto;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
}

#message-text {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    text-align: initial; /* Allow text alignment based on language */
}
html[dir="rtl"] #message-text {
    text-align: right;
}


.message-actions {
    display: flex;
    justify-content: center;
    gap: var(--spacing-unit);
}

.message-actions button {
    padding: 0.7rem 1.2rem;
}

/* Onboarding Styles */
.onboarding-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--background-light); /* Light background for onboarding */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* Ensure it's on top of everything */
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
    flex-direction: column; /* Allows content to stack vertically */
}

.onboarding-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* Disable interactions when hidden */
    display: none; /* Crucial: ensures it doesn't take up space */
}

.onboarding-screen {
    display: none; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    background-color: #ffffff;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 25px var(--shadow-color);
    transform: translateY(20px); /* Initial state for animation */
    opacity: 0; /* Initial state for animation */
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.onboarding-screen.active {
    display: flex; /* Show active screen */
    transform: translateY(0); /* Animate to normal position */
    opacity: 1; /* Fade in */
}

.onboarding-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 1.5rem;
    border: 3px solid var(--primary-color);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.onboarding-title {
    color: var(--primary-dark);
    font-size: 2rem;
    margin-bottom: 1rem;
}

.onboarding-description {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 2rem;
}

.onboarding-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    width: 100%;
}

.onboarding-buttons .btn {
    flex-grow: 1;
    max-width: 180px;
}

/* RTL for onboarding */
html[dir="rtl"] .onboarding-screen {
    text-align: right;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .container {
        border-radius: 0; /* No border-radius on mobile to feel native */
        box-shadow: none;
    }

    .header {
        border-radius: 0;
        padding-top: calc(var(--spacing-unit) * 1 + env(safe-area-inset-top, 0px)); /* Account for notch */
        padding-bottom: calc(var(--spacing-unit) * 1);
    }

    .main-content {
        padding: var(--spacing-unit);
    }

    .tab-button {
        padding: 0.7rem 0.4rem;
        font-size: 0.85rem;
    }

    .list-item {
        padding: 0.8rem;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 1.6rem;
    }

    .tab-button {
        font-size: 0.8rem;
        padding: 0.6rem 0.3rem;
        min-width: unset; /* Let it shrink more if needed */
    }

    .tabs {
        padding: 0.3rem 0;
    }

    .list-item-content {
        font-size: 1rem;
    }

    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    .good-deed-item span {
        font-size: 1rem;
    }

    .onboarding-title {
        font-size: 1.5rem;
    }

    .onboarding-description {
        font-size: 1.0rem;
    }
}
