/* Inline row for fixtures Opponents/Course/Add Course */
.tpw-inline-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.tpw-inline-row .tpw-field input[type="text"],
.tpw-inline-row .tpw-field select {
    width: 100%;
}
/* Visually hidden but accessible label */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
@media (max-width: 700px) {
    .tpw-inline-row {
        flex-direction: column;
        align-items: stretch;
    }
}
.test {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    padding: 10px;
    margin-bottom: 20px;
}

/* Show If builder UI improvements */
.tpw-admin-form-container .tpw-spfx-cond-wrap select,
.tpw-admin-form-container .tpw-showif-row select,
.tpw-admin-form-container .tpw-showif-group select {
    -webkit-appearance: menulist;
    appearance: auto;
    background-color: #ffffff;
    color: #1d2327;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 3px 8px;
    height: 32px;
    line-height: 24px;
    min-width: 140px;
}

.tpw-admin-form-container .tpw-showif-row input[type="text"] {
    background-color: #ffffff;
    color: #1d2327;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 4px 8px;
    height: 32px;
    line-height: 24px;
    min-width: 160px;
}

.tpw-admin-form-container .tpw-showif-row label,
.tpw-admin-form-container .tpw-showif-group label {
    font-weight: 500;
    color: #333;
}

/* Ensure buttons align nicely within the row */
.tpw-admin-form-container .tpw-showif-row .button.button-small {
    height: 30px;
    line-height: 28px;
}

/* Center Remove button text vertically in condition rows */
.tpw-admin-form-container .tpw-showif-box [data-tpw-row-remove] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    line-height: 1;
    padding: 0 10px;
}

/* Boxed layout for each condition row */
.tpw-admin-form-container .tpw-showif-box {
    border: 1px solid #e6e6e6;
    background: #fff;
    border-radius: 6px;
    padding: 12px 12px 12px 12px;
    margin: 10px 0;
}
.tpw-admin-form-container .tpw-showif-box .tpw-field label { font-weight: 600; }
.tpw-admin-form-container .tpw-showif-box select,
.tpw-admin-form-container .tpw-showif-box input[type="text"] {
    width: 100%;
    box-sizing: border-box;
}

/* Generic admin form row: align fields on the same line */
.tpw-admin-form-container .tpw-field-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap; /* allow wrap on small screens */
}
.tpw-admin-form-container .tpw-field-row > .tpw-field {
    flex: 1 1 0;
}

/* Members Clubs UI */
.tpw-member-clubs-field { margin-top: 12px; }
.tpw-member-clubs-list { margin-top: 8px; }
.tpw-member-clubs-list .tpw-club-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
}
.tpw-member-clubs-list .tpw-drag-handle {
    font-size: 18px; /* bigger icon */
    line-height: 1;
    cursor: grab; /* hand/grab cursor */
    user-select: none;
}
.tpw-member-clubs-list .tpw-club-row label { display: flex; align-items: center; gap: 12px; margin: 0; flex: 1 1 auto; }
.tpw-member-clubs-list .tpw-priority-badge { font-weight: 600; white-space: nowrap; min-width: 130px; display: inline-block; }
.tpw-member-clubs-list .tpw-priority-badge.is-home {
    color: #005ae0;
}
.tpw-member-clubs-list select { min-width: 260px; }
.tpw-member-clubs-list .tpw-remove-club-row.button-link-delete {
    margin-left: 8px;
}
/* Space between last row and Add Another Club button */
.tpw-member-clubs-field .tpw-add-club-row { margin-top: 10px; }

/* Manage Courses: Actions cell buttons should match size and have spacing */
#tpw-manage-courses .table-container .table-row .table-cell:last-child {
    display: flex;
    align-items: center;
    gap: 8px; /* space between Edit/Delete */
}
#tpw-manage-courses .table-container .table-row .table-cell:last-child form {
    display: flex; /* ensure form participates in flex gap */
    margin: 0;
}
#tpw-manage-courses .table-container .table-row .table-cell:last-child .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    line-height: 1; /* vertical center */
    padding: 0 12px;
    font-size: 13px;
    border-radius: 4px;
}

/* Manage Courses: Import bar buttons should be same height */
#tpw-manage-courses .tpw-import .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    line-height: 1;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 4px;
}

/* Manage Courses: improve mobile cards */
@media (max-width: 700px) {
    #tpw-manage-courses .table-container .table-head { display: none; }
    #tpw-manage-courses .table-container .table-row {
        display: block;
        background: #fff;
        border: 1px solid #e5e5e5;
        border-radius: 8px;
        padding: 12px;
        margin-bottom: 12px;
    }
    #tpw-manage-courses .table-container .table-row .table-cell {
        display: block;
        padding: 2px 0;
    }
    #tpw-manage-courses .table-container .table-row .table-cell:last-child {
        margin-top: 8px;
        justify-content: flex-start;
    }
    #tpw-manage-courses .table-container .table-row .table-cell:last-child form { flex: 0 0 auto; }
    #tpw-manage-courses .table-container .table-row .table-cell:last-child .button {
        flex: 0 0 auto; /* do not stretch to full width */
        min-width: 120px; /* touch-friendly size without full stretch */
    }
}

/* Manage Courses: pagination styles */
#tpw-manage-courses .tpw-pagination .tpw-page-btn,
#tpw-manage-courses .tpw-pagination .tpw-page-btn:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #999999; /* tpw pink/red */
    border-radius: 6px;
    color: #999999;
    text-decoration: none;
    background: #fff;
    font-weight: 600;
}
#tpw-manage-courses .tpw-pagination .tpw-page-btn.is-active {
    background: #999999;
    color: #fff;
}
#tpw-manage-courses .tpw-pagination .tpw-page-btn.is-disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}
#tpw-manage-courses .tpw-pagination .tpw-page-ellipsis { display: inline-flex; align-items:center; padding: 0 4px; color:#999; }

/* Global pagination styles (fixtures list, match results, etc.) */
.tpw-pagination .tpw-page-btn,
.tpw-pagination .tpw-page-btn:visited {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #999999;
    border-radius: 6px;
    color: #999999;
    text-decoration: none;
    background: #fff;
    font-weight: 600;
}
.tpw-pagination .tpw-page-btn.is-active {
    background: #999999;
    color: #fff;
}
.tpw-pagination .tpw-page-btn.is-disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}
.tpw-pagination .tpw-page-ellipsis {
    display: inline-flex;
    align-items: center;
    padding: 0 4px;
    color: #999;
}

/* ==============================
   Front-end tables (Match Results, Stats, Member's Golf)
   Div-based grid tables (accessible roles)
   ============================== */

/* Shared grid table tokens */
.tpw-grid-table .table-head,
.tpw-grid-table .table-row {
    align-items: start;
}

.tpw-grid-table .table-row:not(.table-head) { background-color: #ffffff; }

.tpw-grid-table .table-cell {
    padding: 10px 12px;
    line-height: 1.5;
    vertical-align: top;
}

.tpw-grid-table .table-head .table-cell { white-space: nowrap; }

/* Helper: center-align numeric/yes-no columns */
.tpw-grid-table .is-yesno { text-align: center; white-space: nowrap; }

/* Parent row visual for grouped stats */
.tpw-grid-table .table-row.is-parent { background: #f6f7f8; }

/* Hover feedback for regular rows (exclude parent/group/past states) */
.tpw-grid-table .table-row:hover:not(.table-head):not(.is-parent):not(.tpw-parent-group):not(.tpw-parent-group-child):not(.is-past) {
    background-color: #f0f4f8;
    transition: background-color 0.15s ease-in-out;
}

/* Match Results grid: Date, [Fixture Name?], Opponents, Course, Result, Score */
.tpw-results-grid .table-head,
.tpw-results-grid .table-row { display: grid; grid-template-columns: 14% 28% 28% 16% 12%; }
.tpw-results-grid.has-fixture-name .table-head,
.tpw-results-grid.has-fixture-name .table-row { grid-template-columns: 12% 20% 24% 24% 12% 8%; }

/* Match Stats grid */
.tpw-stats-grid .table-head,
.tpw-stats-grid .table-row { display: grid; grid-template-columns: 12% 24% 12% 20% 8% 8% 8% 8%; }
.tpw-stats-grid.has-fixture-name .table-head,
.tpw-stats-grid.has-fixture-name .table-row { grid-template-columns: 10% 16% 20% 10% 18% 6.5% 6.5% 6.5% 6.5%; }

/* Member's Golf grid */
.tpw-members-golf-grid .table-head,
.tpw-members-golf-grid .table-row { display: grid; grid-template-columns: 12% 30% 18% 8% 8% 8% 8% 8%; }

/* Responsive stacking for grid tables */
@media (max-width: 768px) {
    .tpw-grid-table { font-size: 0.9rem; }
    .tpw-grid-table .table-head { display: none; }
    .tpw-grid-table .table-row { display: block; }
    .tpw-grid-table .table-row .table-cell {
        display: grid;
        grid-template-columns: 140px 1fr;
        gap: 4px 10px;
        padding: 8px 10px;
    }
    .tpw-grid-table .table-row .table-cell::before {
        content: attr(data-label);
        font-weight: 600;
        white-space: nowrap;
        color: #333;
    }
}