@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');
@import url('bootstrap/bootstrap.min.css');

:root {
    --topbar-height: 72px;
    --bottom-panel-height: 110px;
}

html, body {
    height: 100%;
    overflow-x: hidden;
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body.blazored-modal-open {
    overflow: hidden;
}

.gymnast-component.draggable:hover,
.gymnast-component.draggable:hover *,
.gymnast-component.draggable:focus,
.gymnast-component.draggable:focus *,
.gymnast-component.draggable:focus-visible,
.gymnast-component.draggable:focus-visible * {
    cursor: move;        /* Fallback */
    cursor: -webkit-grab; /* Safari */
    cursor: -moz-grab;    /* Old Firefox */
    cursor: grab;
}

body {
    padding-top: var(--topbar-height);
}

.top-bar {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.page {
    height: 100%;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}


.full-height-container {
    min-height: calc(100vh - 57px);
}

.full-height-container .col-md-2 .p-3 ul {
    flex-grow: 0;
}

.nav {
    display: flex;
    flex-direction: row;
}

.nav-item {
    margin-right: 15px;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: #0071c1;
}

.btn-primary {
    color: #fff;
    background-color: #1b6ec2;
    border-color: #1861ac;
}

.btn:focus,
.btn:focus-visible,
.btn:active:focus, 
.btn-link.nav-link:focus, 
.form-control:focus, 
.form-check-input:focus {
    /* Apply your purple glow with 50% opacity */
    box-shadow: 0 0 0 0.25rem rgba(111, 66, 193, 0.5);
    /* Ensure no default browser outline interferes */
    outline: 0;
}

.btn-purple {
    --bs-btn-color: #fff;
    --bs-btn-bg: #6f42c1;
    --bs-btn-border-color: #6f42c1;
    
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #5e37a6;
    --bs-btn-hover-border-color: #58349a;
    
    --bs-btn-focus-shadow-rgb: 137, 94, 207;

    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #58349a;
    --bs-btn-active-border-color: #53318f;

    --bs-btn-disabled-color: #fff;
    --bs-btn-disabled-bg: #6f42c1;
    --bs-btn-disabled-border-color: #6f42c1;

    outline: 2px solid #58349a;
}

.btn-purple:hover {
    outline: none;
}

.btn-purple:focus,
.btn-purple:focus-visible {
    outline: none !important;
}

.btn-purple:disabled,
.btn-purple.disabled {
    opacity: 0.65;
}

.content {
    padding-top: 1.1rem;
    flex-grow: 1;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgO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pbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

    .loading-progress circle {
        fill: none;
        stroke: #e0e0e0;
        stroke-width: 0.6rem;
        transform-origin: 50% 50%;
        transform: rotate(-90deg);
    }

        .loading-progress circle:last-child {
            stroke: #1b6ec2;
            stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
            transition: stroke-dasharray 0.05s ease-in-out;
        }

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

    .loading-progress-text:after {
        content: var(--blazor-load-percentage-text, "Loading");
    }

code {
    color: #c02d76;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

.blazored-modal-container {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--topbar-height);
    bottom: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1rem 2rem;
    z-index: 4000 !important; /* Ensure above fixed navbar */
}

.blazored-modal-overlay {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--topbar-height);
    bottom: 0;
    z-index: 3999 !important; /* Just under modal container */
}

@media (max-width: 640px) {
    .blazored-modal-container {
        padding: 2.5rem 0.5rem 1.5rem;
    }
}

.modal-content {
    border: none;
}

/* Textarea and general form control focus color */
.form-control:focus {
    border-color: #6f42c1; /* Keep your base purple border */
    /* Increase the opacity (last value) in rgba() for a stronger glow */
    box-shadow: 0 0 0 0.25rem rgba(111, 66, 193, 0.5); /* Now 50% opacity */
}

.modal-footer {
    border-top: none;
    display: block;
}

/* Form Switch - Checked State Background/Border */
.form-switch .form-check-input:checked {
    background-color: #6f42c1; /* Your base purple */
    border-color: #6f42c1; /* Your base purple */
    /* The white circle inside is usually handled by background-image, */
    /* which we don't need to override unless the color clashes */
}

/* Form Switch - Focus State (Consistent with Textarea) */
.form-switch .form-check-input:focus {
    /* Use the same focus border color as .form-control */
    border-color: #6f42c1;
    /* Use the same focus shadow as .form-control */
    box-shadow: 0 0 0 0.25rem rgba(111, 66, 193, 0.5);
    /* Ensure default track background image remains */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");
}

/* Form Switch - Checked + Focus State (Ensure background image for circle is correct) */
/* Might not be strictly necessary if :checked rule applies correctly, but can help ensure consistency */
.form-switch .form-check-input:checked:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e"); /* White circle */
}

/* Keep existing rules for .floor-layout-container, etc. */
.floor-layout-container {
    display: grid;
    grid-template-columns: auto 1fr auto; /* Col 1 | Col 2 (Grid) | Col 3 */
    grid-template-rows: auto 1fr auto;    /* Row 1 | Row 2 (Grid) | Row 3 */
    justify-items: center; /* Centers Top/Bottom controls horizontally in Col 2 */
    /* align-items: center; <-- Might vertically center Left/Right controls too much */
    gap: 1rem;
    /* ... */
}

.floor-controls-top { 
    grid-area: 1 / 2 / 2 / 3; 
    display: flex; 
    gap: 0.5rem; 
}

.floor-controls-left {
    grid-area: 2 / 1 / 3 / 2;
    align-self: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.floor-controls-right {
    grid-area: 2 / 3 / 3 / 4;
    align-self: center;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.floor-controls-bottom {
    grid-area: 3 / 2 / 4 / 3;
    display: flex;
    gap: 0.5rem;
}

.front-indicator-label {
    font-size: 0.8rem;
    font-style: italic;
}

.floor-grid-wrapper {
    grid-area: 2 / 2 / 3 / 3;    /* Placement in parent grid */
    width: 100%;                /* Take full width of grid cell */
    overflow: auto;             /* Add scrollbars BOTH ways if needed */
    align-self: stretch;        /* Stretch vertically within grid row (better than start) */
    -webkit-overflow-scrolling: touch; /* Smoother scrolling on iOS */
    padding: 3px;
}

div.active {
    outline: 2px solid #6f42c1; 
    outline-offset: 1px;
}

.navbar .nav-link.active-position {
    outline: 2px solid #6f42c1;
    outline-offset: 2px;
    color: #ffffff !important;
    border-radius: .25rem;
}

.navbar-nav .nav-item .nav-link {
    margin-left: 2px;
    margin-right: 2px;
}

.navbar-nav .nav-item.my-auto {
    align-self: center;
}

/* Optional: Style for the 'invisible space' feel */
/*
.floor-controls-top, .floor-controls-bottom, 
.floor-controls-left, .floor-controls-right {
    background-color: #f8f9fa; // Very light grey
    padding: 0.5rem;
    border-radius: 0.25rem;
}
*/

/* Add padding to main container to prevent overlap */
.page-container {
    padding-bottom: var(--bottom-panel-height); /* ADJUST TO MATCH PANEL HEIGHT */
}

/* Welcome modal responsive sizing */
.welcome-modal-dialog .modal-dialog {
    max-width: min(960px, 60vw);
    width: auto;
    margin: 0 auto calc(var(--bottom-panel-height) + 1rem);
}

.welcome-modal-dialog {
    padding: calc(var(--topbar-height) + 1rem) 0 calc(var(--bottom-panel-height) + 1rem);
}

.welcome-modal-dialog .modal-content {
    overflow-y: auto;
}

.welcome-modal {
    max-width: min(900px, 90vw);
    margin: 0 auto;
}

@media (min-width: 1200px) {
    .welcome-modal {
        max-width: 960px;
    }
}

@media (max-width: 992px) {
    .welcome-modal-dialog .modal-dialog {
        max-width: min(900px, 85vw);
    }
}

@media (max-width: 640px) {
    .welcome-modal-dialog .modal-dialog {
        max-width: 95vw;
    }

    .welcome-modal-dialog .modal-content {
        max-height: calc(100vh - 1.5rem);
    }
}

/* Simple Fixed Bottom Panel */
.gymnast-bottom-panel-simple {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1020;
    height: 110px;
    overflow: hidden; /* Hide vertical overflow */
    -webkit-overflow-scrolling: touch; /* iOS momentum scrolling */
}

/* When any modal is open, hide the fixed bottom bar to guarantee space for modal actions */
body.modal-open .gymnast-bottom-panel-simple {
    display: none !important;
}

body.blazored-modal-open .gymnast-bottom-panel-simple {
    display: none !important;
}

.gymnast-bottom-panel-simple .gymnast-scroll-container {
    overflow-y: auto; /* Primarily for when expanded later */
    /* Adjust 35px based on actual measured height of the H6 + its padding/borders */
    height: calc(100% - 35px);
    -webkit-overflow-scrolling: touch;
}

.delete-mode-active .gymnast-component:hover {
    outline: 2px dashed red; /* Example hover effect in delete mode */
    outline-offset: 1px;
}

/* Target the container Blazored Toast creates */
.blazored-toast-container {
    /* Set z-index higher than fixed navbar (default 1030) */
    /* But lower than modals (default 1050+) if toasts shouldn't cover modals */
    z-index: 1040 !important; /* Use !important to ensure override */
}

/* Drag & Drop highlights */
.gymnast-component.dropzone-cell.drop-target {
    /* Use inset box-shadow instead of outline to avoid clipping issues */
    box-shadow: inset 0 0 0 3px #6f42c1;
    background: rgba(111, 66, 193, 0.08);
    transition: background 120ms ease, box-shadow 120ms ease;
}

.gymnast-component.draggable,
.gymnast-component.draggable * {
    touch-action: none; /* Important for mobile devices to allow drag */
    user-select: none;
    cursor: move;        /* Fallback for environments without grab cursors */
    cursor: -webkit-grab; /* Safari */
    cursor: -moz-grab;    /* Old Firefox */
    cursor: grab;
    transition: transform 120ms ease, box-shadow 120ms ease, outline-color 120ms ease;
}

.gymnast-component.draggable:active,
.gymnast-component.draggable:active * {
    cursor: move;             /* Fallback */
    cursor: -webkit-grabbing; /* Safari */
    cursor: -moz-grabbing;    /* Old Firefox */
    cursor: grabbing;
}

/* While dragging, prevent page scrollbars to avoid the right-side scrollbar flash */
/* During drag, hide page scrollbars but DO NOT hide overflow on all descendants (that clips borders/outlines) */
body.dragging-active {
    overflow: hidden;
    cursor: move !important;             /* Fallback */
    cursor: -webkit-grabbing !important; /* Ensure grabbing hand during drag */
    cursor: -moz-grabbing !important;
    cursor: grabbing !important;
}
body.dragging-active * {
    cursor: move !important;             /* Fallback */
    cursor: -webkit-grabbing !important; /* Ensure grabbing hand during drag */
    cursor: -moz-grabbing !important;
    cursor: grabbing !important;
}

/* Optional: enhance visibility of the drag ghost (most is inline-styled in JS) */
.drag-ghost {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    border-radius: .25rem;
    border: 2px solid rgba(111, 66, 193, 0.5);
}

/* While dragging, hide scrollbars on key scroll containers (keep scrolling enabled) */
body.dragging-active .floor-grid-wrapper {
    -ms-overflow-style: none; /* IE/Edge */
    scrollbar-width: none;    /* Firefox */
}
body.dragging-active .floor-grid-wrapper::-webkit-scrollbar {
    display: none;            /* Chrome/Safari/Edge */
}

body.dragging-active .gymnast-bottom-panel-simple .gymnast-scroll-container {
    -ms-overflow-style: none; /* IE/Edge */
    scrollbar-width: none;    /* Firefox */
}
body.dragging-active .gymnast-bottom-panel-simple .gymnast-scroll-container::-webkit-scrollbar {
    display: none;            /* Chrome/Safari/Edge */
}

/* Visual feedback on the source element while dragging (desktop mainly) */
body.dragging-active .gymnast-component.dragging-source {
    opacity: 0.6 !important;
    /* Use inset box-shadow on the container so the inner text doesn't get an outline */
    box-shadow: inset 0 0 0 2px #6f42c1;
    cursor: -webkit-grabbing !important; /* Force grabbing over body cursor */
    cursor: -moz-grabbing !important;
    cursor: grabbing !important;
}
/* Ensure no child inside the source gets an outline */
body.dragging-active .gymnast-component.dragging-source * {
    outline: none !important;
}

/* Highlight the list as a valid drop return target */
#gymnast-list-dropzone.drop-target {
    /* Inset box-shadow avoids being cut off by parent overflow */
    box-shadow: inset 0 0 0 2px #6f42c1;
}

/* Cursor and ghost feedback for allowed vs not-allowed drop */
/* Keep cursor uniform as grabbing; we use ghost color to indicate allowed/not-allowed */
body.dragging-active.drop-allowed .drag-ghost {
    border-color: #198754; /* bootstrap success green */
    box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.25), 0 4px 12px rgba(0, 0, 0, 0.25);
}
body.dragging-active:not(.drop-allowed) .drag-ghost {
    border-color: #dc3545; /* bootstrap danger red */
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.25), 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* --- AddGymnasts Modal: Keep buttons visible on very small screens --- */
.add-gymnasts-modal {
    display: flex;
    flex-direction: column;
    /* Primary: runtime viewport height variable (robust on iOS Chrome/Safari) */
    max-height: calc(var(--app-vh, 1vh) * 100 - 2rem);
}

/* Prefer small-viewport units when available, then dynamic viewport, then fallback */
@supports (max-height: 100svh) {
    .add-gymnasts-modal { max-height: calc(100svh - 2rem); }
}
@supports (max-height: 100dvh) {
    .add-gymnasts-modal { max-height: calc(100dvh - 2rem); }
}

.add-gymnasts-modal .modal-body {
    /* Body should take remaining space and scroll internally */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Reserve space for sticky footer (approx button height) plus safe-area */
    padding-bottom: calc(120px + env(safe-area-inset-bottom));
}

.add-gymnasts-modal .modal-sticky-footer {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: .5rem .25rem calc(.85rem + env(safe-area-inset-bottom)) .25rem;
    border-top: 1px solid rgba(0,0,0,.1);
    z-index: 3000; /* sit above any app-fixed bars */
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.add-gymnasts-modal .gymnasts-textarea {
    min-height: 120px;
    /* Avoid iOS zoom/overflow oddities */
    -webkit-touch-callout: default;
}

@media (max-width: 420px) {
    .add-gymnasts-modal .gymnasts-textarea {
        max-height: 120px; /* allow body to scroll rather than push buttons off screen */
    }
    .add-gymnasts-modal .help-section {
        margin-bottom: 0.5rem !important;
    }
    .add-gymnasts-modal .help-section img {
        max-height: 120px;
        width: auto;
    }
    .add-gymnasts-modal .modal-sticky-footer .btn {
        flex: 1 1 auto;
    }
}

/* Further compress for short viewports regardless of width */
@media (max-height: 740px) {
    .add-gymnasts-modal .gymnasts-textarea { max-height: 100px; }
    .add-gymnasts-modal .help-section img { display: none; }
    .add-gymnasts-modal .modal-body { padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
}

/* Trash dropzone: only visible while dragging */
.trash-dropzone {
    position: fixed;
    top: 72px;              /* below the top navbar */
    right: 16px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(220, 53, 69, 0.08); /* danger red tint */
    border: 3px solid #dc3545;
    color: #dc3545;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    z-index: 1065; /* above bottom panel (1020), toasts (1040), and most UI */
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 120ms ease, transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
    pointer-events: none; /* avoid blocking UI when hidden */
}

body.dragging-active .trash-dropzone {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.trash-dropzone .oi-trash { font-size: 1.25rem; }

.trash-dropzone.drop-target {
    box-shadow: 0 0 0 6px rgba(220, 53, 69, 0.15);
    background: rgba(220, 53, 69, 0.15);
}

/* When over trash, force ghost to danger red to signal destructive action */
body.dragging-active.over-trash .drag-ghost {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.28), 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}