/* Fixed pale tints: each of these paints its own ground, so the role variables
   solved for the surface OUTSIDE them are wrong inside them. Re-pointing here covers
   the whole subtree - setting `color` alone would fix only the text sitting directly
   on the panel and leave every child reading --sp-fg-* still resolving the outer
   ground, which is how bug 079 stayed broken while looking fixed. */
.account-error-message,
.account-success-message,
.account-toast,
.badge-paused,
.btn-secondary:hover,
.toggle-slider,
.toggle-slider::after {
    --sp-fg-text: #212529;
    --sp-fg-muted: #4d5761;
    --sp-fg-link: #0a55c0;
    --sp-fg-accent: #7a4f00;
    --sp-fg-error: #b3261e;
    --sp-fg-warning: #7a4f00;
    --sp-fg-success: #1d6a2a;
    --sp-fg-edge: #14477d;
}

/* Account Page Styles (S-024) — Mobile-first */

.account-page {
    max-width: 600px;
    margin: 0 auto;
    padding: 1rem;
    font-family: var(--sp-font-family, inherit);
    color: var(--sp-fg-text);
}

/* Header */
.account-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.account-header h1 {
    font-size: 1.5rem;
    color: var(--sp-fg-text);
    margin: 0;
}

.account-logout-link {
    background: none;
    border: none;
    color: var(--sp-fg-link);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.5rem;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
}

/* Toast notification */
.account-toast {
    background: #d4edda;
    color: #155724;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    transition: opacity 0.3s ease;
}

.account-toast.is-dismissing {
    opacity: 0;
}

/* Sections */
.account-section {
    margin-bottom: 2rem;
}

.account-section h2 {
    font-size: 1.1rem;
    color: var(--sp-fg-text);
    margin-bottom: 0.75rem;
}

/* Tappable rows */
.account-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    min-height: 44px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: inherit;
    border-radius: 8px;
    transition: background 0.15s ease;
}

.account-row:hover {
    background: var(--sp-surface-color, #f8f9fa);
}

.account-row-content {
    flex: 1;
    min-width: 0;
}

.account-row-primary {
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.account-row-secondary {
    font-size: 0.875rem;
    color: var(--sp-fg-muted);
    margin: 0 0 0.125rem;
}

.chevron {
    font-size: 1.25rem;
    color: var(--sp-fg-muted);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

/* Badges */
.badge-paused {
    background: #fef3c7;
    color: #92400e;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    display: inline-block;
}

/* Appointment cards */
.appointment-card {
    padding: 1rem;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.appointment-card-past {
    opacity: 0.8;
}

.appointment-info {
    margin-bottom: 0.75rem;
}

.appointment-date {
    font-weight: 600;
    margin: 0 0 0.25rem;
}

.appointment-service,
.appointment-location,
.appointment-provider {
    font-size: 0.875rem;
    color: var(--sp-fg-muted);
    margin: 0 0 0.125rem;
}

.appointment-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Empty states */
.account-empty-state {
    color: var(--sp-fg-muted);
    font-style: italic;
    margin-bottom: 1rem;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    min-height: 48px;
    background: var(--sp-primary-color, #1976d2);
    color: var(--sp-fg-button-label);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-weight: 500;
    transition: background 0.15s ease;
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    min-height: 44px;
    min-width: 44px;
    background: var(--sp-surface-color, #f8f9fa);
    color: var(--sp-fg-text);
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
}

/* Touch target minimum */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Payment methods placeholder */
.account-loading-placeholder {
    padding: 1rem;
    color: var(--sp-fg-muted);
    font-size: 0.875rem;
}

/* CTA section */
.account-cta-section {
    margin: 2rem 0;
}

/* Footer */
.account-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    text-align: center;
    font-size: 0.8rem;
    color: var(--sp-fg-muted);
}

.open-in-new-tab {
    display: none;
    margin-bottom: 0.5rem;
}

.account-branding {
    margin: 0;
}

/* Back link */
.account-back-link {
    display: inline-flex;
    align-items: center;
    color: var(--sp-fg-link);
    text-decoration: none;
    font-size: 0.875rem;
    min-height: 44px;
    margin-bottom: 1rem;
}

.account-back-link:hover {
    text-decoration: underline;
}

/* Form elements */
.account-field-group {
    margin-bottom: 1.25rem;
}

.account-field-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.account-input {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-sizing: border-box;
    min-height: 44px;
    transition: border-color 0.15s ease;
}

.account-input:focus {
    outline: none;
    border-color: var(--sp-fg-link);
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

.account-field-error {
    display: block;
    color: var(--sp-fg-error);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

.account-readonly-group {
    margin-bottom: 1.25rem;
    padding: 0.75rem;
    background: var(--sp-surface-color, #f8f9fa);
    border-radius: 8px;
}

.account-form-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

/* Error / success messages */
.account-error-message {
    background: #f8d7da;
    color: #842029;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.account-success-message {
    background: #d4edda;
    color: #155724;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.account-help-text {
    font-size: 0.875rem;
    color: var(--sp-fg-muted);
    margin-top: 1rem;
}

/* Login container */
.account-login-container {
    max-width: 400px;
    margin: 2rem auto;
}

.account-login-container h1 {
    margin-bottom: 1.5rem;
    color: var(--sp-fg-text);
}

/* Communication preferences */
.account-pref-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
}

.account-pref-section h2 {
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.account-pref-description {
    font-size: 0.875rem;
    color: var(--sp-fg-muted);
    margin-bottom: 0.75rem;
}

.account-pref-readonly {
    font-size: 0.875rem;
    color: var(--sp-fg-muted);
    font-style: italic;
}

/* Toggle switch (CSS-only) */
.toggle-switch {
    display: flex;
    align-items: center;
    cursor: pointer;
    min-height: 44px;
    user-select: none;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    background: #ccc;
    border-radius: 13px;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--sp-primary-color, #1976d2);
}

.toggle-switch input:checked + .toggle-slider::after {
    transform: translateX(22px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.3);
}

.toggle-label {
    margin-left: 0.75rem;
    font-size: 0.875rem;
}

.account-toggle-row {
    margin-bottom: 0.5rem;
}

/* Pause-all visual state */
.account-pref-section.is-paused {
    opacity: 0.5;
    pointer-events: none;
}

/* Opt-out page */
.account-optout-page {
    max-width: 480px;
}

.account-optout-detail {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--sp-surface-color, #f8f9fa);
    border-radius: 8px;
}

.account-optout-upsell {
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* Details/summary for past appointments */
.account-section details summary {
    cursor: pointer;
    list-style: none;
}

.account-section details summary::-webkit-details-marker {
    display: none;
}

.account-section details summary::before {
    content: "\25B6";
    display: inline-block;
    margin-right: 0.5rem;
    transition: transform 0.2s ease;
    font-size: 0.75rem;
}

.account-section details[open] summary::before {
    transform: rotate(90deg);
}

/* Payment methods loaded via AJAX */
.payment-method-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid #eee;
    font-size: 0.875rem;
}

.payment-method-item:last-child {
    border-bottom: none;
}

.payment-method-brand {
    font-weight: 600;
    margin-right: 0.5rem;
    text-transform: capitalize;
}

.payment-method-expiry {
    color: var(--sp-fg-muted);
    margin-left: auto;
}

/* Tablet/desktop */
@media (min-width: 768px) {
    .account-page {
        padding: 2rem;
    }

    .btn-primary {
        width: auto;
    }

    .appointment-actions {
        flex-direction: row;
    }

    .account-form-actions {
        flex-direction: row;
    }
}
