/* ==========================================
   DOCTOR APP - FEATURE PAGES
   (doctors, appointments, booking, emergency,
    prescriptions, help, settings)
   ========================================== */

:root {
    --primary: #174b91;
    --primary-dark: #10366b;
    --accent: #24a6d9;
    --background: #f4f7fc;
    --surface: #ffffff;
    --text: #182b49;
    --muted: #78869b;
    --border: #e5ebf3;
    --danger: #c53243;
    --success: #167647;
    --shadow: 0 8px 25px rgba(22, 57, 100, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    font-family: Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    padding-bottom: 40px;
}

body.has-nav {
    padding-bottom: 100px;
}

/* ---------- HEADER ---------- */

.header {
    width: 100%;
    min-height: 75px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 6%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 1px;
    text-decoration: none;
}

.brand-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 24px;
}

.brand-dot {
    color: var(--accent);
}

.back-link {
    color: var(--primary);
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
}

.profile-button {
    width: 43px;
    height: 43px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: #eef4ff;
    font-size: 21px;
    cursor: pointer;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    color: var(--primary);
}

/* ---------- LAYOUT ---------- */

.page {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 22px 16px 30px;
    animation: page-in 0.35s ease both;
}

@keyframes page-in {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-title {
    font-size: 24px;
    margin-bottom: 6px;
}

.page-subtitle {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
    margin-bottom: 20px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px 17px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.panel h2 {
    font-size: 17px;
    margin-bottom: 4px;
}

.panel > .hint {
    margin-bottom: 14px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.hint {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.7;
}

/* ---------- FORMS ---------- */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 12px;
}

.field {
    min-width: 0;
}

.field.full {
    grid-column: 1 / -1;
}

label {
    display: block;
    margin: 14px 0 8px;
    font-size: 13px;
    font-weight: bold;
}

input, select, textarea {
    display: block;
    width: 100%;
    min-width: 0;
    padding: 13px;
    border: 1px solid var(--border);
    border-radius: 11px;
    outline: none;
    background: #fbfdff;
    color: var(--text);
    font: inherit;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(36, 166, 217, 0.12);
}

textarea {
    resize: vertical;
}

/* ---------- BUTTONS ---------- */

.primary-button, .secondary-button, .danger-button {
    min-height: 45px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    font-family: inherit;
}

.primary-button {
    color: white;
    background: linear-gradient(110deg, #174b91, #24a6d9);
    box-shadow: 0 8px 18px rgba(23, 75, 145, 0.18);
}

.secondary-button {
    color: var(--text);
    background: #edf2f9;
}

.danger-button {
    color: white;
    background: var(--danger);
}

.primary-button:active, .secondary-button:active, .danger-button:active {
    transform: scale(0.97);
}

.full-button {
    width: 100%;
    margin-top: 12px;
}

.text-button {
    border: 0;
    border-radius: 10px;
    background: #edf4ff;
    color: var(--primary);
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    font-family: inherit;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.form-error {
    display: none;
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 13px;
    line-height: 1.6;
}

.form-error.show {
    display: block;
}

.form-success, .status {
    display: none;
    margin: 12px 0 0;
    color: var(--success);
    font-size: 13px;
    line-height: 1.6;
}

.form-success.show, .status.visible {
    display: block;
}

.status.error, .form-error.show {
    color: var(--danger);
}

/* ---------- SEARCH BAR ---------- */

.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 13px;
    padding: 4px 6px 4px 14px;
    margin-bottom: 14px;
}

.search-bar input {
    border: 0;
    background: transparent;
    padding: 12px 4px;
    box-shadow: none;
}

.search-bar input:focus {
    box-shadow: none;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    font-family: inherit;
}

.chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ---------- DOCTOR CARDS ---------- */

.doctor-list {
    display: grid;
    gap: 12px;
}

.doctor-card {
    display: flex;
    gap: 13px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 15px;
    box-shadow: var(--shadow);
}

.doctor-avatar {
    width: 52px;
    height: 52px;
    flex-shrink: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, #d9eaff, #edf7ff);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 21px;
    font-weight: 800;
}

.doctor-info {
    flex: 1;
    min-width: 0;
}

.doctor-info h3 {
    font-size: 15px;
    margin-bottom: 3px;
}

.doctor-specialty {
    color: var(--accent);
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
}

.doctor-meta {
    color: var(--muted);
    font-size: 11.5px;
    line-height: 1.7;
}

.doctor-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: stretch;
}

.doctor-actions .primary-button,
.doctor-actions .secondary-button {
    min-height: 38px;
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
}

.rating {
    color: #e8a13c;
    font-weight: bold;
    font-size: 12px;
}

/* ---------- LIST CARDS (appointments etc.) ---------- */

.item-list {
    display: grid;
    gap: 12px;
}

.item-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.item-card h3 {
    font-size: 15px;
    margin-bottom: 5px;
}

.item-card p {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.7;
}

.item-card .row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
}

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 11px;
    font-weight: bold;
}

.badge.confirmed {
    background: #e2f6ec;
    color: var(--success);
}

.badge.completed {
    background: #eef2f7;
    color: var(--muted);
}

.badge.cancelled {
    background: #fdecee;
    color: var(--danger);
}

.badge.mode {
    background: #eaf3ff;
    color: var(--primary);
}

.empty-state {
    padding: 22px 14px;
    border: 1px dashed #cfdaea;
    border-radius: 14px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.8;
}

/* ---------- EMERGENCY ---------- */

.sos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 11px;
}

.sos-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 13px;
    border-radius: 15px;
    border: 1px solid var(--border);
    background: var(--surface);
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: transform 0.15s;
}

.sos-card:active {
    transform: scale(0.97);
}

.sos-card .sos-icon {
    font-size: 23px;
}

.sos-card b {
    font-size: 14px;
}

.sos-card span {
    color: var(--muted);
    font-size: 11px;
}

.sos-card .sos-number {
    color: var(--danger);
    font-size: 19px;
    font-weight: 800;
}

.sos-card.main {
    background: linear-gradient(130deg, #c53243, #e2545f);
    border: 0;
    color: white;
}

.sos-card.main span,
.sos-card.main .sos-number {
    color: #ffe3e6;
}

/* ---------- SETTINGS TOGGLES ---------- */

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 15px 2px;
    border-bottom: 1px solid #eef2f7;
}

.setting-row:last-child {
    border-bottom: 0;
}

.setting-row p {
    font-size: 13px;
    font-weight: bold;
    margin-bottom: 3px;
}

.setting-row small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.6;
}

.switch {
    position: relative;
    width: 48px;
    height: 27px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: #cfd9e6;
    border-radius: 999px;
    cursor: pointer;
    transition: 0.2s;
}

.switch .slider::before {
    content: "";
    position: absolute;
    width: 21px;
    height: 21px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(21px);
}

/* ---------- FAQ ---------- */

.faq-item {
    border-bottom: 1px solid #eef2f7;
    padding: 13px 2px;
}

.faq-item:last-child {
    border-bottom: 0;
}

.faq-item b {
    display: block;
    font-size: 13.5px;
    margin-bottom: 6px;
}

.faq-item p {
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.8;
}

/* ---------- BOTTOM NAV ---------- */

.bottom-nav {
    position: fixed;
    z-index: 10;
    bottom: 0;
    left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--border);
    box-shadow: 0 -5px 20px rgba(22, 57, 100, 0.04);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 0;
    border: none;
    background: transparent;
    color: #8c9aaf;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
}

.nav-item span {
    font-size: 22px;
    line-height: 1.2;
}

.nav-item small {
    font-size: 10px;
    font-weight: bold;
}

.nav-item.active {
    color: var(--primary);
}

/* ---------- RESPONSIVE ---------- */

@media (max-width: 560px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .doctor-card {
        flex-wrap: wrap;
    }

    .doctor-actions {
        flex-direction: row;
        width: 100%;
    }

    .doctor-actions .primary-button,
    .doctor-actions .secondary-button {
        flex: 1;
    }
}

/* Live doctor tracking (Blinkit-style) */
.live-banner {
    background: linear-gradient(90deg, #123c73, #2c6fbf);
    color: #fff;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
}
#liveMap .leaflet-tile-pane { opacity: 0.95; }

/* ============================================================
   RESPONSIVE — phone, tablet, laptop, MacBook, desktop
   (mobile-first upar wale styles; neeche screen-size enhancements)
   ============================================================ */

/* ---------- base polish: modern mobile browsers ---------- */
body {
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

.header {
    position: sticky;
    top: 0;
    z-index: 20;
    padding-top: calc(15px + env(safe-area-inset-top, 0px));
}

/* iOS Safari: focus par auto-zoom rokne ke liye 16px */
@supports (-webkit-touch-callout: none) {
    input, select, textarea {
        font-size: 16px;
    }
}

/* ---------- hover effects sirf wahan jahan pointer hai ---------- */
@media (hover: hover) and (pointer: fine) {
    .primary-button:hover,
    .secondary-button:hover,
    .login-btn:hover {
        filter: brightness(1.06);
    }

    .item-card:hover,
    .doctor-card:hover,
    .address-card:hover {
        box-shadow: 0 10px 28px rgba(22, 57, 100, 0.09);
        transform: translateY(-2px);
    }

    .item-card, .doctor-card, .address-card {
        transition: box-shadow 0.2s ease, transform 0.2s ease;
    }

    .nav-item:hover {
        color: var(--primary);
        background: #eef4ff;
    }

    a:hover {
        filter: brightness(1.1);
    }
}

/* ---------- TABLETS (768px+) ---------- */
@media (min-width: 768px) {
    .page {
        max-width: 920px;
        padding: 32px 32px 60px;
    }

    .header {
        padding: 18px 32px;
    }

    .page-title {
        font-size: 30px;
    }

    .panel {
        padding: 26px 28px;
    }

    /* cards 2-column me */
    .item-list,
    .address-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .item-list > .empty-state,
    .address-list > .empty-state {
        grid-column: 1 / -1;
    }

    .live-banner {
        font-size: 15px;
        padding: 14px 18px;
    }

    #liveMap {
        height: 320px;
    }
}

/* ---------- LAPTOP / DESKTOP / MACBOOK (1024px+) ---------- */
@media (min-width: 1024px) {
    body.has-nav {
        padding-bottom: 40px;
    }

    /* bottom-nav -> fixed LEFT SIDEBAR (dashboard look) */
    .bottom-nav {
        top: 0;
        bottom: auto;
        left: 0;
        right: auto;
        width: 236px;
        height: 100vh;
        height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        grid-template-columns: none;
        gap: 6px;
        padding: calc(96px + env(safe-area-inset-top, 0px)) 16px 24px;
        border-top: none;
        border-right: 1px solid var(--border);
        box-shadow: none;
        background: var(--surface);
        overflow-y: auto;
    }

    .nav-item {
        flex-direction: row;
        justify-content: flex-start;
        gap: 13px;
        padding: 13px 16px;
        border-radius: 13px;
    }

    .nav-item span {
        font-size: 20px;
        width: 26px;
        text-align: center;
    }

    .nav-item small {
        font-size: 13.5px;
    }

    .nav-item.active {
        background: #e8f0fe;
    }

    /* content sidebar ke right side me (sirf un pages par jinme sidebar hai;
       width:auto -> kabhi horizontal overflow nahi) */
    body.has-nav .page {
        width: auto;
        margin: 0 auto 0 236px;
        max-width: 1180px;
        padding: 36px 40px 70px;
    }

    .header {
        padding: 18px 32px;
    }

    .brand {
        font-size: 25px;
    }

    .page-title {
        font-size: 33px;
    }

    .panel {
        padding: 30px 32px;
        border-radius: 22px;
    }

    .item-card, .doctor-card {
        padding: 18px;
    }

    #liveMap {
        height: 380px;
    }

    /* forms desktop par thode spacious — but NOT full-screen wide */
    .form-grid {
        gap: 4px 18px;
    }

    .panel .form-grid,
    .panel form {
        max-width: 780px;
    }

    /* doctor cards 2-column desktop par */
    .doctor-list,
    .item-list,
    .address-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px;
    }

    .doctor-list > .empty-state,
    .item-list > .empty-state,
    .address-list > .empty-state {
        grid-column: 1 / -1;
    }

    .bottom-nav::-webkit-scrollbar {
        width: 6px;
    }

    .bottom-nav::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 999px;
    }
}

/* ---------- BIG DESKTOP / MONITORS (1440px+) ---------- */
@media (min-width: 1440px) {
    .doctor-list,
    .item-list,
    .address-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .page {
        max-width: 1400px;
    }
}

/* ---------- AVATARS (profile photos — har jagah DP) ---------- */
.nav-item .nav-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #e8f0fe center/cover no-repeat;
    color: var(--primary);
    font-size: 11px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.avatar-sm {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #eef4ff center/cover no-repeat;
    color: var(--primary);
    font-weight: 800;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    float: right;
    margin-left: 10px;
    margin-bottom: 4px;
    flex-shrink: 0;
}

.doctor-card .doctor-avatar,
#doctorAvatar {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* ===== R32: Visit OTP / SOS / Busy / Receipt ===== */
.visit-otp-show {
    display: block;
    margin: 10px 0 4px;
    padding: 10px 12px;
    border: 2px dashed var(--primary);
    border-radius: 12px;
    background: #eef4ff;
    font-size: 1rem;
}
.visit-otp-show b { font-size: 1.35rem; letter-spacing: 6px; margin-left: 4px; }
.visit-otp-show small { display: block; color: #4b5b73; margin-top: 2px; }
.visit-otp-box { flex-basis: 100%; width: 100%; margin-top: 8px; }
.visit-otp-box .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.visit-otp-input {
    width: 110px; min-height: 40px; font-size: 1.2rem; letter-spacing: 6px; text-align: center;
    border: 1px solid #c8d3e3; border-radius: 10px; padding: 6px 8px;
}
.visit-otp-btn { min-height: 40px; padding: 8px 14px; }
.sos-button {
    min-height: 36px; padding: 8px 14px; border: 0; border-radius: 10px;
    background: var(--danger); color: #fff; font-weight: 800; cursor: pointer;
}
.sos-button:active { transform: scale(0.97); }
.availability-chip { margin: 6px 0 0; font-weight: 700; font-size: 0.9rem; }
.availability-chip.busy { color: #b45309; }
.availability-chip.free { color: #15803d; }
.availability-toggle.is-busy { border-left: 4px solid #f59e0b; }
.availability-toggle.is-busy .availability-dot { background: #f59e0b; }

.receipt { max-width: 640px; margin: 0 auto; }
.receipt-head { text-align: center; border-bottom: 1px solid #e3e8f0; padding-bottom: 10px; margin-bottom: 12px; }
.receipt-head h1 { font-size: 1.25rem; margin: 6px 0 0; }
.receipt-brand { font-weight: 800; color: var(--primary); font-size: 1.1rem; }
.receipt-info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0 0 14px; }
.receipt-info dt { color: #5b6b82; }
.receipt-info dd { margin: 0; font-weight: 600; word-break: break-word; }
.receipt-table { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
.receipt-table td { padding: 8px 4px; border-bottom: 1px solid #edf1f6; }
.receipt-table td:last-child { text-align: right; }
.receipt-total td { font-weight: 800; font-size: 1.05rem; border-top: 2px solid #c8d3e3; }
.receipt-foot { font-size: 0.8rem; }
@media print {
    .no-print, .bottom-nav, .header { display: none !important; }
    body { background: #fff !important; }
    .receipt { box-shadow: none !important; border: 0 !important; }
}

/* R33: language */
.lang-auto-bar {
    position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
    z-index: 9999; background: #123c73; color: #fff; padding: 10px 14px; border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: .92rem; max-width: 92vw;
}
.lang-auto-bar a { color: #ffe08a; font-weight: 700; }
.lang-auto-bar button { background: transparent; border: 0; color: #fff; font-size: 1rem; margin-left: 6px; cursor: pointer; }
#languageSelect { width: 100%; min-height: 44px; }
