/**
 * portal-redesign.css
 *
 * Shared design system for the client portal.
 * Conversion-optimised, mobile-first layout.
 * Typography: Plus Jakarta Sans.
 */

/* =============================================================================
   Design Tokens
   ============================================================================= */

:root {
    --brand: #194f90;
    --brand-deep: #0e3461;
    --brand-light: #e8f0fa;
    --brand-subtle: #f4f7fb;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #5a6578;
    --text-muted: #8d95a3;
    --border: #e2e6ec;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --warning-bg: #fffbeb;
    --warning-border: #f59e0b;
    --warning-text: #92400e;
    --radius: 14px;
    --font-body: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

/* =============================================================================
   Reset & Base
   ============================================================================= */

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* overscroll-behavior left to default so pull-to-refresh works on mobile.
       Signature pad pages prevent scroll during drawing via JS touch handlers. */
}

body {
    font-family: var(--font-body);
    color: var(--text);
    background: var(--brand-subtle);
    min-height: 100vh;
    line-height: 1.5;
}

a {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}

a:hover {
    opacity: 0.8;
}

/* =============================================================================
   Page Container
   ============================================================================= */

.portal-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
}

/* =============================================================================
   Header Bar
   ============================================================================= */

.header-bar {
    background: var(--brand);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-logo {
    height: 28px;
    width: auto;
    filter: brightness(0) invert(1);
    opacity: 0.95;
}

.header-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    border-radius: 4px;
}
.header-logo-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 18px;
}

.header-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    transition: background 120ms ease;
    letter-spacing: 0.01em;
}
.header-back-link:hover,
.header-back-link:focus-visible {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.header-back-link svg {
    width: 15px;
    height: 15px;
}

.header-trust {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.75);
    letter-spacing: 0.02em;
}

.header-trust svg {
    width: 13px;
    height: 13px;
    opacity: 0.8;
}

/* On the narrowest screens, drop "Secure" so the back link stays prominent */
@media (max-width: 419px) {
    .header-trust { display: none; }
    .header-back-link { padding: 6px 8px; }
}

/* =============================================================================
   Main Card
   ============================================================================= */

.main-card {
    background: var(--surface);
    margin: 16px;
    border-radius: var(--radius);
    box-shadow:
        0 1px 3px rgba(25, 79, 144, 0.06),
        0 8px 32px rgba(25, 79, 144, 0.08);
    overflow: hidden;
}

/* =============================================================================
   Greeting
   ============================================================================= */

.greeting {
    padding: 28px 24px 0;
}

.greeting h1 {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    color: var(--text);
    letter-spacing: -0.02em;
}

.greeting h1 .name {
    color: var(--brand);
}

.greeting p {
    margin-top: 8px;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* =============================================================================
   Action Area
   ============================================================================= */

.action-area {
    padding: 24px;
}

/* =============================================================================
   Buttons
   ============================================================================= */

.btn-primary {
    width: 100%;
    min-height: 58px;
    border: none;
    border-radius: 12px;
    background: var(--brand);
    color: #fff;
    font-family: var(--font-body);
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 12px rgba(25, 79, 144, 0.25);
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.btn-primary:hover {
    background: var(--brand-deep);
    box-shadow: 0 4px 20px rgba(25, 79, 144, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 6px rgba(25, 79, 144, 0.2);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-primary svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.btn-secondary {
    width: 100%;
    min-height: 50px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.btn-submit {
    width: 100%;
    min-height: 58px;
    border: none;
    border-radius: 12px;
    background: var(--success);
    color: #fff;
    font-family: var(--font-body);
    font-size: 16.5px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 12px rgba(22, 163, 74, 0.25);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.btn-submit::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.btn-submit:hover {
    background: #15803d;
    box-shadow: 0 4px 20px rgba(22, 163, 74, 0.35);
    transform: translateY(-1px);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-submit svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* =============================================================================
   Divider
   ============================================================================= */

.divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 16px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.divider span {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* =============================================================================
   Accepted Types (micro-copy)
   ============================================================================= */

.accepted-types {
    text-align: center;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 16px;
    letter-spacing: 0.01em;
}

.accepted-types strong {
    font-weight: 500;
    color: var(--text-secondary);
}

/* =============================================================================
   Collapsible Tips
   ============================================================================= */

.tips-section {
    border-top: 1px solid var(--border);
    margin: 0 24px;
}

.tips-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 16px 0;
    font-family: var(--font-body);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.15s;
}

.tips-toggle:hover {
    color: var(--brand);
}

.tips-toggle-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tips-toggle svg {
    width: 16px;
    height: 16px;
}

.tips-chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.25s ease;
    color: var(--text-muted);
}

.tips-content {
    display: none;
    padding-bottom: 20px;
}

.tips-section.open .tips-content {
    display: block;
}

.tips-section.open .tips-chevron {
    transform: rotate(180deg);
}

.tip-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 0;
    font-size: 13.5px;
    line-height: 1.45;
    color: var(--text-secondary);
}

.tip-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--brand-light);
    color: var(--brand);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.tip-icon svg {
    width: 10px;
    height: 10px;
}

/* =============================================================================
   Callout Boxes
   ============================================================================= */

.callout {
    margin: 0 24px 16px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 13.5px;
    line-height: 1.5;
}

.callout-brand {
    background: var(--brand-light);
    border-left: 3px solid var(--brand);
    color: var(--text-secondary);
}

.callout-brand strong {
    color: var(--text);
    font-weight: 600;
}

.callout-warning {
    background: var(--warning-bg);
    border-left: 3px solid var(--warning-border);
    color: var(--warning-text);
}

.callout-warning strong {
    font-weight: 600;
}

/* =============================================================================
   Signature Pad
   ============================================================================= */

.sig-pad-wrapper {
    padding: 0 24px 4px;
}

.sig-pad-label {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.sig-pad-container {
    position: relative;
}

.sig-pad-canvas {
    width: 100%;
    height: 160px;
    border: 2px dashed var(--border);
    border-radius: 10px;
    background: #fafbfc;
    display: block;
    touch-action: none;
}

.sig-pad-canvas.has-signature {
    border-style: solid;
    border-color: var(--brand);
}

.sig-clear-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-family: var(--font-body);
    transition: color 0.15s, opacity 0.15s;
    opacity: 0.7;
}

.sig-clear-btn:hover {
    color: var(--text);
    opacity: 1;
}

/* =============================================================================
   Legal Text
   ============================================================================= */

.legal-text {
    padding: 0 24px;
    margin-bottom: 4px;
}

.legal-text p {
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.legal-text p:last-child {
    margin-bottom: 0;
}

.legal-text .muted {
    font-size: 11.5px;
    color: var(--text-muted);
}

/* =============================================================================
   Error State
   ============================================================================= */

.error-box {
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-left: 4px solid var(--error);
    border-radius: 10px;
    padding: 16px;
    margin: 0 24px 24px;
}

.error-box h2 {
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 6px;
}

.error-box p {
    font-size: 13.5px;
    color: #7f1d1d;
    line-height: 1.5;
    margin-bottom: 6px;
}

.error-box ul {
    margin: 8px 0 0 20px;
    font-size: 13px;
    color: #7f1d1d;
    line-height: 1.6;
}

/* =============================================================================
   Success State
   ============================================================================= */

.success-state {
    padding: 48px 24px;
    text-align: center;
}

.success-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--success-bg);
    color: var(--success);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
}

.success-icon svg {
    width: 36px;
    height: 36px;
}

.success-state h2 {
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.success-state p {
    font-size: 14.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* =============================================================================
   File Preview (Upload ID)
   ============================================================================= */

.file-preview-area {
    border: 2px solid var(--success);
    border-radius: 12px;
    padding: 0;
    text-align: center;
    background: var(--success-bg);
    overflow: hidden;
}

.file-preview-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
}

.file-preview-header svg {
    width: 20px;
    height: 20px;
}

.preview-container {
    max-width: 100%;
    max-height: 160px;
    overflow: hidden;
    border-top: 1px solid rgba(22, 163, 74, 0.15);
    border-bottom: 1px solid rgba(22, 163, 74, 0.15);
}

.preview-container img {
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
    margin: 0 auto;
    display: block;
}

.file-info {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.file-info-name {
    color: var(--text-secondary);
    font-weight: 500;
    word-break: break-all;
}

.file-info-change {
    color: var(--brand);
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    background: none;
    border: none;
    font-family: var(--font-body);
    font-size: 13px;
    flex-shrink: 0;
    margin-left: 12px;
}

/* =============================================================================
   Progress Bar (Upload)
   ============================================================================= */

.progress-bar {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-bar-fill {
    height: 100%;
    background: var(--brand);
    width: 0%;
    transition: width 0.3s ease;
}

/* =============================================================================
   Manual Email Fields (Confirm Instructions)
   ============================================================================= */

.manual-fields {
    padding: 0 24px 16px;
}

.manual-field {
    margin-bottom: 10px;
}

.manual-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}

.manual-field-row {
    display: flex;
    gap: 6px;
}

.manual-field input,
.manual-field textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 16px; /* >= 16px prevents iOS Safari auto-zoom on focus */
    font-family: var(--font-body);
    color: var(--text);
    background: #f8f9fb;
    line-height: 1.4;
}

.manual-field textarea {
    resize: vertical;
    min-height: 120px;
}

.copy-btn {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    padding: 9px 12px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-body);
    white-space: nowrap;
    transition: all 0.15s;
}

.copy-btn:hover {
    background: var(--brand-light);
    color: var(--brand);
}

/* =============================================================================
   Trust Footer
   ============================================================================= */

.trust-footer {
    padding: 20px 24px 28px;
    text-align: center;
}

.trust-badges {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 10px;
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--text-muted);
}

.trust-badge svg {
    width: 14px;
    height: 14px;
    color: var(--brand);
    opacity: 0.6;
}

.sra-badge {
    margin: 10px 0;
}

.trust-footer p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.5;
    opacity: 0.7;
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */

.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}

.toast {
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 320px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: var(--success);
    color: white;
}

.toast-error {
    background: var(--error);
    color: white;
}

/* =============================================================================
   Loading Indicator
   ============================================================================= */

.loading-indicator {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =============================================================================
   Utility: Hidden
   ============================================================================= */

.hidden {
    display: none !important;
}

/* =============================================================================
   Screen-reader only
   ============================================================================= */

/* =============================================================================
   Utility classes (used by JS-generated HTML)
   ============================================================================= */

.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-3 { margin-top: 0.75rem; }
.mb-2 { margin-bottom: 0.5rem; }
.rounded { border-radius: 0.25rem; }
.text-sm { font-size: 0.875rem; }
.text-primary { color: var(--brand); }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-red-500 { color: #ef4444; }
.text-red-700 { color: #b91c1c; }
.text-red-800 { color: #991b1b; }
.bg-white { background-color: #fff; }
.border { border: 1px solid var(--border); }
.border-red-200 { border-color: #fecaca; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.w-16 { width: 4rem; }
.h-16 { height: 4rem; }
.space-y-1 > * + * { margin-top: 0.25rem; }

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