/* Southern Smiles - Shared Styles */
html { scroll-behavior: smooth; }
body { -webkit-font-smoothing: antialiased; }

/* Skip-to-main-content link — visible only when keyboard-focused */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1000;
    padding: 0.75rem 1.25rem;
    background: #1A5FA8;
    color: #fff;
    font-weight: 600;
    border-radius: 0 0 0.5rem 0;
    text-decoration: none;
}
.skip-link:focus { left: 0; outline: 3px solid #7DC242; outline-offset: 2px; }

/* Visible focus ring for keyboard users on interactive elements */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid #7DC242;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Scroll reveal animation */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity 0.7s ease, transform 0.7s ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* Honor user motion preferences — disable scroll-reveal and smooth scroll */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

/* Brand button */
.btn-brand {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.875rem 1.75rem; background: #29ABE2; color: #fff;
    font-family: 'Inter', system-ui, sans-serif; font-weight: 600; font-size: 0.875rem;
    border-radius: 0.5rem; text-decoration: none;
    transition: all 0.3s ease;
}
.btn-brand:hover { background: #1A5FA8; box-shadow: 0 10px 25px rgba(41,171,226,0.3); transform: translateY(-2px); }

/* Outline brand button */
.btn-outline-brand {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.875rem 1.75rem; border: 2px solid #29ABE2; color: #29ABE2;
    font-family: 'Inter', system-ui, sans-serif; font-weight: 600; font-size: 0.875rem;
    border-radius: 0.5rem; text-decoration: none;
    transition: all 0.3s ease;
}
.btn-outline-brand:hover { background: #29ABE2; color: #fff; transform: translateY(-2px); }

/* White button */
.btn-white {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.875rem 1.75rem; background: #fff; color: #1A3A5C;
    font-family: 'Inter', system-ui, sans-serif; font-weight: 600; font-size: 0.875rem;
    border-radius: 0.5rem; text-decoration: none;
    transition: all 0.3s ease;
}
.btn-white:hover { box-shadow: 0 10px 25px rgba(0,0,0,0.1); transform: translateY(-2px); }

/* Section label — uses brand-dark (#1A5FA8) instead of brand (#29ABE2)
   so the small uppercase text passes WCAG AA contrast (6.47:1) on white. */
.section-label {
    display: inline-block; font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.2em;
    text-transform: uppercase; color: #1A5FA8; margin-bottom: 0.75rem;
}

/* Page card */
.page-card {
    background: #fff; border-radius: 1rem; padding: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05); border: 1px solid #f3f4f6;
    transition: all 0.3s ease;
}
.page-card:hover { box-shadow: 0 10px 40px rgba(0,0,0,0.08); transform: translateY(-4px); }

/* Logo on dark backgrounds - brighten for contrast */
.nav-logo-img, .footer-logo-img {
    filter: brightness(1.3) contrast(1.05);
    transition: filter 0.5s ease, height 0.5s ease;
}

/* Section label on dark backgrounds */
.section-label-light {
    display: inline-block; font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.75rem; font-weight: 700; letter-spacing: 0.2em;
    text-transform: uppercase; color: #7DC242; margin-bottom: 0.75rem;
}

/* FAQ accordion */
.faq-open .faq-answer { max-height: 500px; }

/* Shared loading spinner — used while async data loads in the portal/admin */
.ss-spinner {
    display: inline-block;
    width: 1.25rem; height: 1.25rem;
    border: 2px solid #d1d5db;
    border-top-color: #29ABE2;
    border-radius: 50%;
    animation: ss-spin 0.7s linear infinite;
}
.ss-loading {
    display: flex; align-items: center; justify-content: center;
    gap: 0.625rem; padding: 2rem 1rem;
    color: #4A6B8A; font-size: 0.95rem;
}
@keyframes ss-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .ss-spinner { animation: none; border-top-color: #29ABE2; }
}

/* Portal tabs — elderly-friendly */
.portal-tab {
    padding: 0.875rem 1.5rem; font-size: 1.05rem; font-weight: 600;
    color: #3a5a78; border-bottom: 3px solid transparent;
    transition: all 0.2s; white-space: nowrap; cursor: pointer;
    background: none; outline: none;
}
.portal-tab:hover { color: #1A3A5C; }
.portal-tab.active { color: #1A5FA8; border-bottom-color: #29ABE2; font-weight: 700; }

/* Status badges — elderly-friendly */
.status-badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.35rem 0.875rem; border-radius: 9999px;
    font-size: 0.875rem; font-weight: 700; text-transform: capitalize;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-proposed { background: #f3e8ff; color: #6b21a8; }
.status-confirmed { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-completed { background: #dbeafe; color: #1e40af; }

/* Auth form input — elderly-friendly */
.auth-input {
    width: 100%; padding: 0.875rem 1.125rem; border-radius: 0.75rem;
    border: 2px solid #d1d5db; outline: none;
    font-size: 1.0625rem; font-family: 'Inter', system-ui, sans-serif;
    transition: all 0.2s; color: #1A3A5C;
}
.auth-input::placeholder { color: #94a3b8; font-size: 1rem; }
.auth-input:focus { border-color: #29ABE2; box-shadow: 0 0 0 3px rgba(41,171,226,0.2); }

/* Page card without hover lift (for forms) — elderly-friendly */
.page-card-static {
    background: #fff; border-radius: 1rem; padding: 2.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06); border: 1px solid #e5e7eb;
}

/* ============ Messaging ============ */
.msg-list { display: flex; flex-direction: column; gap: 0.5rem; }

.msg-bubble {
    max-width: 80%; padding: 0.875rem 1.125rem; border-radius: 1rem;
    font-size: 1rem; line-height: 1.6; word-wrap: break-word;
    position: relative;
}
.msg-bubble.patient {
    align-self: flex-end; background: #29ABE2; color: #fff;
    border-bottom-right-radius: 0.25rem;
}
.msg-bubble.staff {
    align-self: flex-start; background: #f3f4f6; color: #1A3A5C;
    border-bottom-left-radius: 0.25rem;
}
.msg-time {
    font-size: 0.8125rem; margin-top: 0.25rem; opacity: 0.7;
}
.msg-bubble.patient .msg-time { text-align: right; color: rgba(255,255,255,0.7); }
.msg-bubble.staff .msg-time { text-align: left; color: #4A6B8A; }

/* Conversation list item */
.convo-item {
    display: flex; align-items: center; gap: 0.875rem;
    padding: 1rem 1.25rem; border-radius: 0.75rem;
    cursor: pointer; transition: all 0.15s; border: 1px solid #e5e7eb;
    background: #fff;
}
.convo-item:hover { background: #f8fafc; border-color: #e2e8f0; }
.convo-item.unread { border-left: 3px solid #29ABE2; background: #f0f9ff; }
.convo-item.active { border-color: #29ABE2; background: #f0f9ff; }

/* Unread dot */
.unread-dot {
    width: 0.5rem; height: 0.5rem; border-radius: 50%;
    background: #29ABE2; flex-shrink: 0;
}

/* Conversation status badges */
.convo-status-open { background: #d1fae5; color: #065f46; }
.convo-status-resolved { background: #dbeafe; color: #1e40af; }
.convo-status-closed { background: #f3f4f6; color: #6b7280; }

/* Admin message panel layout */
.msg-panel {
    display: grid; grid-template-columns: 320px 1fr;
    height: calc(100vh - 200px); min-height: 500px;
    border: 1px solid #e5e7eb; border-radius: 1rem;
    overflow: hidden; background: #fff;
}
.msg-panel-sidebar {
    border-right: 1px solid #e5e7eb; display: flex;
    flex-direction: column; overflow: hidden;
}
.msg-panel-chat {
    display: flex; flex-direction: column; overflow: hidden;
}
.msg-panel-messages {
    flex: 1; overflow-y: auto; padding: 1.25rem;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.msg-panel-input {
    border-top: 1px solid #e5e7eb; padding: 0.75rem 1rem;
    display: flex; gap: 0.5rem; align-items: flex-end;
}
.msg-panel-input textarea {
    flex: 1; resize: none; border: 1px solid #e5e7eb;
    border-radius: 0.75rem; padding: 0.625rem 0.875rem;
    font-size: 0.875rem; font-family: 'Inter', system-ui, sans-serif;
    outline: none; max-height: 100px; line-height: 1.4;
}
.msg-panel-input textarea:focus {
    border-color: #29ABE2; box-shadow: 0 0 0 3px rgba(41,171,226,0.15);
}

@media (max-width: 768px) {
    .msg-panel { grid-template-columns: 1fr; height: auto; min-height: auto; }
    .msg-panel-sidebar { max-height: 300px; }
    .msg-panel.show-chat .msg-panel-sidebar { display: none; }
    .msg-panel.show-chat .msg-panel-chat { display: flex; }
    .msg-panel:not(.show-chat) .msg-panel-chat { display: none; }
}

/* Portal elderly-friendly responsive + mobile fixes */
@media (max-width: 640px) {
    .portal-tab { padding: 0.75rem 0.875rem; font-size: 0.9rem; }
    .page-card-static { padding: 1.5rem; }
    .auth-input { font-size: 1rem; padding: 0.8rem 1rem; }
    .convo-item { padding: 0.75rem; gap: 0.5rem; }
    .btn-brand, .btn-outline-brand, .btn-white {
        padding: 0.75rem 1.25rem;
        font-size: 0.8125rem;
    }
    .page-card {
        padding: 1.25rem;
    }
}
