/* Profile page specific layout and control sizing rules. */

/* Keep the main profile card white for contrast against the sand page background */
#profile-form-container {
    background-color: rgb(var(--color-surface-2)) !important;
}

/* Dark mode contrast boosts for profile controls and action links. */
html[data-theme="dark"] #theme-mode-label,
html[data-theme="dark"] #admin-mode-label-mobile,
html[data-theme="dark"] #create-dupr-button,
html[data-theme="dark"] #profile-form-container a[href="index.html"] {
    color: rgb(var(--color-gray-800)) !important;
}

/* Keep section headings legible on dark cards without touching light mode styling. */
html[data-theme="dark"] #profile-form-container h3.text-ocean-blue,
html[data-theme="dark"] #profile-form-container h4.text-ocean-blue {
    color: rgb(var(--color-gray-800)) !important;
}

/* Lift low-contrast helper/status text in dark mode. */
html[data-theme="dark"] #profile-form-container .text-gray-500 {
    color: rgb(var(--color-gray-600)) !important;
}

html[data-theme="dark"] #profile-form-container .text-gray-400 {
    color: rgb(var(--color-gray-600)) !important;
}

/* Ensure dark-mode admin inputs/selectors have visible control surfaces. */
html[data-theme="dark"] #profile-form-container #admin-email-input {
    background-color: rgb(var(--color-gray-50)) !important;
    border-color: rgb(var(--color-border-strong)) !important;
    color: rgb(var(--color-gray-900)) !important;
}

html[data-theme="dark"] #account-management-user-select,
html[data-theme="dark"] #dupr-gender-filter,
html[data-theme="dark"] #dupr-gender-user-select,
html[data-theme="dark"] #dupr-gender-manual-value,
html[data-theme="dark"] #guest-account-select,
html[data-theme="dark"] #unpaid-fees-event-filter,
html[data-theme="dark"] #unpaid-fees-player-filter,
html[data-theme="dark"] #event-management-event-select,
html[data-theme="dark"] #event-management-visibility-filter,
html[data-theme="dark"] #event-management-badge-select,
html[data-theme="dark"] #email-notifications-list {
    background-color: rgb(var(--color-gray-100)) !important;
    border-color: rgb(var(--color-border-strong)) !important;
    color: rgb(var(--color-gray-900)) !important;
}

html[data-theme="dark"] #admin-email-input::placeholder {
    color: rgb(var(--color-gray-500)) !important;
    opacity: 1;
}

html[data-theme="dark"] #admin-email-input:focus,
html[data-theme="dark"] #account-management-user-select:focus,
html[data-theme="dark"] #dupr-gender-filter:focus,
html[data-theme="dark"] #dupr-gender-user-select:focus,
html[data-theme="dark"] #dupr-gender-manual-value:focus,
html[data-theme="dark"] #guest-account-select:focus,
html[data-theme="dark"] #unpaid-fees-event-filter:focus,
html[data-theme="dark"] #unpaid-fees-player-filter:focus,
html[data-theme="dark"] #event-management-event-select:focus,
html[data-theme="dark"] #event-management-visibility-filter:focus,
html[data-theme="dark"] #event-management-badge-select:focus,
html[data-theme="dark"] #email-notifications-list:focus {
    border-color: rgb(var(--color-focus-ring)) !important;
}

/* Lift dark-mode profile toggle cards and labels above the page canvas. */
html[data-theme="dark"] #theme-mode-section,
html[data-theme="dark"] #email-notifications-section,
html[data-theme="dark"] #calendar-sync-section-mobile,
html[data-theme="dark"] #admin-mode-section-mobile {
    background-color: rgb(var(--color-surface-2)) !important;
    border-color: rgb(var(--color-border-strong)) !important;
}

html[data-theme="dark"] #theme-mode-section p,
html[data-theme="dark"] #email-notifications-section p,
html[data-theme="dark"] #calendar-sync-section-mobile p,
html[data-theme="dark"] #admin-mode-section-mobile p {
    color: rgb(var(--color-gray-900)) !important;
}

/* Keep dark-mode toggle tracks/thumbs readable after utility token remaps. */
html[data-theme="dark"] #theme-mode-section label > div:first-of-type,
html[data-theme="dark"] #email-notifications-section label > div:first-of-type,
html[data-theme="dark"] #calendar-sync-section-mobile label > div:first-of-type,
html[data-theme="dark"] #admin-mode-section-mobile label > div:first-of-type {
    background-color: rgb(var(--color-gray-400)) !important;
    border: 1px solid rgb(var(--color-border-strong));
}

html[data-theme="dark"] #theme-mode-section input:checked + div,
html[data-theme="dark"] #email-notifications-section input:checked + div,
html[data-theme="dark"] #calendar-sync-section-mobile input:checked + div,
html[data-theme="dark"] #admin-mode-section-mobile input:checked + div {
    background-color: rgb(var(--color-ocean-blue)) !important;
}

html[data-theme="dark"] #theme-mode-section label > div:last-child,
html[data-theme="dark"] #email-notifications-section label > div:last-child,
html[data-theme="dark"] #calendar-sync-section-mobile label > div:last-child,
html[data-theme="dark"] #admin-mode-section-mobile label > div:last-child {
    background-color: rgb(var(--color-gray-950)) !important;
    border: 1px solid rgb(var(--color-gray-500));
}

/* Replace seafoam/green interactive states with neutral dark hover surfaces. */
html[data-theme="dark"] #admin-mode-button-desktop,
html[data-theme="dark"] #calendar-sync-button {
    -webkit-text-fill-color: currentColor;
}

html[data-theme="dark"] #admin-mode-button-desktop:not(.bg-ocean-blue),
html[data-theme="dark"] #calendar-sync-button:not(.bg-ocean-blue) {
    background-color: rgb(var(--color-surface-2)) !important;
    border-color: rgb(var(--color-ocean-blue)) !important;
    color: rgb(var(--color-ocean-blue)) !important;
    -webkit-text-fill-color: rgb(var(--color-ocean-blue));
}

html[data-theme="dark"] #admin-mode-button-desktop.bg-ocean-blue,
html[data-theme="dark"] #calendar-sync-button.bg-ocean-blue {
    color: rgb(var(--color-text-on-accent)) !important;
    -webkit-text-fill-color: rgb(var(--color-text-on-accent));
}

html[data-theme="dark"] #profile-form-container .hover\:bg-seafoam-light\/45:not(:disabled):hover,
html[data-theme="dark"] #profile-form-container .hover\:bg-seafoam-light\/45:not(:disabled):focus-visible,
html[data-theme="dark"] #profile-form-container .hover\:bg-seafoam-light\/45:not(:disabled):active {
    background-color: rgb(var(--color-gray-200)) !important;
    -webkit-text-fill-color: currentColor;
}

.dupr-link-modal-panel {
    width: 95%;
    max-width: 768px;
    height: calc(100dvh - 1rem);
    max-height: calc(100dvh - 1rem);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
}

.dupr-link-modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

@supports not (height: 100dvh) {
    .dupr-link-modal-panel {
        height: calc(100vh - 1rem);
        max-height: calc(100vh - 1rem);
    }
}

@media (min-width: 768px) {
    .dupr-link-modal-panel {
        height: calc(100dvh - 3rem);
        max-height: calc(100dvh - 3rem);
        margin-top: 1.5rem;
        margin-bottom: 1.5rem;
    }

    @supports not (height: 100dvh) {
        .dupr-link-modal-panel {
            height: calc(100vh - 3rem);
            max-height: calc(100vh - 3rem);
        }
    }
}

.dupr-link-modal-body > iframe {
    display: block;
}

/* Normalize create-event control sizing across browsers/devices */
#create-event-tools .create-event-field {
    height: 42px;
    min-width: 0;
    max-width: 100%;
    background-color: rgb(var(--color-surface-2)) !important;
    box-sizing: border-box;
}

#create-event-tools input.create-event-field,
#create-event-tools select.create-event-field {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

#create-event-tools input.create-event-field[type="number"] {
    -moz-appearance: textfield;
}

#create-event-tools input.create-event-field[type="number"]::-webkit-outer-spin-button,
#create-event-tools input.create-event-field[type="number"]::-webkit-inner-spin-button {
    margin: 0;
}

#create-event-tools .create-event-grid-item {
    min-width: 0;
}

#create-event-tools .create-event-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    flex-wrap: nowrap;
    gap: 0.5rem;
}

#create-event-tools .create-event-header > h4 {
    min-width: 0;
    flex: 1 1 auto;
}

#create-event-tools #create-event-visibility-toggle {
    margin-left: auto;
    flex: 0 0 auto;
}

#create-event-tools .create-event-submit-row {
    display: flex;
    width: 100%;
    justify-content: flex-end !important;
}

/* D1 baseline header layout: keep title left-aligned and button behavior stable across breakpoints. */
#d1-baseline-tools .profile-section-header > h4 {
    text-align: left;
}

#d1-baseline-actions {
    width: 100%;
}

#d1-preview-reset-button {
    width: 100%;
    order: 3;
}

#d1-preview-reset-dry-run-button {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
}

#d1-baseline-download-button {
    order: 2;
    flex: 1 1 0;
    min-width: 0;
}

@media (min-width: 768px) {
    #d1-baseline-actions {
        width: auto;
        margin-left: auto;
        justify-content: flex-end;
    }

    #d1-preview-reset-button {
        width: auto;
        order: 1;
    }

    #d1-preview-reset-dry-run-button {
        order: 2;
        flex: 0 0 auto;
    }

    #d1-baseline-download-button {
        order: 3;
        flex: 0 0 auto;
    }
}

/* Match DUPR ID input height to the existing compact account-action buttons. */
#account-management-editor input.account-management-compact-input {
    height: 34px !important;
    min-height: 34px !important;
    padding-top: 0.25rem !important;
    padding-bottom: 0.25rem !important;
    line-height: 1.1 !important;
    box-sizing: border-box;
}

#create-event-date-input.create-event-field {
    height: 42px !important;
    min-height: 42px !important;
    line-height: 1.2;
    padding-top: 0.5rem !important;
    padding-bottom: 0.5rem !important;
    background-color: rgb(var(--color-surface-2)) !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
}

#profile-page-nav {
    background: linear-gradient(
        135deg,
        rgb(var(--color-hero-gradient-start)) 0%,
        rgb(var(--color-hero-gradient-mid)) 52%,
        rgb(var(--color-ocean-blue)) 100%
    );
}

#profile-page-nav .profile-brand-link,
#profile-page-nav .profile-nav-link {
    color: rgb(var(--color-gray-50));
}

#profile-page-nav .profile-nav-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    min-width: 0;
    padding: 0;
    border: 1px solid rgb(255 255 255 / 0.44);
    border-radius: 0.58rem;
    background: rgb(255 255 255 / 0.14);
    box-shadow: 0 6px 18px rgb(8 28 44 / 0.18);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    transition:
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;
}

#profile-page-nav .profile-nav-icon-button img {
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.96;
}

#profile-page-nav .profile-nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.42rem 0.78rem;
    border: 1px solid currentColor;
    border-radius: 0.58rem;
    background: transparent;
    line-height: 1;
}

#profile-page-nav .profile-brand-link:hover,
#profile-page-nav .profile-brand-link:focus-visible,
#profile-page-nav .profile-nav-link:hover,
#profile-page-nav .profile-nav-link:focus-visible {
    color: rgb(var(--color-gray-100));
}

#profile-page-nav .profile-nav-icon-button:hover,
#profile-page-nav .profile-nav-icon-button:focus-visible {
    background: rgb(255 255 255 / 0.22);
    border-color: rgb(255 255 255 / 0.7);
    box-shadow: 0 8px 22px rgb(8 28 44 / 0.24);
    transform: translateY(-1px);
}

html[data-theme="dark"] #profile-page-nav {
    background: linear-gradient(
        135deg,
        rgb(var(--color-hero-gradient-start)) 0%,
        rgb(var(--color-hero-gradient-mid)) 52%,
        rgb(var(--color-ocean-blue)) 100%
    );
}

html[data-theme="dark"] #profile-page-nav .profile-brand-link,
html[data-theme="dark"] #profile-page-nav .profile-nav-link {
    color: rgb(var(--color-gray-50));
}

html[data-theme="dark"] #profile-page-nav .profile-nav-icon-button {
    border-color: rgb(255 255 255 / 0.34);
    background: rgb(255 255 255 / 0.1);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.26);
}

html[data-theme="dark"] #profile-page-nav .profile-brand-link:hover,
html[data-theme="dark"] #profile-page-nav .profile-brand-link:focus-visible,
html[data-theme="dark"] #profile-page-nav .profile-nav-link:hover,
html[data-theme="dark"] #profile-page-nav .profile-nav-link:focus-visible {
    color: rgb(var(--color-gray-100));
}

html[data-theme="dark"] #profile-page-nav .profile-nav-icon-button:hover,
html[data-theme="dark"] #profile-page-nav .profile-nav-icon-button:focus-visible {
    background: rgb(255 255 255 / 0.16);
    border-color: rgb(255 255 255 / 0.5);
}

#profile-nav-row {
    min-height: 52px;
    gap: 0.5rem;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

.profile-brand-link {
    min-width: 0;
    flex: 1 1 auto;
}

.profile-brand-text {
    display: flex;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
    transform: translateY(0.04em);
}

@media (max-width: 767px) {
    .profile-header-row,
    .profile-section-header {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .profile-header-row > :first-child,
    .profile-section-header > :first-child {
        min-width: 0;
        flex: 1 1 auto;
    }

    .profile-header-actions {
        flex: 0 0 auto;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    #create-event-tools .create-event-header {
        width: 100%;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap !important;
    }
}

.profile-dupr-account-button:not(.hidden) {
    display: inline-flex;
}

.profile-settings-heading {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    gap: 0.28rem;
}

.profile-settings-icon {
    display: block;
    width: 1.35rem;
    height: 1.35rem;
    flex: 0 0 auto;
    opacity: 0.86;
}

#profile-identity-header {
    margin-top: 0.15rem;
}

.rating-label-mobile {
    display: inline;
}

.rating-label-desktop {
    display: none;
}

@media (min-width: 768px) {
    #profile-nav-row {
        min-height: 64px;
        padding-top: 0;
        padding-bottom: 0;
    }

    .rating-label-mobile {
        display: none;
    }

    .rating-label-desktop {
        display: inline;
    }
}
