/* ============================================================
   ConTrack AI · Terms & Conditions / Privacy Policy modal
   Shown once per account: after signing up, and at sign in
   until the agreement is recorded on the backend.
   ============================================================ */

.terms-overlay {
    font-family: "DM Sans", sans-serif;
    font-size: 14px;
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(26, 26, 26, 0.62);
    backdrop-filter: blur(2px);
    animation: termsFadeIn .22s ease both;
}

.terms-overlay[hidden] {
    display: none;
}

.terms-modal {
    display: flex;
    flex-direction: column;
    width: min(660px, 100%);
    max-height: min(90vh, 860px);
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    animation: termsRise .32s cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes termsFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes termsRise {
    from { opacity: 0; transform: translateY(18px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ───────────────────────────────────────────────── */
.terms-head {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 28px 16px;
    border-bottom: 1px solid #e6e6e6;
}

.terms-head h2 {
    flex: 1;
    margin: 0;
    font-family: "Playfair Display", serif;
    font-size: 20px;
    font-weight: 700;
    color: #7A0C0C;
    line-height: 1.35;
}

.terms-close {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: none;
    box-shadow: none;
    letter-spacing: normal;
    color: #8a8a8a;
    cursor: pointer;
    filter: none;
    transition: color .18s ease, background .18s ease;
}

.terms-close:hover {
    filter: none;
    background: #f4eaea;
    color: #7A0C0C;
}

.terms-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(228, 193, 156, 0.65);
}

.terms-close svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.1;
    stroke-linecap: round;
}

/* ── Scrolling body ───────────────────────────────────────── */
.terms-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 28px 20px;
}

.terms-intro {
    margin: 0 0 18px;
    font-size: 14px;
    color: #333;
    line-height: 1.6;
}

.terms-section + .terms-section {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid #ececec;
}

.terms-section h3 {
    margin: 0 0 10px;
    font-family: "Playfair Display", serif;
    font-size: 16px;
    font-weight: 700;
    color: #a9161c;
}

.terms-section ul {
    margin: 0;
    padding-left: 20px;
    list-style: disc;
}

.terms-section li {
    margin-bottom: 7px;
    font-size: 14px;
    color: #3d3d3d;
    line-height: 1.55;
}

.terms-section li:last-child {
    margin-bottom: 0;
}

.terms-body::-webkit-scrollbar {
    width: 9px;
}

.terms-body::-webkit-scrollbar-thumb {
    border-radius: 9px;
    background: #e3c6c8;
}

.terms-body::-webkit-scrollbar-thumb:hover {
    background: #cfa4a8;
}

/* ── Footer: agreement + action ───────────────────────────── */
.terms-foot {
    flex-shrink: 0;
    padding: 16px 28px 20px;
    border-top: 1px solid #e6e6e6;
    background: #fff;
}

.terms-agree {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 14px;
    color: #3d3d3d;
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
}

.terms-agree input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    accent-color: #7A0C0C;
    cursor: pointer;
}

.terms-agree em {
    font-style: normal;
    font-weight: 600;
    color: #a9161c;
}

.terms-submit {
    width: 100%;
    margin-top: 14px;
    padding: 13px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #7A0C0C, #991B1B);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .3px;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(122, 12, 12, 0.26);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: filter .08s ease, transform .08s ease, box-shadow .08s ease, opacity .18s ease;
}

.terms-submit:hover:not(:disabled) {
    filter: none;
}

.terms-submit:active:not(:disabled),
.terms-submit.is-pressed:not(:disabled) {
    filter: brightness(1.45);
    transform: translateY(1px);
    box-shadow: 0 3px 10px rgba(122, 12, 12, 0.2);
}

.terms-submit:disabled {
    opacity: .45;
    box-shadow: none;
    cursor: not-allowed;
    filter: none;
}

.terms-submit:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(228, 193, 156, 0.75);
}

.terms-error {
    margin: 12px 0 0;
    font-size: 12px;
    color: #ef4444;
    text-align: center;
}

.terms-error[hidden] {
    display: none;
}

/* ── Read-only mode (opened from the T&C / Privacy links) ─── */
/* Keeps a footer so the card stays balanced top-to-bottom. */
.terms-modal.is-readonly .terms-agree,
.terms-modal.is-readonly .terms-error {
    display: none;
}

.terms-modal.is-readonly .terms-submit {
    margin-top: 0;
}

/* ── Consent row on the signup form ───────────────────────── */
/* Beats `.terms span` in CP.css, which would colour the whole sentence red. */
.terms .terms-consent-text {
    color: #666;
    font-weight: 400;
    line-height: 1.5;
}

.terms-link {
    width: auto;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 4px;
    background: none;
    box-shadow: none;
    color: #EF4444;
    font: inherit;
    font-weight: 600;
    letter-spacing: normal;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    filter: none;
}

.terms-link:hover {
    filter: none;
    color: #7A0C0C;
}

.terms-link:active {
    filter: none;
    color: #f6c4c6;
}

.login-footer a[data-terms-open]:active {
    color: #F4C396;
}

.terms-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(228, 193, 156, 0.65);
}

/* ── Notice shown on the sign-in card ─────────────────────── */
.login-notice {
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid #f0c9cb;
    border-radius: 8px;
    background: #FFF1F3;
    color: #7A0C0C;
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

.login-notice[hidden] {
    display: none;
}

@media (max-width: 640px) {
    .terms-overlay { padding: 12px; }
    .terms-modal { max-height: 92vh; border-radius: 10px; }
    .terms-head { padding: 16px 18px 13px; }
    .terms-head h2 { font-size: 20px; }
    .terms-body { padding: 16px 18px 18px; }
    .terms-foot { padding: 14px 18px 18px; }
}

@media (prefers-reduced-motion: reduce) {
    .terms-overlay,
    .terms-modal {
        animation: none;
    }
}
