:root {
    /* Color Palette */
    --primary-color: #4f46e5;
    /* Indigo 600 */
    --primary-hover: #4338ca;
    /* Indigo 700 */
    --primary-light: #e0e7ff;
    /* Indigo 100 */

    --secondary-color: #64748b;
    /* Slate 500 */
    --secondary-hover: #475569;
    /* Slate 600 */
    --secondary-light: #f1f5f9;
    /* Slate 100 */

    --success-color: #10b981;
    /* Emerald 500 */
    --success-hover: #059669;
    /* Emerald 600 */
    --success-light: #d1fae5;
    /* Emerald 100 */

    --error-color: #ef4444;
    /* Red 500 */
    --error-light: #fee2e2;

    --bg-color: #f8fafc;
    /* Slate 50 */
    --card-bg: #ffffff;

    --text-main: #0f172a;
    /* Slate 900 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #94a3b8;
    /* Slate 400 */

    --border-color: #e2e8f0;
    /* Slate 200 */
    --border-focus: #818cf8;
    /* Indigo 400 */

    /* Shadows & Radii */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-focus: 0 0 0 4px var(--primary-light);

    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 1rem;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
    /* Less padding for mobile */
    position: relative;
    overflow-x: hidden;
}

/* Background Design Elements */
.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background:
        radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.04), transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.04), transparent 50%);
    z-index: -1;
}

/* Utility Classes */
.d-none {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-light {
    color: var(--text-light);
}

.w-100 {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-3 {
    margin-top: 0.75rem;
}

.mt-4 {
    margin-top: 1rem;
}

.mt-5 {
    margin-top: 1.5rem;
}

.mb-0 {
    margin-bottom: 0;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.pb-4 {
    padding-bottom: 1rem;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

h4 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}


/* Main Container */
.portal-container {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    /* Narrower for mobile portal */
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    align-self: flex-start;
    margin-top: 1rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.portal-header {
    margin-bottom: 1.5rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    border-radius: 20px;
}

.portal-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-footer-text {
    color: var(--text-light);
    font-size: 0.9rem;
}

.login-signup-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.login-signup-link:hover {
    text-decoration: underline;
}

/* Login Form */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-size: 0.9rem;
}

.required {
    color: var(--error-color);
}

.hint {
    color: var(--text-light);
    font-size: 0.8rem;
    display: block;
    margin-top: 0.25rem;
}

.input-wrapper {
    position: relative;
}

.input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
}

.input-wrapper input,
.input-wrapper select {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 2.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: var(--transition);
    outline: none;
}

.input-wrapper input:focus,
.input-wrapper select:focus {
    background-color: var(--card-bg);
    border-color: var(--border-focus);
    box-shadow: var(--shadow-focus);
}

.error-message {
    background-color: var(--error-light);
    color: var(--error-color);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-icon-only {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.25rem;
}

.btn-icon-only:hover {
    color: var(--text-main);
    background-color: var(--secondary-light);
    border-radius: 50%;
}

/* Dashboard Cards */
.patient-greeting h2 {
    font-size: 1.25rem;
    color: var(--text-main);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-info {
    background: #e0f2fe;
    color: #0284c7;
}

.badge-success {
    background: var(--success-light);
    color: var(--success-hover);
}

.action-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--card-bg);
    transition: var(--transition);
    cursor: pointer;
}

.action-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.emergency-card {
    background: #fef2f2;
    border-color: #fecaca;
    flex-direction: column;
    align-items: flex-start;
    padding: 1.5rem;
}

.emergency-card .card-icon {
    background: #fee2e2;
    color: var(--error-color);
    width: 48px;
    height: 48px;
    font-size: 1.5rem;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 0.5rem;
}

.emergency-card h3 {
    color: #b91c1c;
    margin-bottom: 0.25rem;
    border-bottom: none;
}

.emergency-card p {
    color: #7f1d1d;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

/* Quick Actions Grid */
.quick-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.action-card.small {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 1.25rem 0.5rem;
    gap: 0.5rem;
}

.action-card.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-color);
}

.action-card.small .card-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
}

.card-icon.blue {
    background: #e0f2fe;
    color: #0284c7;
}

.card-icon.green {
    background: #dcfce7;
    color: #16a34a;
}

.card-icon.purple {
    background: #f3e8ff;
    color: #9333ea;
}

.card-icon.gray {
    background: #f1f5f9;
    color: #64748b;
}

.action-card.small h4 {
    font-size: 0.85rem;
    margin-bottom: 0;
}

.action-card.small p {
    font-size: 0.75rem;
    color: var(--text-light);
}


/* Info Section */
.info-section h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-link {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.edit-link:hover {
    color: var(--primary-color);
}

.info-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--card-bg);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.info-value {
    font-weight: 600;
    color: var(--text-main);
    font-size: 0.95rem;
    text-align: right;
    max-width: 60%;
    line-height: 1.3;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: flex-end;
    /* Bottom sheet on mobile */
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    max-height: 85vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 1.5rem;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius-lg);
        transform: scale(0.95);
        max-width: 450px;
    }

    .modal-overlay.active .modal-content {
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.modal-header h3 {
    margin-bottom: 0;
    border: none;
    padding: 0;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
}

.close-modal:hover {
    color: var(--text-main);
}

.alert {
    padding: 1rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.4;
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}

.alert-warning {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.alert-warning i {
    color: #d97706;
    margin-top: 0.15rem;
}

/* Vitals BP Input Row */
.bp-input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.bp-input {
    width: 45%;
}

/* Chat Modal Styles */
.chat-modal-content {
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    /* Don't exceed screen height */
}

.chat-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background-color: var(--bg-color);
}

.chat-msg {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.chat-msg.patient {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.doctor {
    align-self: flex-start;
    background-color: white;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.chat-msg .time {
    display: block;
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 0.25rem;
    text-align: right;
}

.chat-msg.doctor .time {
    color: var(--text-light);
}

.chat-input-area {
    display: flex;
    gap: 0.5rem;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    background-color: white;
}

.chat-input-area input {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.chat-input-area input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-input-area button {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== Appointment Booking ===== */
.card-icon.amber {
    background: #fef3c7;
    color: #d97706;
}

.appointment-date-group {
    margin-bottom: 1.25rem;
}

.appointment-date-label {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    padding: 0.35rem 0.75rem;
    background: var(--secondary-light);
    border-radius: 8px;
    display: inline-block;
}

.appointment-slots-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.appointment-slot-btn {
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.2s;
}

.appointment-slot-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.current-booking-card {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.current-booking-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #059669;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.current-booking-card .booking-detail {
    font-size: 1rem;
    font-weight: 700;
    color: #065f46;
}

.current-booking-card .booking-sub {
    font-size: 0.8rem;
    color: #047857;
    margin-top: 0.15rem;
}

.btn-danger-outline {
    padding: 0.4rem 0.75rem;
    border: 1px solid #fca5a5;
    border-radius: 8px;
    background: white;
    color: #dc2626;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-danger-outline:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

.no-slots-message {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.no-slots-message i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.75rem;
    color: var(--text-light);
}

/* Help link to onboarding tour */
.portal-help-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 0.5rem 0;
    transition: color 0.2s;
}

.portal-help-link:hover {
    color: var(--primary);
}

.portal-help-link i {
    font-size: 1rem;
}