/* === NEW PATIENT PORTAL STYLES === */

/* --- General Layout & Typography --- */
body {
    background-color: #f8f9fa; /* A light grey background */
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.portal-splash {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, rgba(255,255,255,0.08), transparent 65%), #0a2540;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 9999;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.portal-splash.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.portal-splash-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem 3rem;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(10px);
}
.portal-splash-logo {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
}
.portal-splash-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.portal-splash-message {
    font-size: 1.15rem;
    letter-spacing: 0.02em;
}
.portal-splash-spinner {
    width: 48px;
    height: 48px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #00d2ff;
    animation: portal-spin 1s linear infinite;
}
@keyframes portal-spin {
    to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
    .portal-splash-spinner {
        animation: none;
    }
}

.portal-header {
    background: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.portal-header .header-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.portal-main {
    padding: 2rem 0;
}

.portal-welcome {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-color-dark);
    margin-bottom: 2rem;
}
body.lang-km {
    font-family: "Hanuman", serif;
    font-optical-sizing: auto;
    font-size: 1.12rem;
}
body.lang-km button,
body.lang-km input,
body.lang-km select,
body.lang-km textarea {
    font-family: "Hanuman", serif;
}
body.lang-km .portal-card h2 {
    font-size: 2.3rem;
}
body.lang-km .btn,
body.lang-km .bottom-nav .nav-item {
    font-size: 1.05rem;
}
body.lang-km .bottom-nav .nav-item i {
    font-size: 24px;
}
body.lang-km .facebook-embed,
body.lang-km .portal-card p,
body.lang-km .portal-card span:not([data-i18n]) {
    font-family: var(--font-family, 'Poppins', sans-serif);
}
.use-base-font {
    font-family: var(--font-family, 'Poppins', sans-serif) !important;
}
.welcome-hidden {
    display: none;
}

/* --- Responsive Grid Layout --- */
.portal-grid {
    display: grid;
    grid-template-columns: 1fr; /* Mobile: Single column */
    gap: 2rem;
}

@media (min-width: 992px) {
    .portal-grid {
        /* Desktop: Two columns, main is wider */
        grid-template-columns: 2fr 1fr;
    }
}

/* --- Mobile App Layout --- */
.mobile-app { display: none; }
.bottom-nav { display: none; }

@media (max-width: 768px) {
    /* Hide desktop grid on mobile */
    .portal-grid { display: none; }

    /* Show mobile app sections */
    .mobile-app { display: block; padding-bottom: 64px; }
    .mobile-page { display: none; }
    .mobile-page.active { display: block; }

    /* Fixed bottom navigation */
    .bottom-nav {
        display: flex;
        position: fixed;
        left: 0; right: 0; bottom: 0;
        height: 88px;
        background: #fff;
        border-top: 1px solid #e6e6e6;
        box-shadow: 0 -2px 6px rgba(0,0,0,0.05);
        z-index: 100;
    }
    .bottom-nav .nav-item {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1rem;
        color: #444;
        background: none;
        border: none;
        cursor: pointer;
        transition: color 0.2s ease, transform 0.2s ease;
        gap: 0.4rem;
    }
    .bottom-nav .nav-item i {
        font-size: 26px;
    }
    .bottom-nav .nav-item.active {
        color: var(--primary-color);
        transform: translateY(-4px);
    }
}

/* Mobile profile card */
.mobile-profile-card {
    text-align: center;
    padding-top: 2.5rem;
}
.mobile-profile-avatar-wrapper {
    width: 120px;
    height: 120px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    border: 4px solid rgba(0,0,0,0.05);
    padding: 4px;
    background: linear-gradient(145deg, rgba(0, 144, 214, 0.15), rgba(0, 218, 183, 0.15));
    display: flex;
    align-items: center;
    justify-content: center;
}
.mobile-profile-avatar {
    width: 112px;
    height: 112px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center;
    display: block;
    margin: 0 auto;
    border: 1px solid #e6e6e6;
    background: #f5f5f5;
}
.mobile-profile-name {
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 0.7rem;
}
.mobile-profile-email {
    color: var(--text-color-light);
    margin-bottom: 1.25rem;
}
.mobile-profile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.btn-block {
    width: 100%;
}

/* --- Card Styling --- */
.portal-card {
    background-color: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    height: fit-content;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 0.5rem;
}

.portal-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.portal-card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eee;
}

/* --- Next Appointment Card (Prominent) --- */
.portal-card.prominent {
    border-left: 5px solid var(--primary-color);
}
.appointment-details {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.appointment-details .icon {
    font-size: 2.5rem;
    color: var(--primary-color);
}
.appointment-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-color-dark);
}
.appointment-info p {
    font-size: 1.1rem;
    color: var(--text-color-light);
    margin-top: 0.25rem;
}
.no-appointment-message {
    font-size: 1.1rem;
    color: var(--text-color-light);
}

/* --- Exercise Plan --- */
.exercise-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}
.exercise-item {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}
.exercise-item h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.exercise-item .notes {
    color: var(--text-color-light);
    margin-bottom: 1rem;
}
.exercise-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Big, clear buttons for exercises */
.btn-exercise {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}
.btn-exercise i {
    font-size: 1.2rem;
}
.btn-exercise.video {
    background-color: var(--secondary-color);
    color: #fff;
}
.btn-exercise.video:hover {
    background-color: #1a6a8f;
}
.btn-exercise.complete {
    background-color: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}
.btn-exercise.complete:hover {
    background-color: #dcfce7;
}
.btn-exercise.completed {
    background-color: #16a34a;
    color: #fff;
    cursor: not-allowed;
}

.exercise-video-wrapper {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    max-width: 100%;
    background: #000;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.exercise-video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* --- History & Info Lists --- */
.history-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.history-card {
    border: 1px solid #eef2f5;
    border-radius: 14px;
    padding: 1rem;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}
.history-card-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
}
.history-title {
    margin: 0;
    font-size: 1.05rem;
    color: var(--text-color-dark);
}
.history-date {
    margin: 0.15rem 0 0;
    color: var(--text-color-light);
    font-size: 0.9rem;
}
.status-chip {
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: capitalize;
    background: #eef2f7;
    color: var(--text-color-dark);
}
.status-chip.status-completed,
.status-chip.status-confirmed {
    background: rgba(22, 163, 74, 0.15);
    color: #15803d;
}
.status-chip.status-cancelled {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
}
.status-chip.status-pending,
.status-chip.status-scheduled {
    background: rgba(250, 204, 21, 0.25);
    color: #b45309;
}
.status-chip.status-paid {
    background: rgba(34, 197, 94, 0.18);
    color: #15803d;
}
.status-chip.status-unpaid,
.status-chip.status-overdue {
    background: rgba(248, 113, 113, 0.18);
    color: #b91c1c;
}
.history-meta {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.95rem;
}
.history-meta span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-color-dark);
}
.history-meta i {
    color: var(--primary-color);
}
.history-item.empty {
    border: 1px dashed #cfd8f3;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    color: var(--text-color-light);
}
.patient-info-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.patient-info-list li {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    color: var(--text-color-dark);
}
.patient-info-list span {
    color: var(--text-color-light);
}
.invoice-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.invoice-row {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 1rem;
    background: #ffffff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.invoice-row-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
}
.invoice-row-header .invoice-id {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}
.invoice-row-header .invoice-date {
    margin: 0;
    color: var(--text-color-light);
    font-size: 0.9rem;
}
.invoice-row-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}
.invoice-row-meta .amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}
.invoice-actions {
    display: flex;
    justify-content: flex-end;
}
.invoice-actions .download-invoice {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    padding: 0.45rem 0.85rem;
}

#clinic-contact-info p {
    font-size: 1rem;
    color: var(--text-color-light);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- Mobile Password Modal --- */
.mobile-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 300;
}
.mobile-modal.open {
    display: flex;
}
.mobile-modal-content {
    width: 100%;
    max-width: 420px;
    background: #ffffff;
    border-radius: 20px;
    padding: 2rem 1.5rem 1.75rem;
    position: relative;
    box-shadow: 0 25px 45px rgba(15, 23, 42, 0.15);
}
.mobile-modal-content h3 {
    margin-top: 0;
    margin-bottom: 1rem;
}
.mobile-modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: transparent;
    font-size: 1.1rem;
    color: var(--text-color-light);
    cursor: pointer;
}

/* --- Language Switcher --- */
.language-switcher {
    position: relative;
}
.icon-button {
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--text-color-dark);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}
.icon-button:hover {
    background: rgba(0,0,0,0.1);
}
.language-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.15);
    padding: 0.25rem;
    display: none;
    min-width: 140px;
    z-index: 200;
}
.language-menu.open {
    display: block;
}
.language-menu button {
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.65rem 0.75rem;
    text-align: left;
    font-size: 0.95rem;
    color: var(--text-color-dark);
    border-radius: 8px;
}
.language-menu button:hover {
    background: rgba(0, 144, 214, 0.08);
}
.language-menu button.active {
    background: rgba(0, 144, 214, 0.15);
    font-weight: 600;
}


/* --- Change Password Card --- */
.change-password-form .form-group {
    margin-bottom: 0.75rem;
}
.change-password-form input[type="password"] {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.change-password-form .error-message {
    color: var(--red-accent);
    margin: 0.5rem 0 0.75rem;
}
.hint-text {
    margin-top: 0.75rem;
    color: var(--text-color-light);
    font-size: 0.9rem;
}

#exercise-progress-chart {
    max-width: 100%;
    height: 220px;
}

/* --- Skeleton Loaders for Better UX --- */
.skeleton-loader {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite linear;
    border-radius: 8px;
    height: 70px;
    margin-bottom: 1rem;
}
.skeleton-loader.large-loader {
    height: 120px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Patient Login Page --- */
body.login-page {
    position: relative;
    background: radial-gradient(circle at top, rgba(0, 148, 255, 0.12), transparent 45%), #eef5ff;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
body.login-page::before,
body.login-page::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.65;
    z-index: 0;
}
body.login-page::before {
    width: 480px;
    height: 480px;
    background: rgba(20, 110, 255, 0.25);
    top: -140px;
    right: -120px;
}
body.login-page::after {
    width: 360px;
    height: 360px;
    background: rgba(0, 210, 255, 0.25);
    bottom: -120px;
    left: -60px;
}
.login-header {
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 2;
}
.login-header .nav-links a {
    font-weight: 500;
    color: #0f172a;
}

.login-main {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 2rem 0;
    position: relative;
    z-index: 1;
}

.login-section {
    width: 100%;
    background: none;
}

.login-layout {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 0 1.5rem;
}

.login-duo {
    display: flex;
    width: 100%;
    max-width: 960px;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.18);
    background: rgba(255, 255, 255, 0.04);
}

.login-info {
    background: linear-gradient(135deg, #0f172a, #0b3b7a);
    color: #fff;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}
.login-info h1 {
    font-size: 2.25rem;
    margin-bottom: 0.75rem;
}
.login-info .lead {
    font-size: 1rem;
    line-height: 1.5;
    opacity: 0.9;
    margin-bottom: 0;
}

.login-container {
    flex: 1;
    background: #fff;
    padding: 2rem;
    border-left: 1px solid #edf2ff;
    animation: floatUp 0.6s ease forwards;
}
.login-container h2 {
    text-align: center;
    color: var(--primary-blue);
}
.login-container p {
    text-align: center;
    color: var(--dark-text);
    margin-bottom: 1.5rem;
}
.login-container .form-group {
    margin-bottom: 1rem;
}
.login-container .form-group label {
    font-weight: 500;
    color: #0f172a;
    display: block;
    margin-bottom: 0.35rem;
}
.login-container .form-group input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-size: 1rem;
}
.login-container .form-group input:focus {
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(0, 51, 160, 0.12);
    outline: none;
}
.login-container .btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-container .spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-blue);
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
    display: none;
}
.login-container .btn.loading .spinner {
    display: inline-block;
}
.login-container .btn.loading .button-text {
    display: none;
}
.login-support {
    margin-top: 1.5rem;
    font-size: 0.92rem;
    color: #64748b;
}

@media (max-width: 640px) {
    body.login-page {
        min-height: auto;
        height: auto;
        overflow: auto;
    }
    .login-layout {
        padding: 0 1rem;
    }
    .login-duo {
        flex-direction: column;
        box-shadow: none;
        border-radius: 16px;
    }
    .login-info {
        border-radius: 16px 16px 0 0;
        text-align: center;
    }
    .login-container {
        border-left: none;
        border-top: 1px solid #edf2ff;
        border-radius: 0 0 16px 16px;
        box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
    }
    .login-info {
        padding: 2rem;
        text-align: center;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes floatUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.card-title-with-icon {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.card-title-with-icon i {
    color: var(--primary-color);
    font-size: 1.25rem;
}

.facebook-embed {
    width: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    background: linear-gradient(135deg, #f8fbff 0%, #eef5ff 100%);
}
.facebook-embed .fb-page {
    width: 100% !important;
}
.facebook-embed .fb-page > span,
.facebook-embed .fb-page iframe {
    width: 100% !important;
}
