/* ============================================================================
   ttbp-pos-profile.css — Player Profile Panel
   Requires: ttbp-tokens.css (loaded first for design-token variables)
   ============================================================================ */

/* ── Backdrop ──────────────────────────────────────────────────────────────── */
.ttbp_profile_backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .52); /* overlay black */
    z-index: 1000010;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--ttbp-sp-4);
    box-sizing: border-box;
}

/* Prevent body scroll when panel is open */
body.ttbp-profile-open {
    overflow: hidden;
}

/* ── Centered panel ─────────────────────────────────────────────────────────── */
.ttbp_profile_panel {
    background: var(--ttbp-white);
    width: 420px;
    max-width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--ttbp-shadow-xl);
    border-radius: var(--ttbp-radius-xl);
    display: flex;
    flex-direction: column;
    animation: ttbp_profile_pop_in .2s ease;
}

@keyframes ttbp_profile_pop_in {
    from { transform: scale(.95); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.ttbp_profile_hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px var(--ttbp-sp-4);
    background: var(--ttbp-primary-dark);
    color: var(--ttbp-white);
    flex-shrink: 0;
}

.ttbp_profile_hdr_left {
    display: flex;
    align-items: center;
    gap: var(--ttbp-sp-2);
    font-weight: var(--ttbp-fw-bold);
    font-size: var(--ttbp-fs-base);
    letter-spacing: .03em;
    text-transform: uppercase;
}

.ttbp_profile_hdr_right {
    display: flex;
    align-items: center;
    gap: var(--ttbp-radius);
}


.ttbp_profile_close_btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.8); /* white with opacity */
    font-size: var(--ttbp-fs-xl);
    cursor: pointer;
    padding: 2px var(--ttbp-radius);
    border-radius: var(--ttbp-radius-sm);
    line-height: 1;
    transition: color .15s;
}
.ttbp_profile_close_btn:hover { color: var(--ttbp-white); }

/* ── Loading ───────────────────────────────────────────────────────────────── */
.ttbp_profile_loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: var(--ttbp-sp-8) var(--ttbp-sp-5);
    color: var(--ttbp-gray-500);
    font-size: var(--ttbp-fs-base);
}

/* ── Error ─────────────────────────────────────────────────────────────────── */
.ttbp_profile_error {
    padding: var(--ttbp-sp-5);
    color: var(--ttbp-danger);
    font-size: 13px;
    background: var(--ttbp-danger-light);
    margin: var(--ttbp-sp-3);
    border-radius: var(--ttbp-radius-lg);
    border: 1px solid #fecaca;
}

/* ── Identity block ────────────────────────────────────────────────────────── */
.ttbp_profile_identity {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px var(--ttbp-sp-4) var(--ttbp-sp-3);
    border-bottom: 1px solid var(--ttbp-gray-100);
}

.ttbp_profile_avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #d1fae5;
    color: var(--ttbp-primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

/* Edit pencil button — right side of identity row */
.ttbp_profile_edit_pencil {
    margin-left: auto;
    background: none;
    border: 1px solid var(--ttbp-gray-300);
    border-radius: var(--ttbp-radius);
    padding: var(--ttbp-radius) 9px;
    font-size: 15px;
    color: var(--ttbp-gray-500);
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
    transition: color .15s, border-color .15s, background .15s;
}
.ttbp_profile_edit_pencil:hover {
    color: var(--ttbp-primary-dark);
    border-color: #86efac;
    background: #f0fdf4;
}

.ttbp_profile_name {
    font-weight: var(--ttbp-fw-bold);
    font-size: var(--ttbp-fs-lg);
    color: var(--ttbp-gray-900);
    line-height: 1.3;
}

.ttbp_profile_sub {
    font-size: var(--ttbp-fs-sm);
    color: var(--ttbp-gray-500);
    margin-top: 2px;
    line-height: 1.4;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.ttbp_profile_badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ttbp-radius);
    padding: 10px var(--ttbp-sp-4);
    border-bottom: 1px solid var(--ttbp-gray-100);
}

.ttbp_badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--ttbp-radius-full);
    font-size: var(--ttbp-fs-xs);
    font-weight: var(--ttbp-fw-semibold);
    letter-spacing: .02em;
}

.ttbp_badge_green { background: #dcfce7; color: var(--ttbp-primary-dark); }
.ttbp_badge_gray  { background: var(--ttbp-gray-100); color: var(--ttbp-gray-500); }
.ttbp_badge_blue  { background: #dbeafe; color: #1d4ed8; }

/* ── Credits row ───────────────────────────────────────────────────────────── */
.ttbp_profile_credits_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--ttbp-sp-3) var(--ttbp-sp-4);
    border-bottom: 1px solid var(--ttbp-gray-100);
    background: #f0fdf4;
}

.ttbp_profile_credits_label {
    font-size: 13px;
    color: var(--ttbp-primary-dark);
    font-weight: var(--ttbp-fw-semibold);
    display: flex;
    align-items: center;
    gap: 7px;
}

.ttbp_profile_credits_amount {
    font-size: var(--ttbp-fs-xl);
    font-weight: 800;
    color: var(--ttbp-primary-dark);
}

/* ── Open tabs notice ──────────────────────────────────────────────────────── */
.ttbp_profile_open_tabs {
    padding: var(--ttbp-sp-2) var(--ttbp-sp-4);
    background: #fffbeb;
    border-bottom: 1px solid #fef3c7;
    font-size: var(--ttbp-fs-sm);
    color: #92400e;
    font-weight: var(--ttbp-fw-medium);
}

.ttbp_profile_open_tabs_label {
    display: flex;
    align-items: center;
    gap: var(--ttbp-radius);
    margin-bottom: var(--ttbp-radius);
}

.ttbp_tab_load_btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-top: var(--ttbp-sp-1);
    padding: 7px 10px;
    background: var(--ttbp-white);
    border: 1px solid #fcd34d;
    border-radius: var(--ttbp-radius);
    font-size: var(--ttbp-fs-sm);
    font-weight: var(--ttbp-fw-semibold);
    color: #92400e;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    text-align: left;
}
.ttbp_tab_load_btn:hover {
    background: #fef3c7;
    border-color: #f59e0b;
}
.ttbp_tab_load_btn .tab_load_total {
    color: #d97706;
    font-size: 13px;
}

/* ── Sections ──────────────────────────────────────────────────────────────── */
.ttbp_profile_section {
    padding: 14px var(--ttbp-sp-4);
    border-bottom: 1px solid var(--ttbp-gray-100);
}

.ttbp_profile_section_label {
    font-size: var(--ttbp-fs-xs);
    font-weight: var(--ttbp-fw-bold);
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ttbp-gray-400);
    margin-bottom: 10px;
}

/* ── Form rows ─────────────────────────────────────────────────────────────── */
.ttbp_profile_form_row {
    margin-bottom: 10px;
}

.ttbp_profile_form_row label {
    display: block;
    font-size: var(--ttbp-fs-xs);
    font-weight: var(--ttbp-fw-semibold);
    color: var(--ttbp-gray-700);
    margin-bottom: var(--ttbp-sp-1);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.ttbp_profile_input {
    width: 100%;
    padding: var(--ttbp-sp-2) 10px;
    border: 1px solid var(--ttbp-gray-300);
    border-radius: var(--ttbp-input-radius);
    font-size: 13px;
    color: var(--ttbp-gray-900);
    outline: none;
    transition: border-color .15s;
    box-sizing: border-box;
}
.ttbp_profile_input:focus {
    border-color: #16a34a;
    box-shadow: var(--ttbp-input-focus);
}

/* ── Action buttons ────────────────────────────────────────────────────────── */
.ttbp_profile_action_btn {
    width: 100%;
    justify-content: center;
    margin-bottom: var(--ttbp-radius);
}

.ttbp_profile_payment_section .ttbp_profile_pay_actions {
    display: flex;
    flex-direction: column;
    gap: var(--ttbp-sp-2);
}

/* ── COF confirmation form ─────────────────────────────────────────────────── */
.ttbp_profile_cof_form {
    margin-top: var(--ttbp-sp-3);
    padding: var(--ttbp-sp-3);
    background: var(--ttbp-gray-50);
    border: 1px solid var(--ttbp-border);
    border-radius: var(--ttbp-radius-lg);
}

.ttbp_profile_cof_btns {
    display: flex;
    gap: var(--ttbp-sp-2);
    margin-top: 10px;
}
.ttbp_profile_cof_btns .ttbp_button {
    flex: 1;
    justify-content: center;
}

/* ── Inline feedback message ───────────────────────────────────────────────── */
.ttbp_profile_msg {
    margin-top: var(--ttbp-sp-2);
    font-size: var(--ttbp-fs-sm);
    font-weight: var(--ttbp-fw-semibold);
    padding: var(--ttbp-radius) 10px;
    border-radius: 5px;
    background: var(--ttbp-gray-50);
}

/* ── Required asterisk ─────────────────────────────────────────────────────── */
.ttbp_req { color: var(--ttbp-danger); margin-left: 2px; }

/* ── Editable profile grid ─────────────────────────────────────────────────── */
.ttbp_pp_grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    padding: 12px var(--ttbp-sp-4) 8px;
}
.ttbp_pp_span2 { grid-column: 1 / -1; }
.ttbp_pp_field label {
    display: block;
    font-size: var(--ttbp-fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--ttbp-gray-400);
    margin-bottom: 2px;
}
.ttbp_pp_input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid var(--ttbp-gray-200);
    border-radius: 5px;
    font-size: var(--ttbp-fs-base);
    color: var(--ttbp-gray-900);
    outline: none;
    box-sizing: border-box;
    transition: border-color .15s;
}
.ttbp_pp_input:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 2px rgba(21,128,61,0.12);
}
textarea.ttbp_pp_input { resize: vertical; min-height: 36px; }
select.ttbp_pp_input { padding: 4px 6px; }

/* ── Status + Save row ────────────────────────────────────────────────────── */
.ttbp_pp_status_row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px var(--ttbp-sp-4);
    border-top: 1px solid var(--ttbp-gray-100);
    border-bottom: 1px solid var(--ttbp-gray-100);
    background: var(--ttbp-gray-50);
}
.ttbp_pp_status_row .ttbp_profile_badges {
    padding: 0;
    border: none;
    gap: 4px;
}
.ttbp_pp_save_wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.ttbp_pp_save_btn {
    padding: 4px 14px;
    font-size: 12px;
}
.ttbp_pp_save_msg {
    font-size: 11px;
    font-weight: 600;
    transition: opacity .3s;
}
.ttbp_pp_save_msg.ok { color: #16a34a; }
.ttbp_pp_save_msg.err { color: #dc2626; }

/* ── Actions row (credits + tab side by side) ─────────────────────────────── */
.ttbp_pp_actions_row {
    display: flex;
    gap: 1px;
    background: var(--ttbp-gray-100);
}
.ttbp_pp_action_box {
    flex: 1;
    padding: 8px 12px;
    background: var(--ttbp-white);
}
.ttbp_pp_action_hdr {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ttbp-gray-600);
    margin-bottom: 6px;
}
.ttbp_pp_action_hdr strong { font-size: 14px; }
.ttbp_pp_tab_toggle { margin-left: auto; }
.ttbp_pp_action_body { }
.ttbp_pp_inline_row {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}
.ttbp_pp_sm { max-width: 80px; }
.ttbp_pp_sm_btn {
    padding: 4px 10px;
    font-size: var(--ttbp-fs-xs);
    white-space: nowrap;
}

/* ── Collapsible give credits ─────────────────────────────────────────────── */
.ttbp_pp_details {
    border-top: 1px solid var(--ttbp-gray-100);
}
.ttbp_pp_details summary {
    padding: 8px var(--ttbp-sp-4);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ttbp-gray-500);
    cursor: pointer;
    user-select: none;
}
.ttbp_pp_details summary:hover { color: var(--ttbp-gray-700); }
.ttbp_pp_details_body {
    padding: 0 var(--ttbp-sp-4) 10px;
}

/* ── Wider panel for editable content ─────────────────────────────────────── */
.ttbp_profile_panel {
    width: 480px;
}

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .ttbp_profile_panel {
        width: 100vw;
    }
    .ttbp_pp_actions_row {
        flex-direction: column;
    }
}

/* ── Player profile context bar (compact, between header and body) ──────── */
.ttbp_sale_player_profiles {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ttbp-sp-1);
    padding: var(--ttbp-sp-1) var(--ttbp-sp-3);
    background: #f0fdf4;
    border-bottom: 1px solid #d1fae5;
    flex-shrink: 0;
}

.ttbp_sale_profiles_label {
    font-size: 9px;
    font-weight: var(--ttbp-fw-bold);
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ttbp-primary-dark);
    margin-right: var(--ttbp-sp-1);
    white-space: nowrap;
}

.ttbp_player_profile_btn {
    display: inline-flex;
    align-items: center;
    gap: var(--ttbp-sp-1);
    margin: 0 2px 2px 0;
    padding: 3px var(--ttbp-sp-2);
    background: var(--ttbp-white);
    border: 1px solid #86efac;
    border-radius: var(--ttbp-radius-full);
    font-size: var(--ttbp-fs-xs);
    font-weight: var(--ttbp-fw-semibold);
    color: var(--ttbp-primary-dark);
    cursor: pointer;
    transition: background .15s, border-color .15s;
}
.ttbp_player_profile_btn:hover {
    background: #dcfce7;
    border-color: #4ade80;
}

/* ── Player row profile button (in Booking Info modal) ─────────────────────── */
/* Inherits .bi-gr-btn base from ttbp-sale.css; this adds the green accent */
.bi-gr-profile {
    background: #d1fae5;
    color: var(--ttbp-primary-dark);
    border-color: #86efac;
    font-size: var(--ttbp-fs-base);
    line-height: 1;
}
.bi-gr-profile:hover {
    background: #a7f3d0;
    color: #065f46;
}

/* ── Customer search in header ───────────────────────────────────────────── */
.ttbp_sale_customer_search {
    display: flex;
    align-items: center;
    gap: var(--ttbp-radius);
    flex-shrink: 0;
    position: relative;
}
.ttbp_sale_customer_search_inner {
    display: flex;
    align-items: center;
    gap: var(--ttbp-radius);
    position: relative;
}
.ttbp_sale_customer_search_inner > i {
    color: rgba(255,255,255,0.7); /* white with opacity */
    font-size: var(--ttbp-fs-sm);
}
#ttbp_customer_search_input {
    width: 720px;
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,0.35); /* white with opacity */
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    background: rgba(255,255,255,0.15); /* white with opacity */
    color: var(--ttbp-white);
}
#ttbp_customer_search_input::placeholder {
    color: rgba(255,255,255,0.55); /* white with opacity */
}
#ttbp_customer_search_input:focus {
    border-color: rgba(255,255,255,0.5); /* white with opacity */
    background: rgba(255,255,255,0.25); /* white with opacity */
}
.ttbp_customer_search_results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--ttbp-white);
    border: 1px solid #d1fae5;
    border-radius: var(--ttbp-radius-lg);
    box-shadow: var(--ttbp-shadow-lg);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    min-width: 260px;
}
.ttbp_customer_result_item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 10px;
    cursor: pointer;
    font-size: var(--ttbp-fs-sm);
    border-bottom: 1px solid var(--ttbp-gray-100);
    transition: background .12s;
}
.ttbp_customer_result_item:hover {
    background: #f0fdf4;
}
.ttbp_customer_result_item:last-child {
    border-bottom: none;
}
.ttbp_customer_result_name {
    font-weight: var(--ttbp-fw-semibold);
    color: var(--ttbp-gray-900);
}
.ttbp_customer_result_email {
    font-size: 10px;
    color: var(--ttbp-gray-500);
}
.ttbp_sale_customer_badge {
    display: none; /* badge moved to header via ttbp_hdr_customer_badge */
}
.ttbp_customer_search_empty {
    padding: 10px;
    text-align: center;
    font-size: var(--ttbp-fs-xs);
    color: var(--ttbp-gray-500);
}

/* ── Create New customer button (POS header) ──────────────────────────────── */
.ttbp_customer_create_btn {
    padding: 4px 10px;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 5px;
    background: rgba(255,255,255,0.15);
    color: var(--ttbp-white);
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.ttbp_customer_create_btn:hover {
    background: rgba(255,255,255,0.25);
    border-color: rgba(255,255,255,0.5);
}
.ttbp_customer_create_btn i { margin-right: 3px; }

/* ── Inline create form (dropdown below search) ──────────────────────────── */
.ttbp_customer_create_form {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--ttbp-white);
    border: 1px solid #d1fae5;
    border-radius: var(--ttbp-radius-lg);
    box-shadow: var(--ttbp-shadow-lg);
    padding: 12px;
    z-index: 1001;
    min-width: 320px;
}
.ttbp_ccf_fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}
.ttbp_ccf_fields input {
    padding: 7px 10px;
    border: 1px solid var(--ttbp-gray-200);
    border-radius: 5px;
    font-size: 13px;
    outline: none;
    color: var(--ttbp-gray-900);
}
.ttbp_ccf_fields input:focus {
    border-color: var(--ttbp-primary);
    box-shadow: 0 0 0 2px rgba(21,128,61,0.15);
}
.ttbp_ccf_actions {
    display: flex;
    gap: 8px;
}
.ttbp_ccf_save {
    padding: 6px 14px;
    background: var(--ttbp-primary);
    color: var(--ttbp-white);
    border: none;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s;
}
.ttbp_ccf_save:hover { background: #166534; }
.ttbp_ccf_cancel {
    padding: 6px 12px;
    background: transparent;
    color: var(--ttbp-gray-500);
    border: 1px solid var(--ttbp-gray-200);
    border-radius: 5px;
    font-size: 13px;
    cursor: pointer;
}
.ttbp_ccf_cancel:hover { background: var(--ttbp-gray-50); }
.ttbp_ccf_msg {
    margin-top: 8px;
    font-size: 12px;
    text-align: center;
}

/* ── Toggle switch ─────────────────────────────────────────────────────────── */
/* ── Manager lock fields (COF / Tabs in edit customer modal) ──────────── */
.ttbp-locked-field {
    transition: opacity .2s;
}
.ttbp-locked-field[data-locked="true"] .ttbp-lock-label {
    opacity: 0.5;
    pointer-events: none;
}
.ttbp-locked-field[data-locked="false"] .ttbp-lock-label {
    opacity: 1;
    pointer-events: auto;
}
.ttbp-lock-toggle {
    background: none;
    border: 1px solid var(--ttbp-gray-300);
    border-radius: var(--ttbp-radius-sm);
    padding: var(--ttbp-sp-1) 7px;
    cursor: pointer;
    font-size: var(--ttbp-fs-base);
    color: var(--ttbp-gray-500);
    line-height: 1;
    transition: color .15s, border-color .15s, background .15s;
}
.ttbp-lock-toggle:hover {
    background: var(--ttbp-gray-100);
    border-color: var(--ttbp-gray-400);
    color: var(--ttbp-gray-700);
}
.ttbp-locked-field[data-locked="false"] .ttbp-lock-toggle {
    color: #16a34a;
    border-color: #86efac;
}

.ttbp_toggle_switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
}
.ttbp_toggle_switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.ttbp_toggle_slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--ttbp-gray-300);
    border-radius: var(--ttbp-radius-full);
    transition: background .2s;
}
.ttbp_toggle_slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: var(--ttbp-white);
    border-radius: 50%;
    transition: transform .2s;
}
.ttbp_toggle_switch input:checked + .ttbp_toggle_slider {
    background: var(--ttbp-primary-dark);
}
.ttbp_toggle_switch input:checked + .ttbp_toggle_slider::before {
    transform: translateX(16px);
}

/* ── Card info badge (COF section) ─────────────────────────────────────── */
#ttbp_profile_card_info .ttbp_badge {
    font-size: 12px;
    padding: 4px 12px;
}
#ttbp_profile_card_info .ttbp_badge i {
    font-size: 14px;
}

/* ── Declined state ────────────────────────────────────────────────────── */
#ttbp_profile_cof_declined_wrap .ttbp_badge {
    font-size: 12px;
    padding: 4px 12px;
    background: #fef2f2;
    color: #991b1b;
}
#ttbp_profile_cof_declined_wrap .ttbp_badge i {
    color: #dc2626;
}
