
html body .doctors-grid,
html body *:has(> .doctor-card) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
}

/* min-width:0 stops long names from stretching a column */
html body .doctors-grid > *,
html body *:has(> .doctor-card) > * {
    min-width: 0;
}

@media (max-width: 899px) {
    html body .doctors-grid,
    html body *:has(> .doctor-card) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }
}

@media (max-width: 599px) {
    html body .doctors-grid,
    html body *:has(> .doctor-card) {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}

@media (max-width: 340px) {
    html body .doctors-grid,
    html body *:has(> .doctor-card) {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ===================================================================
   Card — base (tablet + desktop)
   =================================================================== */
.doctor-card {
    --dc-gap: 14px;
    position: relative;
    height: 100%;
    min-height: 0;
    border-radius: 20px;
    box-shadow: 0 1px 2px rgba(15, 40, 70, 0.04);
}

.doctor-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 18px 40px -18px rgba(11, 42, 69, 0.35);
}

/* ---------- Cover + badge ---------- */
.doctor-card .doctor-cover {
    height: 104px;
}

.doctor-card .subscription-badge {
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
}

/* ---------- Favorite (heart) ----------
   The doubled class bumps specificity so older files can't hide it.
   The <form> around the button has no class and takes no space,
   because the button is absolutely positioned against .doctor-card. */
.doctor-card.doctor-card .doctor-favorite {
    position: absolute;
    top: 12px;
    left: 12px;
    right: auto;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    border-radius: 50%;
    border: 1px solid rgba(15, 40, 70, 0.1);
    background: var(--bg-surface, #fff);
    color: var(--text-muted, #64748b);
    box-shadow: 0 2px 8px rgba(15, 40, 70, 0.12);
    cursor: pointer;
    transition: transform 0.15s ease, color 0.15s ease;
}

.doctor-card.doctor-card .doctor-favorite:hover {
    transform: scale(1.08);
}

.doctor-card.doctor-card .doctor-favorite i {
    display: block;
    font-size: 17px;
    line-height: 1;
    color: inherit;
}

/* Font Awesome weights: regular = 400, solid = 900 */
.doctor-card .doctor-favorite i.fa-regular {
    font-weight: 400;
}

.doctor-card .doctor-favorite i.fa-solid {
    font-weight: 900;
}

.doctor-card.doctor-card .doctor-favorite.is-active,
.doctor-card.doctor-card .doctor-favorite.is-active i {
    color: #ef4444;
}

/* ---------- Avatar ---------- */
.doctor-card .doctor-image {
    width: 96px;
    height: 96px;
    top: 56px;
    right: 20px;
    border-width: 4px;
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(11, 42, 69, 0.16);
    overflow: hidden;
    padding: 0;
    background: var(--input, #fff);
}

.doctor-card .doctor-image .med-doctor-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top; /* focus on the face */
    border-radius: inherit;
}

.doctor-card .image-unavailable i {
    width: 38px;
    height: 38px;
    font-size: 16px;
}

.doctor-card .image-unavailable span {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

/* ---------- Content ---------- */
.doctor-card .doctor-content {
    padding: 56px 18px 18px;
    gap: 0;
}

.doctor-card .doctor-name h3,
.doctor-card .doctor-name-title {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.45;
}

.doctor-card .doctor-name p {
    margin-top: 4px;
    font-size: 13px;
    font-weight: 700;
}

.doctor-card .verified-badge {
    font-size: 15px;
}

/* ---------- Rating / limited-info strip ---------- */
.doctor-card .rating-row,
.doctor-card .limited-info {
    min-height: 44px;
    margin-top: var(--dc-gap);
    padding: 9px 12px;
    border-radius: 12px;
}

.doctor-card .stars {
    font-size: 13px;
    gap: 2px;
}

.doctor-card .rating-number {
    font-size: 13px;
    font-weight: 800;
}

.doctor-card .rating-number small {
    font-size: 11px;
    font-weight: 600;
}

.doctor-card .limited-info {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.6;
}

/* ---------- Detail rows ---------- */
.doctor-card .doctor-details {
    gap: 10px;
    margin-top: var(--dc-gap);
}

.doctor-card .doctor-detail {
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.6;
}

.doctor-card .doctor-detail i {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 13px;
}

/* ---------- Service tags ---------- */
.doctor-card .doctor-services {
    gap: 6px;
    margin-top: var(--dc-gap);
}

.doctor-card .service-tag {
    padding: 5px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.5;
}

/* ---------- Primary action ---------- */
.doctor-card .doctor-button-card {
    height: auto;
    min-height: 46px;
    margin-top: 18px;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    gap: 8px;
}

/* ===================================================================
   Tablet, narrower cards (3 columns at 900-1099px are ~290px wide)
   =================================================================== */
@media (min-width: 900px) and (max-width: 1099px) {
    .doctor-card .doctor-content {
        padding-inline: 14px;
    }

    .doctor-card .doctor-button-card {
        font-size: 13px;
    }
}

/* ===================================================================
   Phones (<= 599px): vertical card, two per row
   Layout (RTL): photo block on top, then ALL text starts from the same
   edge (the right side). Name and specialty reserve two lines so every
   row of cards lines up: details and button sit at the bottom.
   =================================================================== */
@media (max-width: 599px) {

    .doctor-card {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 8px;
        border-radius: 16px;
        text-align: start;
        box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    }

    .doctor-card:hover {
        transform: none;
    }

    /* Cover disappears but its children (premium badge) stay in the card */
    .doctor-card .doctor-cover {
        display: contents;
    }

    /* Premium badge: icon-only pill over the photo, top start corner */
    .doctor-card .subscription-badge {
        position: absolute;
        top: 14px;
        right: 14px;
        left: auto;
        bottom: auto;
        z-index: 10;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        padding: 0;
        font-size: 0; /* hides the text, keeps the crown */
        gap: 0;
    }

    .doctor-card .subscription-badge i {
        font-size: 12px;
    }

    /* Heart: over the photo, top end corner */
    .doctor-card.doctor-card .doctor-favorite {
        top: 14px;
        left: 14px;
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }

    .doctor-card.doctor-card .doctor-favorite i {
        font-size: 14px;
    }

    /* Photo block: full card width, fixed ratio so all cards match */
    .doctor-card .doctor-image {
        position: static;
        width: 100%;
        height: auto;
        min-width: 0;
        min-height: 0;
        aspect-ratio: 5 / 4;
        margin: 0 0 10px;
        border-width: 0;
        border-radius: 12px;
        box-shadow: none;
        flex-shrink: 0;
    }

    .doctor-card .image-unavailable {
        width: 100%;
        height: 100%;
        gap: 4px;
    }

    .doctor-card .image-unavailable i {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .doctor-card .image-unavailable span {
        font-size: 10.5px;
        line-height: 1.3;
    }

    .doctor-card .doctor-content {
        flex: 1 1 auto;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
        min-width: 0;
        padding: 0 2px 2px;
        text-align: start;
    }

    .doctor-card .doctor-top {
        margin: 0;
        padding: 0;
    }

    /* Name: up to 2 lines, check badge stays beside the first line */
    .doctor-card .doctor-name-title {
        display: flex;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 4px;
        margin: 0;
        font-size: 0.88rem;
        line-height: 1.4;
    }

    .doctor-card .doctor-name-title span {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        min-width: 0;
        min-height: 2.8em;
        overflow: hidden;
        word-break: break-word;
    }

    .doctor-card .doctor-name-title .verified-badge {
        flex-shrink: 0;
        margin-top: 0.2em;
        font-size: 13px;
    }

    /* Specialty: up to 2 lines, reserved height keeps cards aligned */
    .doctor-card .doctor-name p {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        min-height: 2.6em;
        margin: 0;
        font-size: 0.74rem;
        font-weight: 600;
        line-height: 1.3;
        color: var(--color-primary);
    }

    .doctor-card .rating-row {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 4px;
        min-height: 0;
        margin: 0;
        padding: 0;
        background: none;
        border: 0;
        font-size: 0.74rem;
    }

    .doctor-card .stars {
        font-size: 0.68rem;
        gap: 1px;
    }

    .doctor-card .rating-number {
        font-size: 0.74rem;
    }

    .doctor-card .rating-number small,
    .doctor-card .doctor-services {
        display: none;
    }

    /* "Rating not available": one quiet line, lock icon + short text,
       same start edge and height as the rating row */
    .doctor-card .limited-info {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 5px;
        min-height: 0;
        margin: 0;
        padding: 0;
        border: 0;
        background: none;
        font-size: 0.7rem;
        font-weight: 600;
        line-height: 1.4;
        color: var(--text-subtle, #94a3b8);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .doctor-card .limited-info i {
        flex-shrink: 0;
        width: auto;
        height: auto;
        font-size: 0.66rem;
        color: inherit;
    }

    /* Area + experience: pushed down so they line up across cards */
    .doctor-card .doctor-details {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin: auto 0 0;
        padding-top: 6px;
        color: var(--text-muted);
    }

    .doctor-card .doctor-detail {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 6px;
        max-width: 100%;
        font-size: 0.74rem;
        line-height: 1.4;
    }

    .doctor-card .doctor-detail i {
        width: 22px;
        height: 22px;
        flex-shrink: 0;
        border-radius: 7px;
        font-size: 11px;
    }

    .doctor-card .doctor-button-card {
        width: 100%;
        min-height: 38px;
        height: auto;
        margin-top: 10px;
        padding: 6px 8px;
        border-radius: 10px;
        font-size: 0.76rem;
        line-height: 1.3;
        text-align: center;
    }
}

/* ===================================================================
   Very small phones (<= 340px): one card per row, a bit more room
   =================================================================== */
@media (max-width: 340px) {
    .doctor-card .doctor-image {
        aspect-ratio: 16 / 10;
    }

    .doctor-card .doctor-name-title {
        font-size: 0.95rem;
    }

    .doctor-card .doctor-name p,
    .doctor-card .doctor-detail {
        font-size: 0.8rem;
    }
}
/* الكارت كله بقى لينك للملف الطبي */
.doctor-card .doctor-button-card {
    position: static;
}

.doctor-card .doctor-button-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}

.doctor-card {
    cursor: pointer;
}

/* ===================================================================
   Dark Mode Support for Doctor Cards
   =================================================================== */
body.dark .doctor-card,
body.dark-mode .doctor-card {
    background: var(--card);
    border-color: var(--border);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

body.dark .doctor-card:hover,
body.dark-mode .doctor-card:hover {
    border-color: var(--primary);
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
}

body.dark .doctor-card.doctor-card .doctor-favorite,
body.dark-mode .doctor-card.doctor-card .doctor-favorite {
    background: var(--card);
    border-color: var(--border);
    color: var(--text-light);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

body.dark .doctor-card.doctor-card .doctor-favorite:hover,
body.dark-mode .doctor-card.doctor-card .doctor-favorite:hover {
    background: var(--input);
    color: var(--text);
}

body.dark .doctor-card.doctor-card .doctor-favorite.is-active,
body.dark-mode .doctor-card.doctor-card .doctor-favorite.is-active,
body.dark .doctor-card.doctor-card .doctor-favorite.is-active i,
body.dark-mode .doctor-card.doctor-card .doctor-favorite.is-active i {
    color: #ef4444;
}

body.dark .doctor-card .doctor-image,
body.dark-mode .doctor-card .doctor-image {
    background: var(--input);
    border-color: var(--card);
}

body.dark .doctor-card .doctor-button-card,
body.dark-mode .doctor-card .doctor-button-card {
    background: #1976d2;
    border-color: #1976d2;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(25, 118, 210, 0.3);
}

body.dark .doctor-card .doctor-button-card:hover,
body.dark-mode .doctor-card .doctor-button-card:hover {
    background: #1565c0;
    border-color: #1565c0;
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(21, 101, 192, 0.4);
}

body.dark .doctor-card .doctor-button-card.free-button,
body.dark-mode .doctor-card .doctor-button-card.free-button {
    background: transparent;
    border-color: var(--primary);
    color: var(--primary);
}

body.dark .doctor-card .doctor-button-card.free-button:hover,
body.dark-mode .doctor-card .doctor-button-card.free-button:hover {
    background: var(--primary-light);
    color: #ffffff;
}

body.dark .doctor-card .doctor-name-title,
body.dark-mode .doctor-card .doctor-name-title {
    color: var(--text);
}

body.dark .doctor-card .doctor-name p,
body.dark-mode .doctor-card .doctor-name p {
    color: var(--primary);
}

body.dark .doctor-card .doctor-detail,
body.dark-mode .doctor-card .doctor-detail,
body.dark .doctor-card .doctor-details,
body.dark-mode .doctor-card .doctor-details,
body.dark .doctor-card .limited-info,
body.dark-mode .doctor-card .limited-info {
    color: var(--text-light);
}

body.dark .doctor-card .limited-info,
body.dark-mode .doctor-card .limited-info {
    background: var(--input);
    border-color: var(--border);
}

body.dark .doctor-card .doctor-cover,
body.dark-mode .doctor-card .doctor-cover,
body[data-theme="dark"] .doctor-card .doctor-cover {
    background: linear-gradient(130deg, #071e33, #0d3860, #14497a) !important;
}
