/* Fix streak header layering: ensure no overlap and transparent background */
#streak-flames {
    position: relative;
    z-index: auto;
    background: transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.flame-wrap {
    display: inline-flex;
    align-items: flex-end;
    gap: 6px;
}

.flame {
    display: inline-block;
    transform-origin: 50% 100%;
}

.flame-count {
    font-weight: 700;
}

/* Ensure Current Streak header area is not sticky */
.streak-section h2 {
    position: static;
    background: transparent !important;
    z-index: auto;
    box-shadow: none !important;
    border: none !important;
    padding: 0; /* avoid header panel look */
    top: auto !important;
    left: auto !important;
    right: auto !important;
}

/* Make the inline flame area blend with h2 text */
.streak-section h2 #streak-flames {
    background: transparent !important;
    box-shadow: none !important;
    border: 0 !important;
    margin-left: 8px;
    position: static !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
}

/* Ensure entire streak section has no background contrasting panel */
.streak-section,
.streak-header,
.streak-scroll,
.streak-days {
    background: transparent !important;
    box-shadow: none !important;
}

/* Avoid sticky stacking context if previously set */
.streak-header,
.streak-scroll {
    position: static !important; /* stay in normal flow */
    z-index: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    width: 100%;
    overflow-x: auto; /* ensure horizontal scrolling */
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* smooth iOS/Android */
    overscroll-behavior-x: contain; /* avoid parent scroll hijack */
    touch-action: pan-x; /* allow horizontal gesture */
    scrollbar-gutter: stable both-edges; /* keep content from being cut */
}

.streak-days {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 8px;
    box-sizing: border-box;
    padding: 8px 0; /* vertical breathing room only */
}

.streak-day {
    flex: 0 0 auto; /* prevent shrink clipping */
}

/* Ensure the entire streak section stays in normal flow and doesn't float */
.streak-section {
    position: static !important;
    z-index: auto !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
}
/* General Styles */
* {
    box-sizing: border-box; /* Include padding and border in element's width and height */
}

html, body {
    height: 100%; /* Ensure the html and body take the full height of the viewport */
    width: 100%; /* Ensure no horizontal overflow */
    margin: 0;
    padding: 0;
    overflow: hidden; /* Prevent body scrolling; main will scroll */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

:root {
    --header-height: 70px;
    --footer-height: 50px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu,
                 Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: linear-gradient(to bottom, #ffcccb, #add8e6);
    color: #333;
}

/* Ensure login overlay centers even if login_styles.css fails to load */
#login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#login-form {
    max-width: 400px;
    width: 100%;
}

/* Utility: forcefully hide elements regardless of inline styles */
.hidden {
    display: none !important;
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 10px; /* Remove vertical padding inside header */
    background-color: #ff7f50;
    color: white;
    width: 100%;
    position: fixed; /* Keep header visible at the top */
    top: 0;
    left: 0;
    z-index: 1000;
    height: var(--header-height);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

.header-title {
    font-size: 1.5rem;
    font-weight: bold;
    text-align: center;
    flex-grow: 1;
    margin: 0; /* Remove default h1 top/bottom margin */
}

.logo {
    display: flex;
    align-items: center;
    margin-left: 10px; /* Added margin to the left */
}

.logo img {
    height: 40px;
}

.user-menu {
    position: relative;
    margin-right: 10px; /* Added margin to the right */
}

.user-menu img {
    height: 40px;
    cursor: pointer;
}

.dropdown {
    display: none;
    position: absolute;
    top: 60px;
    right: 10px; /* Adjusted to ensure visibility in mobile view */
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    padding: 10px;
    z-index: 1000;
    width: 200px;
    text-align: left; /* Align text to the left */
}

.dropdown p {
    margin: 5px 0;
    font-size: 14px;
    color: #333;
}

.dropdown button {
    display: block;
    width: 100%;
    margin: 5px 0;
    padding: 10px;
    background: #ff7f50;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

main {
    padding: 10px;
    width: 100%;
    max-width: 100vw; /* Ensure main content does not exceed viewport width */
    overflow-y: auto; /* Scroll within main between header and footer */
    overflow-x: hidden; /* Prevent horizontal overflow */
    position: fixed; /* Pin main between header and footer */
    top: var(--header-height);
    bottom: var(--footer-height);
    left: 0;
    right: 0;
}

.streak, .achievements {
    margin-bottom: 20px;
    text-align: center;
}

.streak-section {
    position: relative;
    display: flex;
    flex-direction: column; /* Ensure heading stays at the top */
    align-items: center;
    justify-content: center;
    max-width: 600px; /* Match achievements container */
    margin: 0 auto; /* Center within main */
    padding: 0 16px; /* Space for arrows at edges */
}

.streak-section h2 {
    position: sticky;
    top: 0;
    background: linear-gradient(to bottom, #ffcccb, #add8e6);
    z-index: 10;
    margin: 0 0 6px 0; /* Reduce extra margin */
    padding: 4px 0;
}

/* Flames next to Current Streak title */
#streak-flames {
    margin-left: 8px;
    font-size: 1.1em; /* slightly larger for visibility */
    vertical-align: middle;
}

/* Single flame + number layout */
#streak-flames .flame-wrap {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

#streak-flames .flame {
    display: inline-block;
    animation: flame-swing 1.4s ease-in-out infinite;
    transform-origin: 50% 100%; /* anchor at bottom center */
}

#streak-flames .flame-count {
    font-weight: 700;
}

/* Subtle left-right swing with fixed bottom */
@keyframes flame-swing {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-6deg); }
    50% { transform: rotate(0deg); }
    75% { transform: rotate(6deg); }
    100% { transform: rotate(0deg); }
}

.streak-scroll {
    width: 100%;
    max-width: 600px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: transparent transparent; /* Default hidden in Firefox */
}

.streak-days {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 10px;
    padding: 0 10px;
}

/* Sleek, auto-hide horizontal scrollbar (WebKit/Blink) */
.streak-scroll::-webkit-scrollbar {
    height: 0px; /* Hidden by default */
    background: transparent;
}

.streak-scroll:hover::-webkit-scrollbar {
    height: 6px; /* Show a slim bar on hover */
}

.streak-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.streak-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.streak-scroll:hover::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.35);
}

/* Firefox: show thin scrollbar only on hover by toggling color */
.streak-scroll:hover {
    scrollbar-color: rgba(0,0,0,0.35) transparent;
}

.streak-day {
    width: 60px;
    height: 80px; /* Increased height for better spacing */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative; /* Ensure tooltip is positioned relative to the icon */
    flex: 0 0 auto; /* Prevent shrinking; keep items fixed size for horizontal scroll */
}

.streak-day svg {
    transition: transform 0.2s ease, fill 0.2s ease; /* Smooth hover effect */
}

.streak-day:hover svg {
    transform: scale(1.1); /* Slight zoom on hover */
}

.day-name {
    margin-top: 5px;
    font-size: 14px; /* Slightly larger font for better readability */
    color: #333;
    text-transform: capitalize; /* Ensure camel case for day names */
}

/* Arrows removed; no styles needed */

footer {
    text-align: center;
    padding: 10px;
    background: #333;
    color: white;
    width: 100%;
    position: fixed; /* Keep footer visible at the bottom */
    bottom: 0;
    left: 0;
    height: var(--footer-height);
}

.tooltip {
    position: absolute;
    bottom: 60px; /* Adjust based on icon size */
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    white-space: nowrap;
    display: none; /* Hidden by default */
    z-index: 1000;
}

.tooltip.visible {
    display: block; /* Show tooltip when visible class is added */
}

.unit-icon {
    width: 20px;
    height: 20px;
    vertical-align: -0.2em; /* Slightly adjust alignment to move the icon up */
    margin-left: 1px; /* Add spacing between the number and the icon */
    display: inline-block; /* Ensure the icon stays inline with the text */
}

span {
    font-weight: bold; /* Make all numbers bold */
}

/* Extra Sections */
.extra-sections {
    position: relative;
    margin: 16px auto; /* Reduce extra margin */
    width: 100%;
    max-width: 600px; /* Match Achievements container width */
    display: flex;
    justify-content: space-between;
    padding: 10px;
    background: linear-gradient(to right, #ffcccb, #add8e6); /* Updated background to match theme */
    border-top: 2px solid #ff7f50; /* Enhanced border for better separation */
    border-radius: 8px; /* Added slight rounding for a modern look */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
}

.extra-sections .section {
    flex: 1;
    margin: 0 10px;
    padding: 15px;
    text-align: center;
    background: #ff7f50; /* Updated button color to match theme */
    color: white; /* White text for contrast */
    border: none;
    border-radius: 8px;
    transition: transform 0.3s, box-shadow 0.3s;
    cursor: pointer;
    font-weight: bold;
}

.extra-sections .section:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2); /* Enhanced shadow on hover */
    background: #ff6347; /* Slightly darker shade on hover */
}

.extra-sections .section h3 {
    font-size: 1.2rem;
    margin: 0;
}

.extra-sections .section:active {
    transform: translateY(0);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.overlay-content {
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    max-height: 80vh; /* Prevent overly tall dialogs */
    overflow: hidden; /* Preserve rounded corners on all sides */
}

.overlay-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 8px 0;
    font-weight: 700;
    border-bottom: 1px solid #eee;
    z-index: 3; /* keep below close button */
}

.close-btn {
    position: absolute;
    top: 6px; /* move slightly up */
    right: 14px; /* move slightly right */
    font-size: 24px;
    cursor: pointer;
    z-index: 10; /* ensure above sticky header */
}

/* Align Activity History overlay data to the left */
#overlay-details {
    margin-top: 0; /* Remove extra margin so header area stays tight */
    text-align: left;
    padding: 10px; /* Add padding for better readability */
    overflow-y: auto; /* Allow internal scrolling if content grows */
    max-height: calc(80vh - 100px); /* Keep content within dialog; adjust as needed */
    border-radius: inherit; /* Match parent rounded corners visually */
}

#overlay-details h4 {
    text-align: left;
    margin-left: 0; /* Align date headers to the left */
}

#overlay-details ul {
    text-align: left;
    padding-left: 20px; /* Indent bullet points for clarity */
}

.achievements-container {
    margin: 20px auto; /* Center the container with spacing */
    padding: 5px 15px; /* Reduced padding above the Achievements text */
    background: #fff; /* White background for visibility */
    border: 2px solid #ff7f50; /* Border matching the theme */
    border-radius: 10px; /* Rounded corners for a modern look */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow for depth */
    max-width: 600px; /* Limit the width for better layout */
    text-align: center; /* Center-align the content */
}

.theme-button {
    background-color: #ff7f50;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.theme-button:hover {
    background-color: #ff6347;
    transform: scale(1.05);
}

.theme-button:active {
    background-color: #e5533d;
    transform: scale(1);
}

#add-achievement-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#add-achievement-form label {
    font-weight: bold;
    text-align: left;
}

#add-achievement-form select,
#add-achievement-form textarea,
#add-achievement-form button {
    font-size: 1rem;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

#add-achievement-form textarea {
    resize: none;
}

#current-day-date {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #333;
}

#add-achievement-btn {
    display: block;
    margin: 10px auto 0; /* Center the button and add spacing */
    text-align: center;
}

/* Celebration animation styles */
.celebration-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 1000;
    display: flex;
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
}

.celebration-star {
    position: absolute;
    width: 40px; /* Increased size */
    height: 40px; /* Increased size */
    background-color: gold;
    clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
    animation: zooming-stars 2s ease-in-out infinite;
}

@keyframes zooming-stars {
    0% {
        transform: scale(0) translateY(0);
        opacity: 1;
    }
    50% {
        transform: scale(2) translateY(-50px); /* Increased scale */
        opacity: 0.9;
    }
    100% {
        transform: scale(0) translateY(-100px);
        opacity: 0;
    }
}

/* Styles for Login Screen */
#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 1000;
}

#login-form {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

#login-form h2 {
    margin-bottom: 20px;
    font-size: 1.8rem;
    color: #333;
}

#login-form label {
    display: block;
    margin: 10px 0 5px;
    font-size: 1rem;
    color: #555;
}

#login-form input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1rem;
}

#login-form button {
    width: 100%;
    padding: 10px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.3s;
}

#login-form button:hover {
    background: #45a049;
}

/* Added to prevent caching of styles */
/* Cache-busting can also be handled by appending a version query parameter to the stylesheet link in HTML */
