
/* ==========================================================================
   ID Specific other elements
   ========================================================================== */

#terms {
    position: absolute;
    top: 20px; /* Adjusted for larger padding */
    right: 30px;
    color: #bbc0d9; /* Muted color from your palette */
    font-size: 0.60vw;
    text-transform: uppercase;
    letter-spacing: 0.05vw;
    cursor: pointer;
    background: none;
    border: none;
}

#terms:hover {
    color: var(--brand-blue-hover);    /* Your brand purple */
    text-decoration: underline;
}


/* ==========================================================================
   Main Containers
   ========================================================================== */


#analysis-container {
    /* 1. Layout & Sizing */
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-height: 0;         /* Crucial: allows children to shrink and scroll */
    box-sizing: border-box; /* Crucial: includes padding in the 100vh height */

    /* 2. Visuals */
    background-color: var(--bg-main); /* Using your variable #F2F2F2 */
    padding: 10px;
    position: relative;

    /* 3. Containment */
    overflow: hidden;      /* Prevents this container from scrolling so the card can */
}

/* Floating Card for Content */
.analysis-content {
    /*flex-grow: 1;*/
    flex: 1 1 auto;
    background-color: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    min-height: 0;
    box-sizing: border-box;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px !important; /* Increased gap between major sections */
    scrollbar-gutter: stable; /* Reserves space for the scrollbar so content doesn't shift */
    /*outline: 3px solid red;*/
}

/* Ensure that when the tab is active, it uses flex to layout children */
.analysis-content.active,
.analysis-content[style*="display: block"] {
    display: flex !important;
    flex-direction: column !important; /* Forces stacking */
    justify-content: flex-start !important; /* Starts content at the top */
    align-items: stretch !important; /* Ensures children take full width */

    /* Ensure scrolling logic carries over to the active state */
    min-height: 0 !important;
    overflow-y: auto !important;
}

/* Custom Scrollbar Refinement */
.analysis-content::-webkit-scrollbar {
    width: 12px; /* Slightly wider to accommodate the 'floating' border */
}

.analysis-content::-webkit-scrollbar-track {
    background: transparent;
    margin: 15px 0; /* Keeps the scrollbar away from the rounded card corners */
}

.analysis-content::-webkit-scrollbar-thumb {
    background-color: #e0e0e0;
    border-radius: 20px;
    /* This creates the 'floating' effect by matching the card background */
    border: 4px solid #ffffff;
}

.analysis-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--brand-blue); /* Visual feedback on hover */
}



/* ==========================================================================
   Generic elements
   ========================================================================== */

.phase-container {
    background-color: var(--bg-light-grey); /* Lighter, cleaner grey */
    width: calc(100% - 24px);
    margin: 10px auto;
    border-radius: 12px; /* Softer corners */
    padding: 5px;
    border: 1px solid #eef0f2;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); /* Very subtle depth */
}

.phase-container > .header {
    height: auto;
    background-color: transparent; /* Remove the dark bar */
    color: var(--brand-blue); /* Use primary colour */
    padding: 0 0 10px 5px;
    border-bottom: 2px solid var(--brand-blue); /* Underline accent */
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05vw;
}

/* Ensure form headers also use the primary blue */
.phase-container > .header h3 {
    color: var(--brand-blue);
    margin: 0;
}

.metric {
    background-color: var(--bg-card);
    padding: 8px 12px;
    margin: 8px 0;
    border-radius: 10px;
    border: 1px solid var(--border-grey);
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: flex-start;
    min-height: 44px;
    box-sizing: border-box;
    gap: 12px;
    transition: all 0.2s ease-in-out; /* Slightly faster for better 'snap' */
}

.metric:hover {
    transform: translateY(-1px);
    /* Soft blue glow in the shadow, but the border remains uniform */
    box-shadow: 0 4px 12px rgba(74, 162, 217, 0.15);
    border-color: var(--brand-blue); /* Uniform highlight around the whole card */
}

/* Ensure indicators (keyframes/eyes) don't shrink when text is long */
.metric-buttons, .metric-set-keyFrame {
    flex-shrink: 0;
}

.metric-content {
    flex: 1;
    text-align: left;
}

.metric-content h5 {
    color: var(--brand-blue);
    font-size: 0.70vw;
    margin: 0 0 4px 0;
    font-weight: 600;
}

.metric-content p {
    color: #555;
    font-size: 0.65vw;
    font-weight: normal;
    line-height: 1.3;
    margin: 0;
}

/* Darken the text when the parent metric card is hovered */
/*.metric:hover .metric-content h5 {
    color: #004085;
}*/

.metric:hover .metric-content p {
    color: #222; /* Darkened from #555 to a near-black for better contrast */
}

.keyframe-indicator {
    flex: 0 0 26px;
    width: 26px !important;
    height: 26px !important;
    align-self: flex-start;     /* Anchor to the top so it doesn't move with text */
    background-image: url("/images/icons/eyeGrey.png");
    background-repeat: no-repeat !important;
    background-size: contain !important;
    background-position: center;
    margin-top: 2px;
}

.warning-indicator {
    flex: 0 0 26px;
    width: 26px !important;
    height: 26px !important;
    align-self: flex-start;     /* Anchor to the top so it doesn't move with text */
    background-repeat: no-repeat !important;
    background-size: contain !important;
    background-position: center;
    margin-top: 2px;
}

.risk{
    background-image: url("/images/icons/grey-warning.png");
}

.speed{
    background-image: url("/images/icons/grey-speed.png");
}

.metric:hover .speed{
    background-image: url("/images/icons/speed-select.png");
}

.metric:hover .risk{
    background-image: url("/images/icons/grey-warning-select.png");
}

.metric:hover .keyframe-indicator{
    background-image: url("/images/icons/eyeGreySelect.png");
}

/* ==========================================================================
   Overview Specific
   ========================================================================== */

.tab {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border: none;
}

.tab button {
    border: none !important;
    background-color: transparent;
    color: var(--brand-grey);
    transition: all 0.3s ease-in-out;
    font-size: 0.60vw;
}

.tab button:hover {
    background-color: rgba(74, 162, 217, 0.1); /* Soft Sky Blue wash */
    color: var(--brand-blue);
}

.tab button.active {
    background-color: var(--brand-blue); /* Your Primary Blue */
    color: white !important;
    box-shadow: 0 4px 12px rgba(74, 162, 217, 0.35); /* Glow matching your blue */
}

/* ==========================================================================
   Analysis Specific
   ========================================================================== */

/* 2. Top information bar */

.info-content {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 10px;
    width: 100%;
    padding: 5px; /* Prevents border-glow from clipping */
}

.feed-element {
    width: 130px;
    height: 70px;
    border: 2px solid var(--brand-blue);
    border-radius: 12px;
    display: flex;
    flex-direction: row;
    background-color: var(--bg-card);
    overflow: hidden;
    transition: transform 0.2s ease;
}

.feed-element:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(74, 162, 217, 0.15);
}

.feed-value-container{
    font-size: 32px;
    color: var(--brand-blue);
    height: 100%;
    width: 64px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.feed-value{
    font-size: 32px;
    height: 36px;
}

.feed-unit{
    font-size: 12px;
}

.meta-icon{
    background-size: cover;
    width: 64px;
    height: 64px;
}

#speed-icon{
    background-image: url("/images/icons/speed.png");
}

#swing-icon{
    background-image: url("/images/icons/swing.png");
}
.flip{
    -webkit-transform: scaleX(-1);
    transform: scaleX(-1);
}

#pitch-length-icon{
    background-image: url("/images/icons/length.png");
}

#equiv-speed-icon{
    background-image: url("/images/icons/equivSpeed.png");
}

#run-up-icon{
    background-image: url("/images/icons/run-up.png");
}

/* Containers for vertically stacked elements */

.analysis-sections {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 25px !important;
    align-items: flex-start;
    padding-bottom: 30px; /* Space at the very bottom so scroll within bounds */
}

.analysis-section {
    width: 100%;           /* Full width of the card */
    margin-bottom: 30px;
    border: none;          /* Remove the old #ddd border */
    text-align: left;      /* Align headers to the left to match Overview */
}

.analysis-section-header {
    width: 100%;
    padding: 8px 0;
    background-color: transparent;
    color: var(--brand-blue); /* Primary Blue Text */
    font-size: 0.8vw;
    font-weight: 700;
    border-bottom: 2px solid var(--brand-blue);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.05vw;
}

/*  Batting Analysis */

/* Fix for the thumbnails container */
.shots-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;             /* Space between thumbnails */
    padding: 5px 0;
}

.shots-container:empty::before {
    content: "No shots identified for this video. Click 'Add New Shot' to begin.";
    display: block;
    width: 100%;
    padding: 40px;
    text-align: center;
    color: var(--brand-grey);
    border: 2px dashed var(--border-grey);
    border-radius: 12px;
    grid-column: 1 / -1; /* spans across if using grid */
}

.shot-container {
    width: 135px;
    height: 240px;         /* Adjusted aspect ratio */
    background: no-repeat center var(--bg-card);
    background-size: contain;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-grey);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
    position: relative;
}


.shot-container:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
    z-index: 10;
}

.shot-frame{
    width: calc(100% - 4px);
    margin: 8px;
    text-align: center;
    cursor: pointer;
    background-color: var(--bg-light-grey);
    outline: 4px white solid;
}
.shot-frame:hover{
    filter: brightness(105%);
}

.shot-header {
    background-color: rgba(0, 0, 0, 0.4); /* Slightly darker for better contrast */
    color: white;
    font-size: 0.6vw;
    font-weight: 600;

    /* Layout: Center text vertically and horizontally */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;

    /* Spacing: Use padding instead of fixed height */
    padding: 6px 4px;
    min-height: 28px; /* Ensures consistency for 1-liners */
    box-sizing: border-box;

    /* Positioning */
    position: absolute;
    bottom: 0;
    width: 100%;

    /* Typography */
    line-height: 1.2;
    white-space: normal; /* Allows wrapping */
    word-wrap: break-word;
}



/* Bowling Analysis */

/* Ensure Bowling containers look identical to Shot containers */
.bowl-analysis-container {
    width: 135px;
    height: 200px;           /* Matching the condensed Batting height */
    background-color: var(--bg-card);
    border-radius: 8px;
    border: 1px solid #eee;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease-in-out;
}

.bowl-analysis-container:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
    border-color: #4AA2D9;
}

/* Ensure the header (label) sits at the bottom like the shots */
.bowl-analysis-container .shot-header {
    background-color: rgba(0, 0, 0, 0.6);
    color: var(--bg-card);
    font-size: 0.6vw;
    padding: 6px;
    text-align: center;
    position: absolute;
    bottom: 0;
    width: 100%;
    order: 2; /* Ensures it stays below the canvas/content */
}

/* Remove default borders from the bowling specific containers */
.bowl-analysis-container canvas {
    width: 100% !important;
    height: auto !important;
    order: 1;
}



/* ==========================================================================
   Edit Overview - Styles that apply only within edit page
   ========================================================================== */

#edit-assessment .metric {
    flex-direction: column; /* Stack label above input for the coach */
    align-items: stretch;
    padding: 18px;
    gap: 12px;
    background-color: var(--bg-card);
    border-left: 4px solid var(--border-grey); /* Subtle accent */
}

#edit-assessment .metric:hover {
    border-left-color: var(--brand-blue);
}

/* Specific layout for the Header within the Edit card */
#edit-assessment .metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Styling the 'Set Frame' button to look like a tool, not a main action */
#edit-assessment .metric-header {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 12px; /* Consistent spacing between Switch and Title */
    margin-bottom: 10px;
}

#edit-assessment .metric-header h4 {
    margin: 0;
    flex-grow: 1; /* This pushes the metric-buttons to the far right */
    text-align: left; /* Standard left alignment */
    font-size: 1.0rem;
    color: var(--brand-grey);
}

/* Position the Slider in the Left Slot */
#edit-assessment .switch {
    grid-column: 1;
    justify-self: start;
}

/* Position the Set Frame buttons in the Right Slot */
#edit-assessment .metric-buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto; /* Safety anchor to keep buttons on the right */
}

/* Container for the options */
.radio-options-container {
    padding-top: 12px;
    margin-left: 20px; /* Aligns under the title, skipping the switch */
    display: flex;
    flex-direction: column; /* Forces vertical stack */
    gap: 12px; /* Spacing between vertical items */
}

/* Individual option as a vertical list item */
.optionSelect {
    display: block;
    width: fit-content;
    cursor: pointer;
    padding: 8px 18px;
    background-color: var(--bg-light-grey);
    border: 1px solid var(--border-grey);
    border-radius: 8px;
    font-size: 0.85em;
    transition: all 0.2s ease;
    color: var(--brand-grey);
    /* Defensive margin in case flex gap isn't supported in older browsers */
    margin-bottom: 2px;
}

/* The Bullet Point */
.optionSelect::before {
    content: "•";
    color: var(--brand-blue);
    font-weight: bold;
    display: inline-block;
    width: 1.4em;
}

.optionSelect:hover {
    background-color: var(--brand-blue);
    color: white;
    border-color: var(--brand-blue);
    transform: translateX(4px); /* Subtle nudge to indicate selection */
}

.optionSelect:hover::before {
    color: white;
}

.publishButton {
    background-color: var(--brand-blue);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.8vw;
    border: none;
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    box-shadow: 0 4px 15px rgba(74, 162, 217, 0.3);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.publishButton:hover {
    background-color: var(--brand-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 162, 217, 0.4);
}

/* Spinner Animation */
.loading-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

.btn-analyse.loading {
    cursor: wait;
    opacity: 0.7;
}


/* TEST */

/* Meta info grid */
.control-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.input-group label {
    display: block;
    font-weight: bold;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #555;
}

.input-group select, .input-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-grey);
    border-radius: 4px;
}

/* Keyframe Rows */



.keyframe-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.column-label {
    width: 150px;
    font-weight: 600;
    font-size: 0.9rem;
}

.action-cluster {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap; /* Add this */
}

.capture-unit {
    display: flex;
    align-items: center;
    justify-content: flex-start; /* Forces content to the left */
    gap: 10px;
    min-width: 250px; /* Ensures the row doesn't shrink when buttons are hidden */
    flex: 1;
}

/* Buttons */
.btn-capture {
    background: var(--brand-blue);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.status-check {
    display: none; /* Hide until setKeyframe runs */
}

.btn-analyse {
    /* Ensure it has some visual weight so you can see it when it appears */
    background-color: #28a745;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 5px;
}

.stepper-group {
    display: flex;
    gap: 2px;
    align-items: center;
}

.stepper-group button {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: #495057;
    transition: all 0.2s;
}

.stepper-group button:hover {
    background: #f8f9fa;
    border-color: #007bff;
    color: #007bff;
}

.stepper-group button:active {
    background-color: #e9ecef;
    transform: translateY(1px);
}

.footer-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}


/* 1. Hide non-active sections when editing */
#edit-keyframe-elements.focus-active .keyframe-column {
    display: none;
}

/* 2. Show only the active column and reset its layout */
#edit-keyframe-elements.focus-active .keyframe-column.active-editing {
    display: block !important;
    width: 100%;
    background: #fdfdfd;
    border: 1px solid #007bff;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Mirroring the exact structure provided */
.meta-header {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    margin-bottom: 0;
}

/* Match the exact spacing of the static Technical Info block */
.meta-header .header h3 {
    color: var(--brand-blue); /* Or your preferred header color */
    margin-bottom: 5px;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-value {
    color: var(--brand-grey);
    font-size: 0.70vw;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 0.02vw;
    opacity: 0.7;
    text-transform: uppercase;
    font-weight: 700;
}

/* Admin data edit */

/* Container Depth */
.category-card { border: 1px solid #d1d8e0; background: #fff; margin-bottom: 25px; }
.assessment-card { background: #f8fafc; border: 1px solid #e2e8f0; }
.phase-card { background: #f1f5f9; border: 1px solid #cbd5e1; }

/* Metric Elevation */
/* Metric Elevation - Fixed with gutter for controls */
.metric-card {
    background: #ffffff !important;
    border: 1px solid #cbd5e1;
    border-left: 4px solid var(--primary);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin: 10px 0 10px 40px;
    padding: 35px 15px 15px 15px; /* Increased top padding from 15px to 35px */
    border-radius: 6px;
    position: relative;
}
.category-card .header-actions:hover {
    background-color: #fcfcfc;
}

/* Smaller, discrete buttons */
.btn {
    padding: 4px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.75rem; /* Smaller text */
    transition: all 0.2s;
    margin-right: 4px;
    display: inline-flex;
    align-items: center;
}

.btn-add {
    background: #ecf0f1;
    color: var(--success);
    border: 1px solid #dcdcdc;
}

.btn-del {
    background: transparent;
    color: #999;
    border: 1px solid transparent;
}

.btn-del:hover {
    color: var(--danger);
    border-color: #fadbd8;
    background: #fdf2f2;
}

/* Keep the Save button prominent but refined */
.btn-save {
    background: var(--primary);
    color: white;
    padding: 8px 20px;
    font-size: 0.85rem;
}

.btn:hover { opacity: 0.9; transform: translateY(-1px); }

/* Badge stays top-right */
.metric-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #edf2f7;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.65rem;
    color: #4a5568;
    font-weight: bold;
}

/* Controls stay top-right, but pushed left of the badge */
.reorder-controls {
    position: absolute;
    right: 60px; /* Pushed further left to avoid badge */
    top: 6px;
    display: flex;
    gap: 8px;
}

.btn-reorder {
    background: #f8fafc;
    border: 1px solid var(--border) !important;
    color: var(--text-muted);
    padding: 2px 8px !important;
    min-width: 20px;
    line-height: 1;
    height: 20px;
}

.btn-reorder:hover {
    background: var(--accent) !important;
    color: white !important;
    border-color: var(--accent) !important;
}