/* Theme colors */
:root {
    --red: #d71920;
    --red-dark: #b5161c;
    --red-shadow: rgba(215, 25, 32, 0.15);
    --red-focus: rgba(215, 25, 32, 0.25);
    --red-glow: rgba(215, 25, 32, 0.30);
    --green: #2a7d2a;
}

/* Base reset & typography */
body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: 1.5;
    margin: 0;
    padding: 2rem;
    background: linear-gradient(135deg, #fff 0%, #f7f7f7 100%);
    color: #1a1a1a;
}

/* Back navigation */
.back-nav {
    text-align: center;
    margin-bottom: 0.5rem;
}
.back-nav a {
    color: var(--red);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9rem;
}
.back-nav a:hover {
    text-decoration: underline;
}

/* Page title */
h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--red);
    text-shadow: 1px 1px 2px #aaa;
    font-weight: bold;
}

/* Progress bar */
.progress-wrapper {
    max-width: 600px;
    margin: 0 auto 2rem;
}
#progress-container {
    background: #fff;
    border: 2px solid var(--red);
    border-radius: 12px;
    overflow: hidden;
    height: 22px;
    position: relative;
}
#progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--red), var(--red-dark));
    background-size: 100% 100%;
    transition: width 0.3s;
    position: relative;
}
#progress-bar::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 6px,
        rgba(255, 255, 255, 0.2) 6px,
        rgba(255, 255, 255, 0.2) 12px
    );
    background-size: 17px 17px;
    animation: progress-stripes 0.6s linear infinite;
}
#progress-bar::after {
    content: '🍁';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    line-height: 1;
    background: #fff;
    border-radius: 50%;
    width: 1.6rem;
    height: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
@keyframes progress-stripes {
    from { background-position: 0 0; }
    to { background-position: 17px 0; }
}
#progress-label {
    text-align: center;
    color: var(--red);
    font-weight: bold;
    font-size: 1rem;
    margin-top: 0.35rem;
}

/* Section headings */
h2 {
    display: flex;
    align-items: baseline;
    margin-top: 2.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--red);
    font-size: 1.25rem;
    color: var(--red);
}

/* List containers */
ul {
    background: #fff;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 3px 8px var(--red-shadow);
    border: 2px solid var(--red);
}

/* List items — full-row clickable */
ul li {
    padding: 0.25rem 0;
    transition: color 0.2s;
}

/* Checkboxes */
input[type="checkbox"] {
    transform: scale(1.2);
    cursor: pointer;
    accent-color: var(--red);
}

/* Labels — full-row clickable area */
label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* Optional hover effect */
ul li:hover {
    background-color: #ffe6e6; /* light red highlight */
    border-radius: 6px;
}

/* Strikethrough text when checkbox is checked (CSS-only) */
li:has(input[type="checkbox"]:checked) {
    color: #555;
    text-decoration: line-through;
    text-decoration-color: #555;
}
li {
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s;
}

/* Section progress count — pushed to right edge */
h2 .count {
    margin-left: auto;
}

/* Overall progress styling */
#overall-count {
    font-size: 1.15rem;
    color: var(--red);
    font-weight: bold;
}

/* Add subtle maple leaf icons before section headings */
h2::before {
    content: "🍁 ";
    margin-right: 0.25rem;
}

/* Add a maple leaf background accent for fun */
body::before {
    content: "🍁";
    position: fixed;
    font-size: 200px;
    opacity: 0.05;
    top: 20%;
    left: 75%;
    pointer-events: none;
}

/* Button row */
.button-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

/* Share button */
#share-btn {
    padding: 0.5rem 1.5rem;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
#share-btn:hover {
    background: var(--red-dark);
}
#clear-btn {
    padding: 0.5rem 1.5rem;
    background: #fff;
    color: var(--red);
    border: 2px solid var(--red);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
#clear-btn:hover {
    background: var(--red);
    color: white;
}
.filter-segmented {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    border: 2px solid var(--red);
    border-radius: 12px;
    padding: 0.4rem;
}
.filter-seg {
    position: relative;
    padding: 0.4rem 1rem;
    background: #fff;
    color: var(--red);
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.filter-seg[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    background: var(--red);
    color: #fff;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: normal;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    box-shadow: 0 2px 8px var(--red-glow);
}
.filter-seg[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--red);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}
.filter-seg[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}
.filter-seg[data-tooltip]:hover::before {
    opacity: 1;
}
.filter-seg.active {
    background: var(--red);
    color: #fff;
}
body.show-unchecked li:has(input[type="checkbox"]:checked) {
    display: none;
}
body.show-checked li:has(input[type="checkbox"]:not(:checked)) {
    display: none;
}
li.search-hidden {
    display: none;
}
.no-results {
    text-align: center;
    color: #999;
    padding: 2rem 1rem;
    font-style: italic;
    display: none;
}

/* Settings gear button */
#settings-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1001;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.2s;
}
#settings-btn:hover {
    background: var(--red-dark);
}

/* Settings slide-out panel */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 340px;
    max-width: 85vw;
    background: #fff;
    z-index: 1002;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    padding: 1.5rem;
    box-sizing: border-box;
}
.settings-panel.open {
    transform: translateX(0);
}
.settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.settings-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.settings-header h2 {
    margin: 0;
    border: none;
    font-size: 1.25rem;
}
.settings-header h2::before {
    content: none;
}
.settings-panel h3 {
    color: var(--red);
    font-size: 1rem;
    margin: 0 0 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--red);
}
#settings-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}
#settings-close:hover {
    color: var(--red);
}
.cloud-settings-body {
    padding: 0;
    background: #fff;
}
.cloud-settings-body label {
    display: block;
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 0.35rem;
}
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.1rem;
    height: 1.1rem;
    border: 1.5px solid var(--red);
    border-radius: 50%;
    color: var(--red);
    font-size: 0.7rem;
    font-weight: bold;
    cursor: pointer;
    vertical-align: middle;
    margin-left: 0.25rem;
    line-height: 1;
}
.help-icon:hover, .help-icon:focus {
    background: var(--red);
    color: #fff;
    outline: none;
}
.help-text {
    display: none;
    font-size: 0.8rem;
    font-weight: normal;
    color: #555;
    border-left: 3px solid var(--red);
    padding: 0.5rem 0.75rem;
    margin: 0.35rem 0 0.75rem;
    line-height: 1.5;
}
.help-text.visible {
    display: block;
}
.help-text a {
    color: var(--red);
    text-decoration: underline;
}
.cloud-input-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}
#pantry-id-input, #search-input {
    border: 2px solid var(--red);
    border-radius: 8px;
    outline: none;
    box-sizing: border-box;
}
#pantry-id-input:focus, #search-input:focus {
    box-shadow: 0 0 0 3px var(--red-focus);
}
#pantry-id-input {
    flex: 1;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
}
#save-pantry-id-btn {
    padding: 0.4rem 1rem;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
}
#save-pantry-id-btn:hover {
    background: var(--red-dark);
}
#clear-cloud-btn {
    padding: 0.4rem 1rem;
    background: #fff;
    color: var(--red);
    border: 2px solid var(--red);
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}
#clear-cloud-btn:hover:not(:disabled) {
    background: var(--red);
    color: white;
}
#clear-cloud-btn:disabled, #sync-btn:disabled, #load-btn:disabled {
    background: #ccc;
    color: #888;
    cursor: not-allowed;
}
#clear-cloud-btn:disabled {
    border-color: #ccc;
}
#cloud-status {
    font-size: 0.85rem;
    margin: 0 0 0.75rem;
    min-height: 1.2em;
}
.cloud-btn-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
#sync-btn, #load-btn {
    padding: 0.4rem 1rem;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
#sync-btn:hover:not(:disabled), #load-btn:hover:not(:disabled) {
    background: var(--red-dark);
}
#load-btn {
    background: #fff;
    color: var(--red);
    border: 2px solid var(--red);
}
#load-btn:hover:not(:disabled) {
    background: var(--red);
    color: white;
}

/* Export section in settings */
.export-body {
    margin-top: 0;
}
.cloud-settings-body + h3 {
    margin-top: 1.5rem;
}
.export-desc {
    font-size: 0.8rem;
    color: #555;
    margin: 0 0 0.75rem;
}
.export-row {
    display: flex;
    gap: 0.5rem;
}
#export-format {
    flex: 1;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
    border: 2px solid var(--red);
    border-radius: 8px;
    background: #fff;
    color: var(--red);
    font-weight: bold;
    cursor: pointer;
    outline: none;
}
#export-format:focus {
    box-shadow: 0 0 0 3px var(--red-focus);
}
#export-btn {
    padding: 0.4rem 1rem;
    background: var(--red);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}
#export-btn:hover {
    background: var(--red-dark);
}

/* Unsaved changes banner */
.cloud-dirty-banner {
    max-width: 600px;
    margin: 0 auto 1.5rem;
    padding: 0.5rem 1rem;
    background: #fff8e1;
    border: 2px solid var(--red);
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--red);
}
.cloud-dirty-banner button {
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.75rem;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    margin-left: 0.25rem;
}
.cloud-dirty-banner button:hover {
    background: var(--red-dark);
}

/* Filter bar */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 0 1rem;
}
#category-nav .filter-seg {
    font-size: 0.85rem;
}
#category-nav .badge {
    font-size: 0.7rem;
    opacity: 0.85;
    margin-left: 0.15rem;
}
.filter-bar #search-container {
    flex-basis: 100%;
    max-width: 400px;
}
#search-container {
    position: relative;
}
#search-input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    font-size: 1rem;
    transition: box-shadow 0.2s;
}
#search-input::placeholder {
    color: #aaa;
}
#search-clear {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #999;
    cursor: pointer;
    display: none;
    padding: 0.25rem;
    line-height: 1;
}
#search-clear:hover {
    color: var(--red);
}

/* Tab content panels */
.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
    animation: fadeIn 0.25s ease-in;
}
.tab-content h2 {
    margin-top: 0.5rem;
}
ul.fade-in {
    animation: fadeIn 0.25s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Footer */
.site-footer {
    text-align: center;
    margin-top: 3rem;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
}
.site-footer a {
    color: var(--red);
    text-decoration: none;
    font-weight: bold;
}
.site-footer a:hover {
    text-decoration: underline;
}
.version-sha {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: #999;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Confirmation modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease-in;
}
.modal-box {
    background: #fff;
    border: 2px solid var(--red);
    border-radius: 12px;
    padding: 1.5rem 2rem;
    max-width: 360px;
    width: 90%;
    box-shadow: 0 6px 24px var(--red-focus);
    text-align: center;
}
.modal-message {
    font-size: 1rem;
    color: #1a1a1a;
    margin: 0 0 1.25rem;
    line-height: 1.5;
}
.modal-btn-row {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}
.modal-btn {
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.modal-btn-danger {
    background: var(--red);
    color: #fff;
    border: 2px solid var(--red);
}
.modal-btn-danger:hover {
    background: var(--red-dark);
    border-color: var(--red-dark);
}
.modal-btn-cancel {
    background: #fff;
    color: var(--red);
    border: 2px solid var(--red);
}
.modal-btn-cancel:hover {
    background: var(--red);
    color: #fff;
}
