/* ============================================
   Patient Portal - Mobile-First Styles
   Clean, calming design for patients
   ============================================ */

:root {
    --portal-primary: #1B72BE;
    --portal-primary-hover: #155FA3;
    --portal-primary-light: #DBEAFE;
    --portal-primary-dark: #1E3A5F;
    --portal-bg: #EFF6FF;
    --portal-card-bg: #FFFFFF;
    --portal-text: #1F2937;
    --portal-text-muted: #6B7280;
    --portal-border: #E5E7EB;
    --portal-navbar-bg: #155FA3;
    --portal-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --portal-radius: 10px;
}

/* ============================================
   BASE
   ============================================ */

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background-color: var(--portal-bg);
    color: var(--portal-text);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.portal-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--portal-bg);
    z-index: 9999;
}

.portal-logo-loading {
    width: 120px;
    height: auto;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.portal-login-wrapper {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 50%, #BFDBFE 100%);
}

.portal-login-card {
    background: #fff;
    border-radius: var(--portal-radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}

.portal-login-logo {
    width: 80px;
    height: auto;
}

.portal-login-card .form-control {
    border-radius: 8px;
    padding: 10px 14px;
    border-color: var(--portal-border);
    font-size: 15px;
}

.portal-login-card .form-control:focus {
    border-color: var(--portal-primary);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.portal-login-card .btn-primary {
    background-color: var(--portal-primary);
    border-color: var(--portal-primary);
    border-radius: 8px;
    padding: 10px 16px;
    font-weight: 500;
    font-size: 15px;
}

.portal-login-card .btn-primary:hover {
    background-color: var(--portal-primary-hover);
    border-color: var(--portal-primary-hover);
}

.portal-login-card .btn-outline-primary {
    border-color: var(--portal-primary);
    color: var(--portal-primary);
    border-radius: 8px;
    padding: 12px 16px;
}

.portal-login-card .btn-outline-primary:hover {
    background-color: var(--portal-primary);
    color: #fff;
}

/* ============================================
   NAVBAR
   ============================================ */

.portal-navbar {
    background: var(--portal-navbar-bg);
    padding: 8px 16px;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.portal-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
}

.portal-nav-logo {
    height: 28px;
    width: auto;
    filter: brightness(0) invert(1);
}

.portal-brand-text {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
}

.portal-nav-links {
    display: flex;
    gap: 4px;
    margin-left: 24px;
}

.portal-nav-link {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 150ms ease;
    white-space: nowrap;
}

.portal-nav-link:hover,
.portal-nav-link.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

.portal-user-name {
    color: rgba(255, 255, 255, 0.9);
    font-size: 13px;
    font-weight: 500;
}

/* Mobile Nav */
.portal-mobile-nav {
    background: var(--portal-navbar-bg);
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.portal-mobile-link {
    display: block;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    transition: background 150ms;
}

.portal-mobile-link:hover,
.portal-mobile-link.active {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.portal-content {
    padding-bottom: 24px;
}

/* ============================================
   CARDS
   ============================================ */

.portal-card {
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    background: var(--portal-card-bg);
    overflow: hidden;
}

.portal-card .card-header {
    background: #F9FAFB;
    border-bottom: 1px solid var(--portal-border);
    padding: 10px 16px;
}

.portal-card .card-body {
    padding: 12px 16px;
}

.portal-clickable {
    cursor: pointer;
    transition: box-shadow 150ms ease, transform 150ms ease;
}

.portal-clickable:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

/* ============================================
   STAT CARDS (Dashboard)
   ============================================ */

.portal-stat-card {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--portal-shadow);
    cursor: pointer;
    transition: all 150ms ease;
}

.portal-stat-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.portal-stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 8px;
}

.portal-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1;
    color: var(--portal-text);
}

.portal-stat-label {
    font-size: 11px;
    color: var(--portal-text-muted);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ============================================
   QUICK LINKS (Dashboard)
   ============================================ */

.portal-quick-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--portal-text);
    font-size: 12px;
    font-weight: 500;
    transition: background 150ms;
    text-align: center;
}

.portal-quick-link i {
    font-size: 24px;
    color: var(--portal-primary);
}

.portal-quick-link:hover {
    background: var(--portal-primary-light);
    color: var(--portal-primary-dark);
}

/* ============================================
   FILTER TABS
   ============================================ */

.portal-filter-tabs .nav-link {
    color: var(--portal-text-muted);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 20px;
    background: transparent;
    border: 1px solid var(--portal-border);
}

.portal-filter-tabs .nav-link.active {
    background: var(--portal-primary);
    color: #fff;
    border-color: var(--portal-primary);
}

/* ============================================
   PROFILE
   ============================================ */

.portal-profile-field {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border-bottom: 1px solid #F3F4F6;
    gap: 8px;
}

.portal-profile-field:last-child {
    border-bottom: none;
}

.portal-profile-field label {
    font-size: 12px;
    color: var(--portal-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 80px;
    flex-shrink: 0;
}

.portal-profile-field span {
    font-size: 13px;
    color: var(--portal-text);
    text-align: right;
    word-break: break-word;
}

/* ============================================
   VITALS TABLE
   ============================================ */

.portal-vitals-table {
    font-size: 13px;
}

.portal-vitals-table thead th {
    background: #F9FAFB;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--portal-text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--portal-border);
    padding: 8px;
}

.portal-vitals-table tbody td {
    padding: 8px;
    vertical-align: middle;
}

/* ============================================
   CLINICAL NOTE CONTENT
   ============================================ */

.portal-note-content {
    font-size: 14px;
    line-height: 1.7;
}

.portal-note-content h1,
.portal-note-content h2,
.portal-note-content h3,
.portal-note-content h4 {
    color: var(--portal-primary-dark);
    margin-top: 16px;
    margin-bottom: 8px;
}

.portal-note-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.portal-note-content table td,
.portal-note-content table th {
    border: 1px solid var(--portal-border);
    padding: 6px 10px;
    font-size: 13px;
}

/* ============================================
   TOAST OVERRIDES
   ============================================ */

.toast-danger { border-left: 4px solid #EF4444; }
.toast-success { border-left: 4px solid #10B981; }
.toast-warning { border-left: 4px solid #F59E0B; }
.toast-info { border-left: 4px solid #3B82F6; }

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary {
    background-color: var(--portal-primary) !important;
    border-color: var(--portal-primary) !important;
}

.btn-primary:hover {
    background-color: var(--portal-primary-hover) !important;
    border-color: var(--portal-primary-hover) !important;
}

.btn-outline-primary {
    color: var(--portal-primary) !important;
    border-color: var(--portal-primary) !important;
}

.btn-outline-primary:hover {
    background-color: var(--portal-primary) !important;
    color: #fff !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .portal-stat-card {
        padding: 12px 8px;
    }

    .portal-stat-value {
        font-size: 20px;
    }

    .portal-stat-label {
        font-size: 10px;
    }

    .portal-stat-icon {
        width: 32px;
        height: 32px;
        font-size: 15px;
    }

    .portal-card .card-body {
        padding: 10px 12px;
    }

    .portal-profile-field {
        flex-direction: column;
        gap: 2px;
    }

    .portal-profile-field span {
        text-align: left;
    }

    .portal-login-card {
        padding: 24px 20px;
    }

    h5 {
        font-size: 1.1rem;
    }
}

@media (max-width: 576px) {
    .portal-content .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .portal-quick-link i {
        font-size: 20px;
    }

    .portal-quick-link {
        padding: 12px 6px;
        font-size: 11px;
    }
}

/* ============================================
   SCROLLBAR (subtle)
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* ============================================
   BILLING PAGE
   ============================================ */

#portalBalanceAmount {
    font-size: 36px;
    letter-spacing: -0.5px;
}

#portalStripeElement,
#portalInstallmentStripeElement {
    min-height: 50px;
    border-color: var(--portal-border);
    border-radius: 8px;
}

.installment-option {
    border-radius: 8px;
    font-size: 13px;
    padding: 8px 12px;
}

.installment-option.active {
    background-color: var(--portal-primary) !important;
    border-color: var(--portal-primary) !important;
}

#portalInstallmentPreview {
    border-radius: 8px;
    background: var(--portal-primary-light);
}

#portalInstallmentPreview .fw-semibold {
    font-size: 24px;
    color: var(--portal-primary-dark);
}

/* ============================================
   BOOKING PAGE
   ============================================ */

/* Booking layout — two columns on desktop */
.booking-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.booking-main {
    flex: 1;
    min-width: 0;
}
.booking-sidebar-wrap {
    width: 260px;
    flex-shrink: 0;
    position: sticky;
    top: 60px;
}

/* Day quick picks */
.booking-day-picks {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.booking-day-pick {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--portal-border);
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: var(--portal-text-muted);
    cursor: pointer;
    transition: all 150ms ease;
}
.booking-day-pick:hover {
    border-color: var(--portal-primary);
    color: var(--portal-primary);
}
.booking-day-pick.active {
    background: var(--portal-primary);
    color: #fff;
    border-color: var(--portal-primary);
}

/* Date nav */
.booking-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--portal-border);
    background: var(--portal-card-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--portal-text-muted);
    transition: all 150ms ease;
}
.booking-nav-btn:hover:not(:disabled) {
    border-color: var(--portal-primary);
    color: var(--portal-primary);
}
.booking-nav-btn:disabled, .booking-nav-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}
.booking-date-display {
    font-size: 15px;
    font-weight: 600;
    color: var(--portal-text);
    min-width: 180px;
    text-align: center;
}

/* Slot grid */
.booking-slot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}
.booking-slot-btn {
    background: var(--portal-card-bg);
    border: 1.5px solid var(--portal-border);
    border-radius: 8px;
    padding: 10px 6px;
    text-align: center;
    cursor: pointer;
    transition: all 150ms ease;
    font-size: 14px;
    font-weight: 500;
    color: var(--portal-text);
}
.booking-slot-btn:hover {
    border-color: var(--portal-primary);
    background: var(--portal-primary-light);
    color: var(--portal-primary-dark);
}
.booking-slot-btn.selected {
    border-color: var(--portal-primary);
    background: var(--portal-primary);
    color: #fff;
}
.booking-slot-btn.selected .booking-slot-period {
    color: rgba(255,255,255,0.8);
}
.booking-slot-period {
    font-size: 10px;
    text-transform: uppercase;
    color: var(--portal-text-muted);
    letter-spacing: 0.3px;
    margin-top: 2px;
}

/* Time section labels */
.booking-time-section {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    color: var(--portal-text-muted);
    margin-bottom: 8px;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.booking-time-section:first-child { margin-top: 0; }
.booking-time-section i { font-size: 14px; }

/* Confirm bar (sidebar/bottom bar) */
.booking-confirm-bar {
    background: var(--portal-card-bg);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    box-shadow: var(--portal-shadow);
    padding: 16px;
}
.booking-summary-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--portal-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--portal-primary);
    margin-bottom: 12px;
}

/* Book button */
.booking-book-btn {
    background: var(--portal-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 14px;
    transition: all 150ms ease;
}
.booking-book-btn:hover { background: var(--portal-primary-hover); color: #fff; }
.booking-book-btn:disabled { background: #D1D5DB; cursor: not-allowed; color: #fff; }

.booking-btn-outline {
    background: transparent;
    color: var(--portal-primary);
    border: 1.5px solid var(--portal-primary);
    border-radius: 8px;
    padding: 10px 24px;
    font-weight: 600;
    font-size: 14px;
    transition: all 150ms ease;
}
.booking-btn-outline:hover { background: var(--portal-primary-light); }

/* Confirmation/Success modal overlay */
.booking-confirm-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 200ms ease;
}
.booking-confirm-overlay.show { opacity: 1; }
.booking-confirm-modal {
    background: var(--portal-card-bg);
    border-radius: 12px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    overflow: hidden;
}
.booking-confirm-header {
    background: var(--portal-primary-light);
    padding: 20px 24px;
    text-align: center;
}
.booking-check-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--portal-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 10px;
}
.booking-confirm-body { padding: 20px 24px; }
.booking-confirm-detail {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 0;
}
.booking-confirm-detail i { color: var(--portal-primary); font-size: 18px; margin-top: 1px; }
.booking-confirm-detail .label { font-size: 11px; text-transform: uppercase; color: var(--portal-text-muted); letter-spacing: 0.3px; }
.booking-confirm-detail .value { font-weight: 600; font-size: 14px; }
.booking-confirm-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--portal-border);
    display: flex;
    gap: 10px;
}

/* Mobile: fixed bottom bar */
@media (max-width: 991px) {
    .booking-layout { display: block; }
    .booking-main { padding-bottom: 110px; }
    .booking-sidebar-wrap {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        z-index: 999;
        padding: 0;
    }
    .booking-confirm-bar {
        border-radius: 12px 12px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
        border-bottom: none;
        padding: 14px 16px;
    }
    .booking-sidebar-extras { display: none; }
    .booking-slot-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
}
@media (min-width: 992px) {
    .booking-mobile-summary { display: none; }
}

/* Small phones */
@media (max-width: 576px) {
    .booking-day-picks {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .booking-day-picks::-webkit-scrollbar { display: none; }
    .booking-day-pick { white-space: nowrap; flex-shrink: 0; font-size: 11px; padding: 5px 10px; }
    .booking-slot-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .booking-slot-btn { padding: 8px 4px; font-size: 13px; }
    .booking-date-display { min-width: 120px; font-size: 13px; }
    .booking-confirm-modal { margin: 10px; }
}

/* File Viewer Modal */
.fv-modal-content { height: 100%; display: flex; flex-direction: column; }
.fv-modal-header { background: #f8f9fa; border-bottom: 1px solid #e9ecef; padding: 12px 20px; flex-shrink: 0; }
.fv-modal-title { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80%; }
.fv-modal-body { flex: 1; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f0f0f0; }
.fv-iframe { width: 100%; height: 100%; border: none; }
.fv-image-container { width: 100%; height: 100%; overflow: auto; display: flex; align-items: center; justify-content: center; padding: 16px; }
.fv-image { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; box-shadow: 0 2px 12px rgba(0,0,0,0.1); }
.fv-video-container { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; background: #000; }
.fv-video { max-width: 100%; max-height: 100%; }
.fv-text-container { width: 100%; height: 100%; overflow: auto; padding: 20px; background: #fff; }
.fv-text-content { margin: 0; font-family: monospace; font-size: 13px; line-height: 1.6; white-space: pre-wrap; word-wrap: break-word; }
.fv-loading, .fv-error, .fv-unsupported { text-align: center; padding: 60px 20px; }

/* ===========================================================================
   Profile avatar system — portal copy.
   ---------------------------------------------------------------------------
   These rules exist in clinic-side styles.css too. Duplicated here on 2026-05
   because _PatientPortalLayout.cshtml does not load styles.css, and without
   these constraints AvatarUtils renders <img> elements at their natural size
   (which produced a screen-sized image on the Profile page).
   Future cleanup: extract to a shared wwwroot/css/avatars.css and include in
   both layouts so this duplication can be deleted.
   =========================================================================== */
.profile-avatar {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
    font-weight: 700;
    color: #fff;
    line-height: 1;
}
/* Belt-and-braces: any <img> inside MUST stay inside the circle, regardless
   of how AvatarUtils builds the inner markup. */
.profile-avatar img,
.profile-avatar .profile-avatar-img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}
.profile-avatar .profile-avatar-initials {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
}

/* Sizes */
.avatar-sm { width: 32px; height: 32px; font-size: 13px; }
.avatar-md { width: 40px; height: 40px; font-size: 15px; }
.avatar-lg { width: 60px; height: 60px; font-size: 22px; }
.avatar-xl { width: 80px; height: 80px; font-size: 28px; box-shadow: 0 4px 16px rgba(0,0,0,.15); }

/* Initials background colors — hardcoded because portal CSS doesn't define
   --primary-color / --secondary-color the way clinic does. */
.avatar-initials-patient  { background: #14b8a6; } /* teal — patient */
.avatar-initials-provider { background: #6366f1; } /* indigo — provider; inline style wins when provider.Color is set */
