/* ===================================
   Legal Page Styles
   Mirrors Emily app's legal screen structure (hero, chip nav,
   numbered sections, info cards, retention table, callouts) using
   demipharm brand colors.
   =================================== */

/* Minimal page header (used when there's no site chrome) */
.legal-mini-header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.legal-mini-header-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.legal-mini-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    color: var(--text-dark);
}

.legal-mini-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9375rem;
}

.legal-mini-brand-text {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--text-dark);
    line-height: 1.2;
}

.legal-mini-brand-sub {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
    margin-top: 2px;
}

.legal-mini-lang {
    position: relative;
}

.legal-mini-lang-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.legal-mini-lang-toggle:hover { border-color: var(--primary-color); }

.legal-mini-lang-toggle svg {
    width: 14px;
    height: 14px;
    transition: transform var(--transition-fast);
}

.legal-mini-lang-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    min-width: 160px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: all var(--transition-fast);
    z-index: 200;
}

.legal-mini-lang.open .legal-mini-lang-dropdown {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.legal-mini-lang.open .legal-mini-lang-toggle svg { transform: rotate(180deg); }

.legal-mini-lang-option {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.875rem;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background var(--transition-fast);
}

.legal-mini-lang-option:hover { background: var(--bg-light); }

.legal-mini-lang-option.active {
    background: rgba(0, 48, 135, 0.06);
    color: var(--primary-color);
    font-weight: 600;
}

.legal-mini-footer {
    text-align: center;
    padding: 2rem 1rem 3rem;
    color: var(--text-light);
    font-size: 0.75rem;
}

/* Layout shell */
.legal-page {
    background: var(--bg-light);
    padding: var(--spacing-lg) 0 var(--spacing-2xl);
}

.legal-container {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* ── Hero ───────────────────────────────────────────────────────────── */
.legal-hero {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.legal-hero-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-md);
    background: rgba(0, 48, 135, 0.08);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.legal-hero-icon svg {
    width: 28px;
    height: 28px;
}

.legal-hero-title {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.2;
    margin-bottom: 0.75rem;
}

.legal-hero-intro {
    font-size: 0.9375rem;
    color: var(--text-gray);
    line-height: 1.7;
    white-space: pre-wrap;
}

.legal-hero-meta {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
    font-size: 0.8125rem;
    color: var(--text-light);
}

.legal-hero-meta strong {
    color: var(--text-dark);
    font-weight: 600;
}

/* ── Chip nav (sticky) ──────────────────────────────────────────────── */
.legal-chips {
    position: sticky;
    top: 64px;
    z-index: 50;
    background: var(--bg-light);
    margin: 0 calc(var(--spacing-md) * -1);
    padding: 0.75rem var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.legal-chips::-webkit-scrollbar { display: none; }

.legal-chips-row {
    display: flex;
    gap: 0.5rem;
    width: max-content;
    padding: 0;
}

.legal-chip {
    flex-shrink: 0;
    padding: 0.5rem 0.875rem;
    border-radius: 999px;
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-gray);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.legal-chip:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.legal-chip.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ── Numbered sections ──────────────────────────────────────────────── */
.legal-section {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem 1.5rem;
    margin-bottom: 1rem;
    scroll-margin-top: 130px;
}

.legal-section-head {
    display: flex;
    gap: 0.875rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}

.legal-section-num {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.875rem;
}

.legal-section-title {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.35;
    padding-top: 0.25rem;
}

.legal-section-body {
    color: var(--text-gray);
    font-size: 0.9375rem;
    line-height: 1.7;
}

.legal-section-body p {
    margin-bottom: 0.875rem;
    white-space: pre-wrap;
}

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

.legal-section-body strong {
    color: var(--text-dark);
    font-weight: 600;
}

.legal-subhead {
    font-family: var(--font-heading);
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 1.25rem 0 0.5rem;
}

.legal-subhead:first-child { margin-top: 0; }

/* ── Bullet list ────────────────────────────────────────────────────── */
.legal-bullets {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legal-bullets li {
    position: relative;
    padding-left: 1.25rem;
    color: var(--text-gray);
    font-size: 0.9375rem;
    line-height: 1.7;
}

.legal-bullets li::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 0.7em;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-color);
}

.legal-bullets--negative li::before {
    background: #dc2626;
}

/* ── Data row card (icon + label + desc + required badge) ───────────── */
.legal-data-group {
    margin-bottom: 1rem;
}

.legal-data-group + .legal-data-group { margin-top: 1rem; }

.legal-data-group-title {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.625rem;
}

.legal-data-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legal-data-row {
    display: flex;
    gap: 0.875rem;
    padding: 0.875rem;
    background: var(--bg-gray);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.legal-data-row-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(0, 48, 135, 0.08);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.legal-data-row-icon svg {
    width: 18px;
    height: 18px;
}

.legal-data-row-text {
    flex: 1;
    min-width: 0;
}

.legal-data-row-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9375rem;
    line-height: 1.3;
    margin-bottom: 0.125rem;
}

.legal-data-row-required {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.legal-data-row-desc {
    font-size: 0.8125rem;
    color: var(--text-gray);
    line-height: 1.5;
}

/* ── Provider card ──────────────────────────────────────────────────── */
.legal-provider {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.legal-provider-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 0.75rem;
    margin-bottom: 0.625rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid var(--border-light);
}

.legal-provider-name {
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.9375rem;
}

.legal-provider-meta {
    font-size: 0.75rem;
    color: var(--text-light);
}

.legal-provider-row {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 0.75rem;
    font-size: 0.8125rem;
    line-height: 1.55;
    margin-bottom: 0.375rem;
}

.legal-provider-row:last-child { margin-bottom: 0; }

.legal-provider-row-label {
    font-weight: 600;
    color: var(--text-dark);
}

.legal-provider-row-value {
    color: var(--text-gray);
}

/* ── Retention table ────────────────────────────────────────────────── */
.legal-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: white;
}

.legal-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.legal-table th {
    text-align: left;
    padding: 0.75rem 0.875rem;
    background: var(--bg-gray);
    font-family: var(--font-heading);
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.legal-table td {
    padding: 0.75rem 0.875rem;
    color: var(--text-gray);
    line-height: 1.5;
    vertical-align: top;
    border-bottom: 1px solid var(--border-light);
}

.legal-table tr:last-child td { border-bottom: none; }

.legal-table td:first-child {
    font-weight: 600;
    color: var(--text-dark);
}

/* ── Callout card ───────────────────────────────────────────────────── */
.legal-callout {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid;
    margin: 0.75rem 0;
}

.legal-callout-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.legal-callout-icon svg { width: 18px; height: 18px; }

.legal-callout-body {
    flex: 1;
    font-size: 0.875rem;
    line-height: 1.6;
}

.legal-callout-title {
    font-family: var(--font-heading);
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.legal-callout--info {
    background: rgba(0, 48, 135, 0.04);
    border-color: rgba(0, 48, 135, 0.2);
    color: var(--text-gray);
}

.legal-callout--info .legal-callout-icon {
    background: rgba(0, 48, 135, 0.1);
    color: var(--primary-color);
}

.legal-callout--info .legal-callout-title { color: var(--primary-color); }

.legal-callout--warning {
    background: rgba(217, 119, 6, 0.05);
    border-color: rgba(217, 119, 6, 0.25);
    color: var(--text-gray);
}

.legal-callout--warning .legal-callout-icon {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

.legal-callout--warning .legal-callout-title { color: #b45309; }

.legal-callout--danger {
    background: rgba(220, 38, 38, 0.05);
    border-color: rgba(220, 38, 38, 0.25);
    color: var(--text-gray);
}

.legal-callout--danger .legal-callout-icon {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
}

.legal-callout--danger .legal-callout-title { color: #dc2626; }

.legal-callout--success {
    background: rgba(0, 166, 81, 0.05);
    border-color: rgba(0, 166, 81, 0.25);
    color: var(--text-gray);
}

.legal-callout--success .legal-callout-icon {
    background: rgba(0, 166, 81, 0.12);
    color: var(--secondary-dark);
}

.legal-callout--success .legal-callout-title { color: var(--secondary-dark); }

/* ── Contact card ───────────────────────────────────────────────────── */
.legal-contact {
    background: linear-gradient(135deg, rgba(0, 48, 135, 0.04), rgba(0, 166, 81, 0.04));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
}

.legal-contact-row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-gray);
    line-height: 1.5;
}

.legal-contact-row svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--primary-color);
    margin-top: 2px;
}

.legal-contact-row a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.legal-contact-row a:hover { text-decoration: underline; }

/* ── Doc switcher (related docs) ────────────────────────────────────── */
.legal-related {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.legal-related-title {
    font-family: var(--font-heading);
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.legal-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.legal-related-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--text-dark);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.legal-related-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.legal-related-card svg {
    width: 20px;
    height: 20px;
    color: var(--primary-color);
    flex-shrink: 0;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .legal-section { padding: 1.25rem 1rem; }
    .legal-hero { padding: 1.5rem 1.25rem; }
    .legal-provider-row {
        grid-template-columns: 1fr;
        gap: 0.125rem;
    }
    .legal-provider-row-label { font-size: 0.75rem; color: var(--text-light); }
}
