﻿/* --- iOS 26 "Liquid Glass" Design System --- */
:root {
    --primary-accent: 30, 144, 255; /* Vibrant iOS Blue */
    --success-color: 40, 167, 69; /* Green for owned categories */
    --soft-radius: 1.5rem;
    --soft-shadow: 0 10px 35px rgba(0, 0, 0, 0.15);
    --backdrop-blur: 20px;
    /* Light Mode Theme */
    --bg-light: #F0F2F5;
    --card-bg-light: rgba(255, 255, 255, 0.6);
    --card-border-light: rgba(255, 255, 255, 0.7);
    --text-primary-light: #1c1c1e;
    --text-secondary-light: #8e8e93;
    --nav-bg-light: rgba(248, 248, 248, 0.8);
    /* Dark Mode Theme */
    --bg-dark: #000000;
    --card-bg-dark: rgba(28, 28, 30, 0.7);
    --card-border-dark: rgba(255, 255, 255, 0.15);
    --text-primary-dark: #ffffff;
    --text-secondary-dark: #8d8d92;
    --nav-bg-dark: rgba(28, 28, 30, 0.75);
    /* --- Phase 1: Safe Area Insets for Xcode Wrapper --- */
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-right: env(safe-area-inset-right, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-inset-left: env(safe-area-inset-left, 0px);
}

/* --- Universal Box Sizing --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* --- Base Theme --- */
html.dark body {
    color: var(--text-primary-dark);
    background: linear-gradient(-45deg, rgb(10, 10, 35), rgb(25, 10, 50), rgb(15, 30, 60), rgb(40, 15, 60));
    background-size: 400% 400%;
    animation: aurora-animation 80s ease infinite;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-primary-light);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
    background: linear-gradient(-45deg, #e0eafc, #cfdef3, #eef1f5, #d6e2ee);
    background-size: 400% 400%;
    animation: aurora-animation 80s ease infinite;
}

/* --- Phase 1: Disable Unwanted Web Behaviors for Native Feel --- */
* {
    -webkit-tap-highlight-color: transparent; /* Disable tap highlight */
    user-select: none; /* Disable text selection for most elements */
    -webkit-user-select: none;
}

/* Re-enable text selection for input fields */
input, textarea {
    user-select: text;
    -webkit-user-select: text;
}
/* --- End Phase 1 --- */

#app-container {
    background-color: var(--card-bg-light);
    border: 1px solid var(--card-border-light);
    box-shadow: var(--soft-shadow);
    border-radius: var(--soft-radius);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    transition: all 0.3s ease;
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
    position: relative;
    z-index: 10;
    padding-top: calc(1.5rem + var(--safe-area-inset-top));
    padding-right: calc(1.5rem + var(--safe-area-inset-right));
    padding-left: calc(1.5rem + var(--safe-area-inset-left));
    padding-bottom: calc(85px + 1.5rem);
    min-height: 100vh;
}

html.dark #app-container {
    background-color: var(--card-bg-dark);
    border: 1px solid var(--card-border-dark);
}

.content-block {
    background-color: rgba(0,0,0,0.02);
    border-radius: 1rem;
    padding: 1.5rem;
}

html.dark .content-block {
    background-color: rgba(255,255,255,0.05);
}

/* --- Glass Components --- */
.glass-card {
    background-color: var(--card-bg-light);
    border: 1px solid var(--card-border-light);
    border-radius: var(--soft-radius);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
    box-shadow: var(--soft-shadow);
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0) 70%), var(--card-bg-light);
}

    .glass-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: inherit;
        padding: 2px;
        background: linear-gradient(to bottom, #999, #444);
        -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        -webkit-mask-composite: destination-out;
        mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
        mask-composite: exclude;
        pointer-events: none;
        z-index: 2;
    }

html.dark .glass-card {
    background-color: var(--card-bg-dark);
    border: 1px solid var(--card-border-dark);
    background: radial-gradient(circle at 50% 0%, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0) 70%), var(--card-bg-dark);
}

.glass-button {
    background: rgba(var(--primary-accent), 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    border: none;
    box-shadow: 0 4px 15px rgba(var(--primary-accent), 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

    .glass-button:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(var(--primary-accent), 0.4);
    }

    .glass-button:active {
        transform: translateY(1px); /* Gives a satisfying press down effect */
        box-shadow: 0 2px 10px rgba(var(--primary-accent), 0.3); /* Softer shadow on press */
    }

    .glass-button.button-destructive {
        background: #dc3545;
        box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
    }

.glass-button-secondary {
    background-color: rgba(0,0,0,0.05);
    color: var(--text-primary-light);
    border: 1px solid transparent;
    padding: 0.75rem 1.5rem;
    border-radius: 9999px;
    font-weight: 600;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

html.dark .glass-button-secondary {
    background-color: rgba(255,255,255,0.08);
    color: var(--text-primary-dark);
}

.glass-button-secondary:hover {
    background-color: rgba(0,0,0,0.1);
}

html.dark .glass-button-secondary:hover {
    background-color: rgba(255,255,255,0.15);
}

.glass-button-secondary.button-destructive {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

    .glass-button-secondary.button-destructive:hover {
        background: rgba(220, 53, 69, 0.3);
    }


.glass-input {
    font-size: 16px;
    background-color: rgba(0,0,0,0.05);
    border: 1px solid transparent;
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    resize: none;
    width: 100%;
    color: var(--text-primary-light);
}

    .glass-input:focus {
        border-color: rgba(var(--primary-accent), 0.5);
        box-shadow: 0 0 0 3px rgba(var(--primary-accent), 0.1);
        outline: none;
    }

html.dark .glass-input {
    background-color: rgba(255,255,255,0.08);
    color: var(--text-primary-dark);
}

/* --- Application-Specific Styles --- */
.app-logo img {
    max-height: 2.5rem; /* 40px */
    display: block;
    margin: 0 auto; /* Centers the logo within its container */
}

/* Handle the case for the text-based settings header */
.app-logo span {
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-primary-light);
}

html.dark .app-logo span {
    color: var(--text-primary-dark);
}


header {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

html.dark header {
    border-bottom-color: var(--card-border-dark);
}

/* --- Modern Settings Page Refactor --- */

.settings-section {
    display: flex;
    flex-direction: column;
}

.settings-header {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary-light);
    margin-bottom: 0.75rem;
    padding-left: 1rem;
}

html.dark .settings-header {
    color: var(--text-secondary-dark);
}

.settings-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    background-color: rgba(0,0,0,0.05);
    transition: background-color 0.2s ease;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.settings-section > .settings-row:first-of-type {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
}

.settings-section > .settings-row:last-of-type {
    border-bottom-left-radius: 0.75rem;
    border-bottom-right-radius: 0.75rem;
    border-bottom: none;
}

html.dark .settings-row {
    background-color: #1c1c1e;
    border-bottom-color: rgba(255,255,255,0.1);
}

.settings-row:hover {
    background-color: rgba(0, 0, 0, 0.08);
}

html.dark .settings-row:hover {
    background-color: #2c2c2e;
}

.settings-row.explainer-row {
    font-size: 0.875rem;
    color: var(--text-secondary-light);
    cursor: default;
    padding-top: 0;
    padding-bottom: 0.85rem;
}

html.dark .settings-row.explainer-row {
    color: var(--text-secondary-dark);
}

.settings-row.explainer-row:hover {
    background-color: rgba(0,0,0,0.05);
}

html.dark .settings-row.explainer-row:hover {
    background-color: #1c1c1e;
}

.settings-row.primary-action {
    justify-content: center;
}

    .settings-row.primary-action span,
    .settings-row.primary-action i {
        color: rgb(var(--primary-accent));
        font-weight: 600;
    }

.settings-row.destructive {
    justify-content: center;
}

    .settings-row.destructive span,
    .settings-row.destructive i {
        color: #ff453a;
    }

.settings-row i {
    color: var(--text-secondary-dark);
    opacity: 0.7;
}

html:not(.dark) .settings-row i {
    color: var(--text-secondary-light);
}

.status-badge-green, .status-badge-yellow {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.5rem;
    border-radius: 99px;
}

.status-badge-green {
    color: #30d158;
    background-color: rgba(48, 209, 88, 0.15);
}

.status-badge-yellow {
    color: #ffd60a;
    background-color: rgba(255, 214, 10, 0.15);
}

/* Toggle Switch Component */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    flex-shrink: 0;
}

    .toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #39393d; /* iOS off-grey */
    transition: .4s;
    border-radius: 34px;
}

html:not(.dark) .slider {
    background-color: #e9e9eb;
}

.slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

input:checked + .slider {
    background-color: #30d158; /* iOS green */
}

    input:checked + .slider:before {
        transform: translateX(20px);
    }
/* --- End Modern Settings Page Refactor --- */

.sso-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.sso-button {
    background-color: rgba(255,255,255,0.08);
    color: var(--text-primary-dark);
    border: 1px solid var(--card-border-dark);
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

    .sso-button:hover {
        background-color: rgba(255,255,255,0.15);
    }

    .sso-button i {
        font-size: 1.25rem;
    }

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary-dark);
    font-size: 0.875rem;
    margin: 1rem 0;
}

    .divider::before, .divider::after {
        content: '';
        flex: 1;
        border-bottom: 1px solid var(--card-border-dark);
    }

    .divider:not(:empty)::before {
        margin-right: .5em;
    }

    .divider:not(:empty)::after {
        margin-left: .5em;
    }

.verify-icon {
    font-size: 3.5rem;
    color: var(--text-secondary-dark);
}

.text-secondary {
    color: var(--text-secondary-dark);
}

/* --- Mobile Navigation and Page Structure --- */
#bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 500;
    background: var(--nav-bg-light);
    backdrop-filter: blur(var(--backdrop-blur));
    -webkit-backdrop-filter: blur(var(--backdrop-blur));
    border-top: 1px solid rgba(0,0,0,0.1);
    padding-top: 10px;
    padding-bottom: calc(10px + var(--safe-area-inset-bottom));
}

    #bottom-nav.hidden {
        display: none;
    }

html.dark #bottom-nav {
    background: var(--nav-bg-dark);
    border-top-color: var(--card-border-dark);
}

.nav-button {
    color: var(--text-secondary-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-grow: 1;
    border-radius: 1rem;
    position: relative;
    padding: 0 0.25rem;
}

html.dark .nav-button {
    color: var(--text-secondary-dark);
}

.nav-button i {
    font-size: 1.5rem;
}

.nav-button svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

.nav-button.active span {
    color: rgb(var(--primary-accent));
}

.nav-button .active-indicator {
    position: absolute;
    bottom: -8px;
    height: 4px;
    width: 24px;
    background-color: rgb(var(--primary-accent));
    border-radius: 2px;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s ease;
}

.nav-button.active .active-indicator {
    opacity: 1;
    transform: scale(1);
}

.page {
    display: none;
    animation: fadeInPage 0.5s ease;
}

    .page.active-page {
        display: block;
    }

@keyframes fadeInPage {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* --- Modals --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

    .modal.hidden {
        display: none;
    }

    .modal.open {
        opacity: 1;
    }

        .modal.open .modal-content-solid {
            transform: scale(1);
        }

.modal-content-solid {
    background-color: var(--bg-light);
    border-radius: var(--soft-radius);
    padding: 2rem;
    box-shadow: var(--soft-shadow);
    max-width: 90%;
    width: 100%;
    position: relative;
    max-height: 90vh;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow-y: auto;
    overflow-x: hidden;
}

@media (min-width: 640px) {
    .modal-content-solid {
        max-width: 448px;
    }
}

html.dark .modal-content-solid {
    background-color: #2c2c2e;
    border: 1px solid var(--card-border-dark);
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.close-button {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    color: var(--text-secondary-light);
    cursor: pointer;
    z-index: 10;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.2s ease;
}

    .close-button:hover {
        background-color: rgba(0,0,0,0.15);
    }

html.dark .close-button {
    background: #3a3a3c;
    color: var(--text-secondary-dark);
}

    html.dark .close-button:hover {
        background-color: #48484a;
    }

/* --- Category Filter --- */
#categoryFilterContainer {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 0.75rem 1rem;
    border-radius: 9999px;
    background-color: rgba(0,0,0,0.1);
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.3), inset -2px -2px 5px rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 1rem;
    max-width: 100%;
    overflow-x: auto;
}

    #categoryFilterContainer::-webkit-scrollbar {
        height: 4px;
    }

    #categoryFilterContainer::-webkit-scrollbar-track {
        background: transparent;
    }

    #categoryFilterContainer::-webkit-scrollbar-thumb {
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
    }


.category-icon-button {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary-light);
    flex-shrink: 0;
    transition: color 0.2s ease, border-color 0.2s ease;
}

html.dark .category-icon-button {
    color: var(--text-secondary-dark);
}

.category-icon-button span {
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
}

.category-icon-button.active {
    color: rgb(var(--primary-accent));
    border-bottom-color: rgb(var(--primary-accent));
}

#aiModal .modal-content-solid {
    height: 85vh;
    max-height: 800px;
    width: 100%;
    max-width: 700px;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
    position: relative;
}

html.dark .ai-chat-header {
    border-bottom-color: var(--card-border-dark);
}

.ai-chat-header .modal-title {
    font-size: 1.25rem;
}

.ai-chat-header .close-button {
    position: static;
    transform: none;
}

.message-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ai-prompt-area {
    padding: 0.75rem;
    border-top: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

html.dark .ai-prompt-area {
    border-top-color: var(--card-border-dark);
}

.ai-prompt-input-group {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

    .ai-prompt-input-group #ai-chat-input {
        border-radius: 1.25rem;
    }

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: 1.25rem;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.5;
}

    .message-bubble.sent {
        background-color: rgb(var(--primary-accent));
        color: white;
        border-bottom-right-radius: 0.25rem;
        align-self: flex-end;
        margin-left: auto;
    }

    .message-bubble.received {
        background-color: rgba(0,0,0,0.08);
        border-bottom-left-radius: 0.25rem;
        align-self: flex-start;
    }

html.dark .message-bubble.received {
    background-color: rgba(255,255,255,0.1);
}

.ai-avatar {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

    .ai-avatar svg {
        width: 100%;
        height: 100%;
    }

/* --- Gear Details Modal --- */
#detailsModal .modal-content-solid {
    padding: 1.5rem;
    max-width: 800px;
}

.details-modal-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.details-modal-header {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.details-modal-content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .details-modal-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 2rem;
    }

    .details-modal-content-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    .form-row-split {
        grid-template-columns: 1fr 1fr;
    }
}

.details-modal-title-group {
    flex: 1;
}

.details-modal-user-col, .details-modal-ai-col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.details-modal-photo-area {
    width: 100%;
    max-width: 300px; /* Limit size on desktop */
    margin: 0 auto;
    aspect-ratio: 16 / 10;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    border-radius: 1rem;
    overflow: hidden;
    background-color: rgba(0,0,0,0.05);
}

html.dark .details-modal-photo-area {
    background-color: rgba(255,255,255,0.05);
}

.details-modal-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary-light);
}

html.dark .photo-upload-placeholder {
    color: var(--text-secondary-dark);
}

.photo-upload-placeholder i {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.photo-upload-placeholder span {
    font-weight: 500;
}

.photo-upload-placeholder.clickable {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

    .photo-upload-placeholder.clickable:hover {
        background-color: rgba(0,0,0,0.05);
    }

html.dark .photo-upload-placeholder.clickable:hover {
    background-color: rgba(255,255,255,0.05);
}

.delete-photo-button {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.8);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .delete-photo-button:hover {
        background: rgba(220, 53, 69, 1);
        transform: scale(1.1);
    }

#upload-progress-container, #receipt-progress-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: rgba(0,0,0,0.1);
}

.upload-progress-bar, .receipt-progress-bar {
    width: 0%;
    height: 100%;
    background-color: rgb(var(--primary-accent));
    transition: width 0.3s ease;
}

.details-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row-split {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.receipt-area {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.receipt-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-grow: 1;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background-color: rgba(0,0,0,0.05);
    color: var(--text-primary-light);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
}

html.dark .receipt-link {
    background-color: rgba(255,255,255,0.08);
    color: var(--text-primary-dark);
}

.receipt-link:hover {
    background-color: rgba(0,0,0,0.1);
}

html.dark .receipt-link:hover {
    background-color: rgba(255,255,255,0.15);
}

.delete-receipt-button {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary-light);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

html.dark .delete-receipt-button {
    color: var(--text-secondary-dark);
}

.delete-receipt-button:hover {
    background-color: rgba(220, 53, 69, 0.2);
    color: #dc3545;
}

.details-modal-footer {
    padding-top: 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.08);
}

html.dark .details-modal-footer {
    border-top-color: var(--card-border-dark);
}

.details-modal-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

    .details-modal-actions .glass-button, .details-modal-actions .glass-button-secondary {
        border-radius: 0.75rem;
    }

.details-modal-ai-col .modal-title {
    margin-bottom: 0.25rem;
}

.details-modal-type {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary-light);
}

.details-modal-specs h3 {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary-light);
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

html.dark .details-modal-specs h3 {
    color: var(--text-secondary-dark);
    border-bottom-color: var(--card-border-dark);
}

.details-modal-specs ul {
    list-style: none;
    padding-left: 0;
    margin: 0 0 1.5rem 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.details-modal-specs li {
    margin-bottom: 0.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary-light);
    margin-bottom: 0.25rem;
}

html.dark .form-label {
    color: var(--text-secondary-dark);
}

/* --- FIX: Fullscreen Loading Indicator --- */
#loading-indicator {
    position: fixed; /* Position relative to the viewport */
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex; /* Use flexbox for centering */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    z-index: 9999; /* Ensure it's on top of all other content */
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

    #loading-indicator.hiding {
        opacity: 0;
        pointer-events: none; /* Make it non-interactive while fading out */
    }

.loading-logo {
    width: 80px;
    height: 80px;
    animation: spin-slow 5s linear infinite;
}

    .loading-logo svg {
        width: 100%;
        height: 100%;
    }

.loading-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary-light);
    transition: opacity 0.3s ease-in-out;
}

html.dark .loading-text {
    color: var(--text-secondary-dark);
}

@keyframes spin-slow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.modal-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    gap: 1.5rem;
    min-height: 250px;
}

@keyframes aurora-animation {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

.image-placeholder-area {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.gear-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gear-name-cutout {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 0.75rem;
    background-color: rgba(0,0,0,0.1);
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.3), inset -2px -2px 5px rgba(255,255,255,0.05);
}

.placeholder-text-engraved {
    color: rgba(255,255,255,0.8);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.4);
    font-weight: 600;
}

#studio-gear-grid {
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.4s ease-out 0.1s, transform 0.4s ease-out 0.1s;
}

    #studio-gear-grid.loaded {
        opacity: 1;
        transform: translateY(0);
    }

.empty-state-container {
    text-align: center;
    padding: 3rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state-icon {
    font-size: 3.5rem;
    color: var(--text-secondary-light);
    opacity: 0.5;
    margin-bottom: 1rem;
}

html.dark .empty-state-icon {
    color: var(--text-secondary-dark);
}

.empty-state-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary-light);
}

html.dark .empty-state-title {
    color: var(--text-primary-dark);
}

.empty-state-text {
    margin-top: 0.5rem;
    max-width: 350px;
    color: var(--text-secondary-light);
}

html.dark .empty-state-text {
    color: var(--text-secondary-dark);
}
/* --- FIX: Body Lock during App Load --- */
body.loading-active {
    overflow: hidden; /* Prevents scrolling while loader is visible */
}

/* --- Planet Loader --- */
:root {
    --loader-size: 150px; /* Overall container size */
    --planet-size: 70px; /* Explicit planet size for easier calculation */
    --planet: #6aa6ff; /* planet base */
    --planet-2: #3c5bd6; /* planet shade */
    --glow: rgba(106,166,255,0.55);
    --note: #fff; /* music note color */
    --ring: rgba(255,255,255,0.15);
    --speed: 5s; /* orbit speed */
    --spin: 6s; /* planet rotation */
    --ring-spacing: 20px; /* The consistent padding between each ring */
}

/* layout */
.planet-loader {
    position: relative;
    width: var(--loader-size);
    height: var(--loader-size);
    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 0 10px var(--glow));
    animation: planet-pulse 4s ease-in-out infinite;
}

    /* planet body */
    .planet-loader .planet {
        position: absolute;
        width: var(--planet-size);
        height: var(--planet-size);
        border-radius: 50%;
        background: radial-gradient(120% 100% at 70% 30%, #fff3 4%, transparent 30%), radial-gradient(100% 100% at 30% 70%, var(--planet) 0%, var(--planet-2) 70%);
        box-shadow: inset -10px -12px 18px #0003, 0 0 18px var(--glow);
        animation: planet-spin var(--spin) linear infinite, planet-breathe 2.6s ease-in-out infinite;
    }

    /* subtle specular highlight */
    .planet-loader .shine {
        position: absolute;
        top: 10%;
        left: 15%;
        width: 35%;
        height: 35%;
        border-radius: 50%;
        background: radial-gradient(circle at 30% 30%, #fff7, #fff0 60%);
        filter: blur(2px);
        pointer-events: none;
    }

    /* orbits */
    .planet-loader .orbit {
        position: absolute;
        border-radius: 50%;
        border: 1.5px solid var(--ring);
        animation: planet-orbit var(--speed) linear infinite;
    }

    /* vary diameters and speeds for depth with explicit pixel spacing */
    .planet-loader .orbit-a {
        width: calc(var(--planet-size) + var(--ring-spacing));
        height: calc(var(--planet-size) + var(--ring-spacing));
        animation-duration: calc(var(--speed) * 1.0);
    }

    .planet-loader .orbit-b {
        width: calc(var(--planet-size) + 2 * var(--ring-spacing));
        height: calc(var(--planet-size) + 2 * var(--ring-spacing));
        animation-duration: calc(var(--speed) * 1.4);
    }

    .planet-loader .orbit-c {
        width: calc(var(--planet-size) + 3 * var(--ring-spacing));
        height: calc(var(--planet-size) + 3 * var(--ring-spacing));
        animation-duration: calc(var(--speed) * 1.9);
    }

    /* notes riding the ring */
    .planet-loader .note {
        position: absolute;
        top: -0.6em;
        left: 50%;
        transform: translateX(-50%);
        font: 700 18px/1 system-ui, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
        color: var(--note);
        text-shadow: 0 0 6px rgba(255,255,255,0.55);
        animation: planet-bob 1.6s ease-in-out infinite;
        opacity: 0.5;
    }

/* animations */
@keyframes planet-orbit {
    from {
        transform: rotate(var(--random-rotation));
    }

    to {
        transform: rotate(calc(360deg + var(--random-rotation)));
    }
}

@keyframes planet-spin {
    to {
        transform: rotate(-360deg);
    }
}

@keyframes planet-breathe {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes planet-pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes planet-bob {
    0%, 100% {
        transform: translate(-50%, 0.1em);
    }

    50% {
        transform: translate(-50%, -0.1em);
    }
}
/* --- End Planet Loader --- */

/* --- Planet Sphere Button --- */
.planet-button {
    /* Scoped CSS Variables */
    --size: 40px;
    --planet-size: 20px;
    --planet: rgb(var(--primary-accent));
    --planet-2: #005ac9;
    --glow: rgba(var(--primary-accent), 0.55);
    --ring: rgba(var(--primary-accent), 0.15);
    --speed: 5s;
    --spin: 6s;
    --ring-spacing: 5px;
    position: relative;
    width: var(--size);
    height: var(--size);
    display: flex;
    justify-content: center;
    align-items: center;
    filter: drop-shadow(0 0 5px var(--glow));
    animation: planet-button-pulse 4s ease-in-out infinite;
    cursor: pointer;
}

    .planet-button .planet {
        position: absolute;
        width: var(--planet-size);
        height: var(--planet-size);
        border-radius: 50%;
        background: radial-gradient(120% 100% at 70% 30%, #fff3 4%, transparent 30%), radial-gradient(100% 100% at 30% 70%, var(--planet) 0%, var(--planet-2) 70%);
        box-shadow: inset -2px -2px 3px #0003, 0 0 5px var(--glow);
        animation: planet-button-spin var(--spin) linear infinite, planet-button-breathe 2.6s ease-in-out infinite;
    }

    .planet-button .shine {
        position: absolute;
        top: 10%;
        left: 15%;
        width: 35%;
        height: 35%;
        border-radius: 50%;
        background: radial-gradient(circle at 30% 30%, #fff7, #fff0 60%);
        filter: blur(1px);
        pointer-events: none;
    }

    .planet-button .orbit {
        position: absolute;
        border-radius: 50%;
        border: 1px solid var(--ring);
        animation: planet-button-orbit var(--speed) linear infinite;
    }

    .planet-button .orbit-a {
        width: calc(var(--planet-size) + var(--ring-spacing));
        height: calc(var(--planet-size) + var(--ring-spacing));
        animation-duration: calc(var(--speed) * 1.0);
    }

    .planet-button .orbit-b {
        width: calc(var(--planet-size) + 2 * var(--ring-spacing));
        height: calc(var(--planet-size) + 2 * var(--ring-spacing));
        animation-duration: calc(var(--speed) * 1.4);
    }

    .planet-button .orbit-c {
        width: calc(var(--planet-size) + 3 * var(--ring-spacing));
        height: calc(var(--planet-size) + 3 * var(--ring-spacing));
        animation-duration: calc(var(--speed) * 1.9);
    }
/* Size Modifiers */
.planet-button-nav {
    --size: 24px;
    --planet-size: 11px;
    --ring-spacing: 3px;
    margin-bottom: 4px; /* Align with other nav icons */
}

.planet-button-header {
    --size: 32px;
    --planet-size: 16px;
    --ring-spacing: 4px;
}
/* Animations */
@keyframes planet-button-orbit {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes planet-button-spin {
    to {
        transform: rotate(-360deg);
    }
}

@keyframes planet-button-breathe {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes planet-button-pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}
/* --- End Planet Sphere Button --- */

/* --- Navigation Bar Icon Redesign --- */
.nav-icon-container {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.nav-button .nav-icon-container i {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

html.dark .nav-button .nav-icon-container i {
    color: rgba(255, 255, 255, 0.9);
}

.nav-button:hover .nav-icon-container {
    transform: translateY(-2px);
}
/* Studio Button: Toned-down Purple Gradient */
.nav-button[data-page="studioPage"] .nav-icon-container {
    background: linear-gradient(45deg, #9333ea, #5b21b6); /* Toned down purple */
    box-shadow: 0 4px 10px rgba(147, 51, 234, 0.3);
}

.nav-button[data-page="studioPage"]:hover .nav-icon-container {
    box-shadow: 0 6px 15px rgba(147, 51, 234, 0.4);
}
/* Add Gear Button: Toned-down Yellow/Orange Gradient */
.nav-button[data-action="add-gear-ai"] .nav-icon-container {
    background: linear-gradient(45deg, #f59e0b, #ea580c); /* Toned down orange */
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.3);
}

.nav-button[data-action="add-gear-ai"]:hover .nav-icon-container {
    box-shadow: 0 6px 15px rgba(245, 158, 11, 0.4);
}
/* Settings Button: Toned-down Green/Blue Gradient */
.nav-button[data-page="settingsPage"] .nav-icon-container {
    background: linear-gradient(45deg, #16a34a, #0891b2); /* Toned down teal */
    box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);
}

.nav-button[data-page="settingsPage"]:hover .nav-icon-container {
    box-shadow: 0 6px 15px rgba(22, 163, 74, 0.4);
}
/* --- End Navigation Bar Icon Redesign --- */

/* --- Login Page Refinements --- */
.login-title-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin-bottom: 1.5rem;
}

.planet-loader-login-decorative {
    --loader-size: 90px;
    --planet-size: 40px;
    --ring-spacing: 12px;
    pointer-events: none;
}

    .planet-loader-login-decorative .note {
        font-size: 14px;
    }
/* --- End Login Page Refinements --- */

/* --- Affiliate Link Styles --- */
#affiliateModal .modal-content-solid {
    max-width: 400px;
}

.affiliate-item {
    cursor: pointer;
    color: #818cf8; /* A nice indigo that stands out */
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
    transition: color 0.2s ease;
}

html.dark .affiliate-item {
    color: #a78bfa; /* A lighter violet for dark mode */
}

.affiliate-item:hover {
    color: #4f46e5; /* A deeper indigo on hover */
}

html.dark .affiliate-item:hover {
    color: #c4b5fd;
}

.affiliate-placeholder {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: rgba(0,0,0,0.05);
    border-radius: 0.75rem;
    font-weight: 500;
}

html.dark .affiliate-placeholder {
    background-color: rgba(255,255,255,0.08);
}

.affiliate-placeholder span {
    font-size: 0.875rem;
    color: var(--text-secondary-light);
}

html.dark .affiliate-placeholder span {
    color: var(--text-secondary-dark);
}

/* --- FIX: Custom SVG Icon Styling --- */
/* This rule ensures our custom SVG piano icon has the same size and color */
/* as the other Font Awesome icons in the category filter bar. */
.custom-svg-icon {
    width: 1.5rem;
    height: 1.5rem;
}

/* --- START: AI Chat Loader Styles --- */
.message-bubble.thinking {
    /* This bubble just needs to be a container for the loader */
    padding: 8px 12px;
    background-color: #e5e7eb; /* Same as model message */
    border-radius: 1.25rem;
    border-bottom-left-radius: 0.25rem;
    display: inline-block; /* Shrink-wrap the loader */
}

.chat-planet-loader {
    --planet-size: 32px;
    --orbit-size-a: 40px;
    --orbit-size-b: 48px;
    --note-size: 8px;
    position: relative;
    width: var(--orbit-size-b);
    height: var(--orbit-size-b);
    flex-shrink: 0;
}

    .chat-planet-loader .planet {
        width: var(--planet-size);
        height: var(--planet-size);
        border-radius: 50%;
        background: radial-gradient(circle at 30% 30%, #a7c5eb, #3b82f6);
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        overflow: hidden;
    }

    .chat-planet-loader .shine {
        position: absolute;
        top: 15%;
        left: 15%;
        width: 40%;
        height: 40%;
        background: white;
        border-radius: 50%;
        opacity: 0.5;
        filter: blur(3px);
    }

    .chat-planet-loader .orbit {
        position: absolute;
        top: 50%;
        left: 50%;
        border: 1px solid rgba(160, 174, 192, 0.4);
        border-radius: 50%;
        animation: orbit-spin 8s linear infinite;
    }

    .chat-planet-loader .orbit-a {
        width: var(--orbit-size-a);
        height: var(--orbit-size-a);
        margin-top: calc(var(--orbit-size-a) / -2);
        margin-left: calc(var(--orbit-size-a) / -2);
    }

    .chat-planet-loader .orbit-b {
        width: var(--orbit-size-b);
        height: var(--orbit-size-b);
        margin-top: calc(var(--orbit-size-b) / -2);
        margin-left: calc(var(--orbit-size-b) / -2);
        animation-duration: 12s;
    }

    .chat-planet-loader .note {
        position: absolute;
        top: -4px;
        left: 50%;
        transform: translateX(-50%);
        font-size: var(--note-size);
        color: #60a5fa;
    }

@keyframes orbit-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}
/* --- END: AI Chat Loader Styles --- */


/* --- START: LAYOUT AND GRID HOTFIX --- */
/* These rules manually replicate the missing Tailwind utility classes */
/* to restore the main page layout. */

.flex.justify-center {
    display: flex;
    justify-content: center;
}

.flex.justify-between {
    display: flex;
    justify-content: space-between;
}

.my-6 {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

#studio-gear-grid.grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 768px) {
    #studio-gear-grid.grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    #studio-gear-grid.grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 1280px) {
    #studio-gear-grid.grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.hidden {
    display: none !important;
}

.overflow-hidden {
    overflow: hidden;
}

.overflow-x-auto {
    overflow-x: auto;
}

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.h-full {
    height: 100%;
}

.relative {
    position: relative;
}

.w-full {
    width: 100%;
}

.w-6 {
    width: 3rem;
}

.h-6 {
    height: 3rem;
}

.h-32 {
    height: 8rem;
}

.object-contain {
    object-fit: contain;
}

.p-4 {
    padding: 1rem;
}

.flex-grow {
    flex-grow: 1;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

.items-center {
    align-items: center;
}

.items-start {
    align-items: flex-start;
}

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.max-w-xs {
    max-width: 20rem;
}

.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mt-6 {
    margin-top: 1.5rem;
}

.mr-2 {
    margin-right: 0.5rem;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-3 {
    gap: 0.75rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.py-2 {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.font-semibold {
    font-weight: 600;
}

.text-xs {
    font-size: 0.75rem;
}

.text-sm {
    font-size: 0.875rem;
}

.text-md {
    font-size: 1rem;
}

.text-purple-400 {
    color: #c084fc;
}

.text-gray-500 {
    color: #6b7280;
}

html.dark .text-gray-500 {
    color: #9ca3af;
}
