/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

@layer base {
    input::placeholder,
    textarea::placeholder {
        color: var(--color-gray-400);
    }

    button:not(:disabled),
    [role="button"]:not(:disabled) {
        cursor: pointer;
    }
}

@layer components {
    a.default-link {
        color: var(--color-primary);
        text-decoration: none;
    }

    a.default-link:hover {
        color: var(--color-primary-700);
        text-decoration: underline;
    }
}

html,
body {
    height: 100%;
    margin: 0;
}

.bg-dark {
    background-color: var(--bg-color);
}

.card {
    background-color: var(--card-color);
}

/* ── Toast notifications ──────────────────────────────────────────── */

/* Toastify wrapper overrides */
.toastify.custom-toast {
    padding: 0;
    background: none;
    box-shadow: none;
    border-radius: 0;
    max-width: 22rem;
    cursor: default;
    transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Close button — hidden until hover, top-right pill */
.toastify.custom-toast .toast-close {
    position: absolute;
    top: -0.375rem;
    right: -0.375rem;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.625rem;
    line-height: 1;
    padding: 0;
    opacity: 0;
    border-radius: 9999px;
    color: var(--color-surface-100);
    background: var(--color-surface-500);
    border: 1px solid var(--color-surface-400);
    transition: opacity 0.2s, background-color 0.15s, transform 0.15s;
    z-index: 1;
}

.toastify.custom-toast:hover .toast-close {
    opacity: 1;
}

.toastify.custom-toast .toast-close:hover {
    background: var(--color-surface-400);
    color: var(--color-surface-50);
    transform: scale(1.1);
}

/* The card itself — frosted glass with accent edge */
.toast-card {
    position: relative;
    overflow: hidden;
    border-radius: 0.75rem;
    background: rgba(22, 22, 22, 0.88);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    border: 1px solid var(--color-surface-400);
    box-shadow:
        0 8px 32px -8px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

/* Left accent strip */
.toast-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--color-surface-300);
}

.toast-card--success::before { background: #34d399; }
.toast-card--error::before   { background: #f87171; }
.toast-card--info::before    { background: var(--color-primary-400); }

/* Body layout */
.toast-card__body {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 0.875rem 0.75rem 1rem;
}

/* Icon badge */
.toast-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.625rem;
    height: 1.625rem;
    border-radius: 0.4375rem;
    flex-shrink: 0;
    font-size: 0.8125rem;
    margin-top: 0.0625rem;
    color: var(--color-surface-200);
    background: var(--color-surface-500);
}

.toast-card--success .toast-card__icon {
    color: #34d399;
    background: rgba(52, 211, 153, 0.14);
}

.toast-card--error .toast-card__icon {
    color: #f87171;
    background: rgba(248, 113, 113, 0.14);
}

.toast-card--info .toast-card__icon {
    color: var(--color-primary-400);
    background: rgba(129, 140, 248, 0.14);
}

/* Message text */
.toast-card__msg {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--color-surface-50);
    letter-spacing: 0.005em;
}

/* Auto-dismiss progress bar */
.toast-card__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.04);
}

.toast-card__progress::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 100%;
    width: 100%;
    transform-origin: left;
    animation: toast-progress var(--toast-duration, 5s) linear forwards;
    background: var(--color-surface-300);
    opacity: 0.5;
}

.toast-card--success .toast-card__progress::after { background: #34d399; opacity: 0.6; }
.toast-card--error .toast-card__progress::after   { background: #f87171; opacity: 0.6; }
.toast-card--info .toast-card__progress::after     { background: var(--color-primary-400); opacity: 0.6; }

@keyframes toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Pause progress on hover (matches Toastify's stopOnFocus) */
.toastify.custom-toast:hover .toast-card__progress::after {
    animation-play-state: paused;
}

/* Mobile — full-width bottom snackbar */
@media (max-width: 640px) {
    .toastify.custom-toast {
        max-width: calc(100vw - 2rem);
        width: calc(100vw - 2rem);
    }

    .toastify.custom-toast .toast-close {
        opacity: 0.6;
        top: 0.5rem;
        right: 0.5rem;
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.6875rem;
    }
}

/* ── Agreement index ──────────────────────────────────────────────── */

.agr-index__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
}

.agr-index__new-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--color-indigo-600);
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    white-space: nowrap;
}

.agr-index__new-btn:hover {
    background-color: var(--color-indigo-700);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-indigo-600) 40%, transparent);
}

.agr-index__section {
    margin-bottom: 2rem;
}

.agr-index__type-heading {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-surface-400);
    margin-bottom: 0.75rem;
    padding-left: 0.125rem;
}

.agr-index__list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agr-index__row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.875rem 1.125rem;
    background-color: var(--color-surface-700);
    border: 1px solid var(--color-surface-600);
    border-radius: 0.625rem;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.agr-index__row:hover {
    border-color: var(--color-surface-500);
    background-color: color-mix(in srgb, var(--color-surface-700) 90%, var(--color-surface-600));
}

.agr-index__row-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.agr-index__badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.175rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
    flex-shrink: 0;
}

.agr-index__badge--active {
    background-color: color-mix(in srgb, var(--color-green-500) 15%, transparent);
    color: var(--color-green-400);
    border: 1px solid color-mix(in srgb, var(--color-green-500) 25%, transparent);
}

.agr-index__badge--draft {
    background-color: var(--color-surface-600);
    color: var(--color-surface-300);
    border: 1px solid var(--color-surface-500);
}

.agr-index__badge--archived {
    background-color: color-mix(in srgb, var(--color-indigo-500) 12%, transparent);
    color: var(--color-indigo-300);
    border: 1px solid color-mix(in srgb, var(--color-indigo-500) 20%, transparent);
}

.agr-index__info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
}

.agr-index__title {
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--color-surface-100);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agr-index__meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--color-surface-400);
}

.agr-index__version {
    font-variant-numeric: tabular-nums;
}

.agr-index__separator {
    opacity: 0.5;
}

.agr-index__row-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.agr-index__warning {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--color-yellow-400);
    font-size: 0.75rem;
    white-space: nowrap;
}

.agr-index__action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-surface-200);
    background-color: var(--color-surface-600);
    border: 1px solid var(--color-surface-500);
    border-radius: 0.375rem;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.agr-index__action-btn:hover {
    background-color: var(--color-surface-500);
    border-color: var(--color-surface-400);
}

.agr-index__activate-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--color-indigo-600);
    border: 1px solid transparent;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.agr-index__activate-btn:hover {
    background-color: var(--color-indigo-700);
    box-shadow: 0 1px 4px color-mix(in srgb, var(--color-indigo-600) 35%, transparent);
}

.agr-index__empty {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1.25rem 1.125rem;
    color: var(--color-surface-400);
    font-size: 0.875rem;
    background-color: var(--color-surface-700);
    border: 1px dashed var(--color-surface-600);
    border-radius: 0.625rem;
}

.agr-index__empty-icon {
    font-size: 1.125rem;
    opacity: 0.5;
}

/* ── Agreement index — responsive ──────────────────────────────── */

@media (max-width: 640px) {
    .agr-index__row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 1rem;
    }

    .agr-index__row-main {
        flex-wrap: wrap;
    }

    .agr-index__row-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .agr-index__warning {
        width: 100%;
    }

    .agr-index__action-btn,
    .agr-index__activate-btn {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.75rem;
    }
}

/* ── Agreement show/preview ──────────────────────────────────────── */

.agr-show__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}

.agr-show__back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-surface-300);
    text-decoration: none;
    transition: color 0.15s ease;
}

.agr-show__back-link:hover {
    color: var(--color-surface-100);
}

.agr-show__toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.agr-show__status-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.8125rem;
    color: var(--color-surface-400);
}

.agr-show__version {
    font-variant-numeric: tabular-nums;
}

.agr-show__separator {
    opacity: 0.5;
}

.agr-show__warning {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--color-yellow-400);
}

.agr-show__preview {
    background-color: var(--color-surface-800);
    border: 1px solid var(--color-surface-600);
    border-radius: 0.75rem;
    overflow: hidden;
}

.agr-show__preview-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-surface-400);
    background-color: var(--color-surface-700);
    border-bottom: 1px solid var(--color-surface-600);
}

.agr-show__preview-content {
    padding: 2rem 1.5rem;
}

/* ── Agreement show — responsive ─────────────────────────────────── */

@media (max-width: 640px) {
    .agr-show__toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .agr-show__toolbar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .agr-show__toolbar-actions .agr-index__action-btn,
    .agr-show__toolbar-actions .agr-index__activate-btn {
        flex: 1;
        justify-content: center;
    }

    .agr-show__preview-content {
        padding: 1.5rem 1rem;
    }
}

/* ── Agreement form ───────────────────────────────────────────────── */

.agreement-form-card {
    background-color: var(--color-surface-700);
    border: 1px solid var(--color-surface-600);
    border-radius: 0.75rem;
    padding: 2rem;
    max-width: 56rem;
}

@media (max-width: 640px) {
    .agreement-form-card {
        padding: 1.25rem;
    }
}

.agreement-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.agreement-form__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 640px) {
    .agreement-form__grid {
        grid-template-columns: 1fr;
    }
}

.agreement-form__field .input_wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.agreement-form__editor {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.agreement-form__actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.agreement-form__btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background-color: var(--color-indigo-600);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.agreement-form__btn-primary:hover {
    background-color: var(--color-indigo-700);
}

.agreement-form__btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-surface-200);
    background-color: var(--color-surface-600);
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.agreement-form__btn-secondary:hover {
    background-color: var(--color-surface-500);
}

/* ── Platform List form ──────────────────────────────────────────── */

/* Settings row — position + active toggle side-by-side */
.plf-settings-row {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
}

.plf-settings-row__field {
    flex: 1;
    min-width: 0;
}

.plf-settings-row__toggle {
    flex-shrink: 0;
    padding-bottom: 0.125rem;
}

/* Toggle card — a tactile on/off switch */
.plf-toggle-card {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem;
    background-color: var(--color-surface-700);
    border: 1px solid var(--color-surface-400);
    border-radius: var(--radius-input);
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    user-select: none;
}

.plf-toggle-card:hover {
    border-color: var(--color-surface-300);
    background-color: color-mix(in srgb, var(--color-surface-700) 80%, var(--color-surface-600));
}

.plf-toggle-card__checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

.plf-toggle-card__indicator {
    position: relative;
    width: 2.25rem;
    height: 1.25rem;
    background-color: var(--color-surface-400);
    border-radius: 9999px;
    transition: background-color 0.25s ease;
    flex-shrink: 0;
}

.plf-toggle-card__indicator::after {
    content: "";
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: 0.95rem;
    height: 0.95rem;
    background-color: var(--color-surface-100);
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.plf-toggle-card__checkbox:checked ~ .plf-toggle-card__indicator {
    background-color: var(--color-primary);
}

.plf-toggle-card__checkbox:checked ~ .plf-toggle-card__indicator::after {
    transform: translateX(1rem);
    background-color: #fff;
}

.plf-toggle-card__checkbox:focus-visible ~ .plf-toggle-card__indicator {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.plf-toggle-card__label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-surface-100);
    white-space: nowrap;
}

/* Collections fieldset */
.plf-collections {
    border: 1px solid var(--color-surface-400);
    border-radius: var(--radius-input);
    padding: 0;
    margin: 0;
    overflow: hidden;
}

.plf-collections__legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-surface-100);
    padding: 0.75rem 1rem;
    background-color: var(--color-surface-600);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    float: left;
}

.plf-collections__icon {
    color: var(--color-primary-400);
    font-size: 0.875rem;
}

.plf-collections__list {
    clear: both;
    display: flex;
    flex-direction: column;
}

.plf-collections__list > .nested-fields:not(:last-of-type) {
    border-bottom: 1px solid var(--color-surface-500);
}

/* Single collection row */
.plf-collection-item {
    padding: 0.75rem 1rem;
    transition: background-color 0.15s;
}

.plf-collection-item:hover {
    background-color: color-mix(in srgb, var(--color-surface-700) 60%, var(--color-surface-600));
}

.plf-collection-item__fields {
    display: grid;
    grid-template-columns: 1fr 5rem 2rem;
    gap: 0.75rem;
    align-items: end;
}

.plf-collection-item__select {
    min-width: 0;
}

.plf-collection-item__position {
    min-width: 0;
}

.plf-collection-item__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    color: var(--color-surface-300);
    background-color: transparent;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    margin-bottom: 0.25rem;
}

.plf-collection-item__remove:hover {
    color: #f87171;
    background-color: rgba(248, 113, 113, 0.1);
    border-color: rgba(248, 113, 113, 0.2);
}

/* "Add Collection" button inside fieldset */
.plf-collections__list > button {
    margin: 0.75rem 1rem;
}

@media (max-width: 640px) {
    .plf-settings-row {
        flex-direction: column;
        align-items: stretch;
    }

    .plf-collection-item__fields {
        grid-template-columns: 1fr 5rem 2rem;
    }
}

/* ── Suggestion action buttons ─────────────────────────────────── */

.suggestion-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    border-radius: 0.625rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.suggestion-action-btn__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.375rem;
    height: 1.375rem;
    border-radius: 0.375rem;
    font-size: 0.6875rem;
    flex-shrink: 0;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Approve ── */

.suggestion-action-btn--approve {
    color: #6ee7b7;
    background-color: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
}

.suggestion-action-btn__icon--approve {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.suggestion-action-btn--approve:hover {
    color: #fff;
    background-color: #059669;
    border-color: #10b981;
    box-shadow:
        0 0 0 1px rgba(16, 185, 129, 0.1),
        0 4px 12px rgba(5, 150, 105, 0.35);
}

.suggestion-action-btn--approve:hover .suggestion-action-btn__icon--approve {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: scale(1.1);
}

.suggestion-action-btn--approve:active {
    transform: scale(0.97);
}

/* ── Reject ── */

.suggestion-action-btn--reject {
    color: #fca5a5;
    background-color: rgba(239, 68, 68, 0.08);
    border-color: rgba(239, 68, 68, 0.15);
}

.suggestion-action-btn__icon--reject {
    background-color: rgba(239, 68, 68, 0.12);
    color: #f87171;
}

.suggestion-action-btn--reject:hover {
    color: #fff;
    background-color: #dc2626;
    border-color: #ef4444;
    box-shadow:
        0 0 0 1px rgba(239, 68, 68, 0.1),
        0 4px 12px rgba(220, 38, 38, 0.35);
}

.suggestion-action-btn--reject:hover .suggestion-action-btn__icon--reject {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: scale(1.1);
}

.suggestion-action-btn--reject:active {
    transform: scale(0.97);
}

.dash-stagger { animation: dash-enter 0.5s ease-out both; }

@keyframes dash-enter {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}