/* My Account → Prescriptions */

.ycc-rx {
    --rx-primary: var(--color-primary, #4a99d2);
    --rx-secondary: var(--color-secondary, #90ae4c);
    --rx-text: #1f2933;
    --rx-muted: #637083;
    --rx-border: #e3e8ee;
    --rx-surface: #fff;
    --rx-subtle: #f5f7fa;
    --rx-radius: 12px;

    --rx-success: #1e7f3c;
    --rx-success-bg: #e5f5ea;
    --rx-warning: #8a5a00;
    --rx-warning-bg: #fff4d6;
    --rx-info: #1f5f8f;
    --rx-info-bg: #e3f0fa;
    --rx-danger: #b42318;
    --rx-danger-bg: #fdecea;
    --rx-neutral-bg: #eef1f4;

    color: var(--rx-text);
    display: grid;
    gap: 32px;
}

.ycc-rx [hidden] { display: none !important; }

/* Let grid/flex children shrink so the scrollable tab strip can't widen the page. */
.ycc-rx > *,
.ycc-rx-section > *,
.ycc-rx-toolbar > * { min-width: 0; }

/* Header */
.ycc-rx-header__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

/* Section */
.ycc-rx-section { display: grid; gap: 16px; }
.ycc-rx-section__title { margin: 0 0 4px; }
.ycc-rx-section__intro { margin: 0; color: var(--rx-muted); max-width: 70ch; }

/* Toolbar: tabs + search + sort */
.ycc-rx-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--rx-border);
    padding-bottom: 12px;
}

.ycc-rx-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
    max-width: 100%;
}

.ycc-rx-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--rx-border);
    background: var(--rx-surface);
    color: var(--rx-text) !important;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none !important;
    white-space: nowrap;
}

.ycc-rx-tab:hover { border-color: var(--rx-primary); }

.ycc-rx-tab.is-active {
    background: var(--rx-primary);
    border-color: var(--rx-primary);
    color: #fff !important;
}

.ycc-rx-tab__count {
    min-width: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--rx-neutral-bg);
    color: var(--rx-muted);
    font-size: 12px;
    line-height: 20px;
    text-align: center;
}

.ycc-rx-tab.is-active .ycc-rx-tab__count { background: rgba(255, 255, 255, .25); color: #fff; }

.ycc-rx-filters { display: flex; gap: 8px; flex-wrap: wrap; }

.ycc-rx-search {
    position: relative;
    display: flex;
    align-items: center;
    margin: 0;
}

.ycc-rx-search svg {
    position: absolute;
    left: 10px;
    color: var(--rx-muted);
    pointer-events: none;
}

.ycc-rx-search input,
.ycc-rx-sort select,
.ycc-rx-field select {
    height: 38px;
    border: 1px solid var(--rx-border);
    border-radius: 8px;
    background: var(--rx-surface);
    font-size: 14px;
    margin: 0;
}

.ycc-rx-search input { padding: 0 10px 0 32px; width: 240px; max-width: 100%; }
.ycc-rx-sort { margin: 0; }
.ycc-rx-sort select { padding: 0 8px; }

/* Card list */
.ycc-rx-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 16px;
    align-items: start;
}

.ycc-rx-empty {
    margin: 0;
    padding: 32px 16px;
    border: 1px dashed var(--rx-border);
    border-radius: var(--rx-radius);
    color: var(--rx-muted);
    text-align: center;
}

/* Card */
.ycc-rx-card {
    position: relative;
    display: grid;
    gap: 14px;
    padding: 18px;
    background: var(--rx-surface);
    border: 1px solid var(--rx-border);
    border-radius: var(--rx-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
    transition: box-shadow .15s ease, opacity .15s ease;
    scroll-margin-top: 120px;
}

.ycc-rx-card:hover { box-shadow: 0 4px 14px rgba(16, 24, 40, .08); }
.ycc-rx-card[aria-busy="true"] { opacity: .6; pointer-events: none; }
.ycc-rx-card.is-highlighted { outline: 3px solid var(--rx-primary); outline-offset: 2px; }

.ycc-rx-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 28px;
}

.ycc-rx-card__title h3 { margin-top: 0; margin-bottom: 0 !important; font-size: 18px; line-height: 1.3; }
.ycc-rx-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 2px 0 0;
    color: var(--rx-muted);
    font-size: 13px;
}

.ycc-rx-card__details { display: grid; gap: 10px; margin: 0; }
.ycc-rx-card__details > div { display: grid; grid-template-columns: 110px 1fr; align-items: center; gap: 8px; }
.ycc-rx-card__details dt { margin: 0; color: var(--rx-muted); font-size: 13px; font-weight: 600; }
.ycc-rx-card__details dd { margin: 0; }
.ycc-rx-field select { width: 100%; padding: 0 8px; }

/* Badge */
.ycc-rx-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .01em;
    background: var(--rx-neutral-bg);
    color: var(--rx-muted);
}

.ycc-rx-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.ycc-rx-badge--success { background: var(--rx-success-bg); color: var(--rx-success); }
.ycc-rx-badge--warning { background: var(--rx-warning-bg); color: var(--rx-warning); }
.ycc-rx-badge--info    { background: var(--rx-info-bg);    color: var(--rx-info); }
.ycc-rx-badge--danger  { background: var(--rx-danger-bg);  color: var(--rx-danger); }

/* Progress tracker */
.ycc-rx-progress {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    margin: 0;
    padding: 0;
    list-style: none;
}

.ycc-rx-progress__step {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 4px;
    margin: 0;
    text-align: center;
}

.ycc-rx-progress__step::before {
    content: "";
    position: absolute;
    top: 5px;
    right: 50%;
    width: 100%;
    height: 2px;
    background: var(--rx-border);
}

.ycc-rx-progress__step:first-child::before { display: none; }
.ycc-rx-progress__step.is-done::before,
.ycc-rx-progress__step.is-current::before { background: var(--rx-primary); }

.ycc-rx-progress__dot {
    position: relative;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--rx-surface);
    border: 2px solid var(--rx-border);
}

.ycc-rx-progress__step.is-done .ycc-rx-progress__dot { background: var(--rx-primary); border-color: var(--rx-primary); }
.ycc-rx-progress__step.is-current .ycc-rx-progress__dot { border-color: var(--rx-primary); box-shadow: 0 0 0 3px rgba(74, 153, 210, .2); }

.ycc-rx-progress__label { font-size: 11px; color: var(--rx-muted); line-height: 1.2; }
.ycc-rx-progress__step.is-current .ycc-rx-progress__label { color: var(--rx-text); font-weight: 700; }

/* Items */
.ycc-rx-items { border-top: 1px solid var(--rx-border); padding-top: 12px; }
.ycc-rx-items__title {
    margin: 0 0 6px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--rx-muted);
}
.ycc-rx-items ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 2px; }

.ycc-rx-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 6px 8px;
    border-radius: 8px;
}

.ycc-rx-item:hover { background: var(--rx-subtle); }
.ycc-rx-item__name { flex: 1 1 160px; font-size: 14px; }

.ycc-rx-chip {
    padding: 1px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: var(--rx-neutral-bg);
    color: var(--rx-muted);
}

.ycc-rx-chip--dispensed { background: var(--rx-success-bg); color: var(--rx-success); }
.ycc-rx-chip--owed      { background: var(--rx-warning-bg); color: var(--rx-warning); }
.ycc-rx-chip--stock     { background: var(--rx-danger-bg);  color: var(--rx-danger); }
.ycc-rx-chip--cancelled { text-decoration: line-through; }

/* Item quantity: "× 3", or − 3 + while the prescription can still change */
.ycc-rx-item__qty { min-width: 32px; font-size: 14px; font-weight: 700; text-align: right; color: var(--rx-text); }

.ycc-rx-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--rx-border);
    border-radius: 8px;
    background: var(--rx-surface);
    overflow: hidden;
}

body.woocommerce-account .ycc-rx button.ycc-rx-qty__btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    min-height: 0;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: var(--rx-subtle) !important;
    color: var(--rx-text) !important;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}
body.woocommerce-account .ycc-rx button.ycc-rx-qty__btn:hover:not(:disabled) { background: var(--rx-neutral-bg) !important; }
body.woocommerce-account .ycc-rx button.ycc-rx-qty__btn:disabled { opacity: .35; cursor: not-allowed; }
.ycc-rx-qty__btn:focus-visible { outline: 3px solid var(--rx-primary); outline-offset: -3px; }
.ycc-rx-qty__value { min-width: 28px; font-size: 14px; font-weight: 700; text-align: center; }

.ycc-rx-item__remove {
    display: inline-grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--rx-muted);
    cursor: pointer;
}

.ycc-rx-item__remove:hover { background: var(--rx-danger-bg); color: var(--rx-danger); }

/* Note */
.ycc-rx-note {
    margin: 0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    background: var(--rx-subtle);
    color: var(--rx-muted);
}

.ycc-rx-note a { font-weight: 700; margin-left: 4px; }
.ycc-rx-note--info    { background: var(--rx-info-bg);    color: var(--rx-info); }
.ycc-rx-note--warning { background: var(--rx-warning-bg); color: var(--rx-warning); }
.ycc-rx-note--danger  { background: var(--rx-danger-bg);  color: var(--rx-danger); }

/* Buttons */
.ycc-rx-card__actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }

.ycc-rx-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
    text-decoration: none !important;
    cursor: pointer;
    transition: filter .15s ease, background-color .15s ease;
}

.ycc-rx-btn:hover:not(:disabled) { filter: brightness(.95); }
.ycc-rx-btn:disabled { opacity: .45; cursor: not-allowed; }

.ycc-rx-btn--primary   { background: var(--rx-primary); color: #fff !important; }
.ycc-rx-btn--secondary { background: var(--rx-secondary); color: #fff !important; }
.ycc-rx-btn--success   { background: var(--rx-success); color: #fff !important; }
.ycc-rx-btn--danger    { background: var(--rx-danger); color: #fff !important; }
.ycc-rx-btn--danger-outline { background: transparent; border-color: var(--rx-danger); color: var(--rx-danger) !important; }
.ycc-rx-btn--ghost     { background: transparent; border-color: var(--rx-border); color: var(--rx-text) !important; }

.ycc-rx-btn:focus-visible,
.ycc-rx-tab:focus-visible,
.ycc-rx-item__remove:focus-visible,
.ycc-rx-menu__toggle:focus-visible,
.ycc-rx-menu__item:focus-visible {
    outline: 3px solid var(--rx-primary);
    outline-offset: 2px;
}

/* Overflow menu */
.ycc-rx-menu { position: relative; }
.ycc-rx-menu__toggle {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: var(--rx-muted);
    cursor: pointer;
    list-style: none;
}

.ycc-rx-menu__toggle::-webkit-details-marker { display: none; }
.ycc-rx-menu__toggle:hover,
.ycc-rx-menu[open] .ycc-rx-menu__toggle { background: var(--rx-subtle); }

.ycc-rx-menu__list {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    z-index: 5;
    min-width: 200px;
    padding: 6px;
    background: var(--rx-surface);
    border: 1px solid var(--rx-border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .12);
}

.ycc-rx-menu__item {
    display: block;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--rx-text);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}

.ycc-rx-menu__item:hover { background: var(--rx-subtle); }
.ycc-rx-menu__item.is-danger { color: var(--rx-danger); }

/* Toasts */
.ycc-rx-toasts {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 100000;
    display: grid;
    gap: 8px;
    max-width: min(380px, calc(100vw - 32px));
}

.ycc-rx-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    background: #1f2933;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 8px 24px rgba(16, 24, 40, .2);
    animation: ycc-rx-in .2s ease-out;
}

.ycc-rx-toast--error { background: var(--rx-danger); }
.ycc-rx-toast a { color: #fff; font-weight: 700; text-decoration: underline; white-space: nowrap; }

@keyframes ycc-rx-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* Confirm dialog */
.ycc-rx-dialog {
    width: min(440px, calc(100vw - 32px));
    padding: 24px;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(16, 24, 40, .25);
}

.ycc-rx-dialog::backdrop { background: rgba(16, 24, 40, .45); }
.ycc-rx-dialog__title { margin: 0 0 8px; font-size: 18px; }
.ycc-rx-dialog__text { margin: 0 0 20px; color: var(--rx-muted); }
.ycc-rx-dialog__actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 600px) {
    .ycc-rx-toolbar { align-items: stretch; flex-direction: column; }
    .ycc-rx-filters { display: grid; grid-template-columns: 1fr auto; }
    .ycc-rx-search input { width: 100%; }
    .ycc-rx-card { padding: 16px; }
    .ycc-rx-card__details > div { grid-template-columns: 1fr; gap: 4px; }
    /* Keep every progress stage readable on phones. */
    .ycc-rx-progress__label { display: block; font-size: 10px; overflow-wrap: anywhere; text-align: center; }
    .ycc-rx-card__actions .ycc-rx-btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
    .ycc-rx-card, .ycc-rx-toast { transition: none; animation: none; }
}
