@layer tokens, reset, base, layout, components;

@layer tokens {
    :root {
        --bg: #ffffff;
        --input-bg: #f3f3f3;
        --text: #000000;
        --text-muted: #8e8e8e;
        --text-sub: #8e8e8e;
        --border: #d4d4d4;
        --error: #c73939;
        --error-bg: #c73939;
        --link-change: #0066cc;
        --link-delete: #c73939;

        --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

        --radius-input: 8px;
        --radius-btn: 8px;

        --col-width: 580px;
    }
}

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

    html {
        font-size: 16px;
        -webkit-font-smoothing: antialiased;
    }

    button {
        font: inherit;
        background: none;
        border: none;
        cursor: pointer;
        color: inherit;
    }
}

@layer base {
    body {
        font-family: var(--font-body);
        background: var(--bg);
        color: var(--text);
        min-height: 100dvh;
    }
}

@layer layout {
    .site-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: 0.875rem 1.75rem;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 10;
        background: color-mix(in srgb, var(--bg) 82%, transparent);
        backdrop-filter: saturate(180%) blur(10px);
        -webkit-backdrop-filter: saturate(180%) blur(10px);
    }

    .site-header__title {
        color: var(--text);
        font-size: 1.0625rem;
        font-weight: 600;
        letter-spacing: -0.01em;
        text-decoration: none;

        &:empty {
            display: none;
        }
    }

    .site-header__logo {
        height: 34px;
    }

    .page-verification {
        padding: 4rem 2rem 2rem;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .page-verification__title {
        font-size: inherit;
        font-weight: inherit;
        letter-spacing: inherit;
        margin: 0;
    }

    .page-verification__form {
        width: 100%;
        max-width: 340px;
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    .page-verification__form > form {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .page-verification__form-label {
        font-size: 1.125rem;
        font-weight: 700;
        margin-bottom: 0.25rem;
    }

    .page-gaps {
        width: 100%;
        max-width: var(--col-width);
        margin-inline: auto;
        padding: 5rem 1rem 4rem;
    }

    .page-gaps__title {
        font-size: 1.5rem;
        font-weight: 700;
        margin-bottom: 0.5rem;
    }

    .page-gaps__desc {
        font-size: 0.9375rem;
        color: var(--text-sub);
        line-height: 1.5;
        margin-bottom: 1.5rem;
    }
}

@layer components {
    .input {
        font-family: var(--font-body);
        font-size: 0.9375rem;
        color: var(--text);
        background: var(--input-bg);
        border: 2px solid transparent;
        border-radius: var(--radius-input);
        padding: 0.75rem 1rem;
        width: 100%;
        appearance: none;
        transition: border-color 0.15s;

        &::placeholder {
            color: var(--text-muted);
        }

        &:focus {
            outline: none;
            border-color: #aaaaaa;
        }

        &.input--error {
            border-color: var(--error);
            background: #fff;
            padding-right: 9rem;
        }
    }

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

    .field-row {
        position: relative;
        display: flex;
        align-items: stretch;
    }

    .field-error-badge {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        display: flex;
        align-items: center;
        background: var(--error-bg);
        color: #fff;
        font-size: 0.8125rem;
        font-weight: 500;
        padding: 0 0.875rem;
        border-radius: 0 var(--radius-input) var(--radius-input) 0;
        white-space: nowrap;
        pointer-events: none;
    }

    .field-error-text {
        color: var(--error);
        font-size: 0.8125rem;
        margin-top: 0.25rem;
    }

    .btn {
        font-family: var(--font-body);
        font-size: 0.9375rem;
        font-weight: 500;
        border-radius: var(--radius-btn);
        padding: 0.75rem 1.5rem;
        border: 2px solid transparent;
        cursor: pointer;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: opacity 0.15s;
        text-decoration: none;
        white-space: nowrap;
        min-width: 8rem;

        &:hover {
            opacity: 0.85;
        }

        &.btn--primary {
            background: #000;
            color: #fff;
            border-color: #000;
            width: 100%;
        }

        &.btn--add {
            background: #000;
            color: #fff;
            border-color: #000;
        }

        &.btn--save {
            background: #fff;
            color: #000;
            border-color: #000;
        }

        &.btn--submit {
            background: #000;
            color: #fff;
            border-color: #000;
        }

        &:disabled {
            opacity: 0.4;
            cursor: not-allowed;
        }
    }

    .divider {
        border: none;
        border-top: 1px solid var(--border);
        margin-block: 1rem;
    }

    .gap-summary {
        margin-block: 0.5rem;
    }

    .gap-summary__row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-block: 0.75rem;
        border-bottom: 1px solid var(--border);

        & .gap-summary__label {
            font-size: 0.9375rem;
            font-weight: 700;
        }

        & .gap-summary__value {
            font-size: 0.9375rem;
            color: var(--text-sub);
        }
    }

    .gap-summary__actions {
        display: flex;
        gap: 1.5rem;
        padding-block: 0.5rem;

        & .link-change,
        & .link-delete {
            font-size: 0.9375rem;
            font-weight: 500;
            padding: 0;
            text-decoration: underline;
            text-underline-offset: 2px;
        }

        & .link-change {
            color: var(--link-change);
        }

        & .link-delete {
            color: var(--link-delete);
        }
    }

    .gap-form {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        margin-block: 1rem;
    }

    .gap-actions {
        display: flex;
        gap: 0.75rem;
        margin-top: 1.25rem;
        align-items: center;
    }

    .declaration {
        display: flex;
        gap: 0.75rem;
        align-items: flex-start;
        margin-block: 1.5rem;

        & input[type="checkbox"] {
            appearance: none;
            width: 1.125rem;
            height: 1.125rem;
            flex-shrink: 0;
            margin-top: 0.125rem;
            background: var(--input-bg);
            border: 1px solid var(--border);
            border-radius: 3px;
            cursor: pointer;

            &:checked {
                background: #000;
                border-color: #000;
                background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='white' stroke-width='2' d='M3 8l3.5 3.5L13 5'/></svg>");
                background-repeat: no-repeat;
                background-position: center;
            }
        }

        & .declaration__label {
            font-size: 0.9375rem;
            line-height: 1.5;
            color: var(--text-sub);
            cursor: pointer;

            & strong {
                color: var(--text);
                font-weight: 700;
            }
        }
    }

    .alert {
        padding: 0.75rem 1rem;
        border-radius: var(--radius-input);
        font-size: 0.875rem;
        margin-bottom: 1rem;

        &.alert--success {
            background: #e6f4ea;
            color: #14532d;
        }

        &.alert--warning {
            background: #fef3c7;
            color: #78350f;
        }
    }

    .error-page {
        min-height: 100dvh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        text-align: center;
        padding: 2rem;
    }

    .error-page__code {
        font-size: 6rem;
        font-weight: 700;
        line-height: 1;
        color: var(--text);
    }

    .error-page__message {
        font-size: 1rem;
        color: var(--text-sub);
        max-width: 360px;
        line-height: 1.6;
    }
}
