/*  ANIMATION KEYFRAMES */
@-webkit-keyframes growIn {
    0% {
        transform: scale(0.98);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes growIn {
    0% {
        transform: scale(0.98);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@-webkit-keyframes growOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0;
    }
}

@keyframes growOut {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    100% {
        transform: scale(0.95);
        opacity: 0;
    }
}

/* BEGIN ELEMENT STYLING */


/* Add selection styles */
::selection {
    color: var(--text-primary);
    background-color: var(--surface-selected);
}

::-moz-selection {
    color: var(--text-primary);
    background-color: var(--surface-selected);
}

a {
    color: inherit;
    text-decoration: none;

    &.list-item {
        padding: var(--p-2) 0;
        display: block;
        text-align: center;
        width: 100%;
    }

    &.underline {
        text-decoration-color: var(--text-secondary);
        text-decoration-line: underline;
        text-decoration-style: dotted;
        text-decoration-thickness: 10%;
        text-decoration-skip-ink: auto;
        text-underline-offset: auto;
        text-underline-position: from-font;
    }

    /* Hover for the entire link */
    &:hover,
    &.contrast:hover {
        color: var(--link-hover);
    }

    &.no-hover {
        &:hover {
            color: inherit;
        }
    }

    &.undecorated {
        text-decoration: none;
    }

    &.contrast {
        color: var(--link-contrast);
        text-decoration-color: var(--link-contrast);
    }
}

body {
    background-color: var(--background-default);
    color: var(--text-primary);
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-weight: var(--font-weight-400);
    font-size: var(--font-size-default);
    line-height: var(--line-height-md);
    letter-spacing: var(--letter-spacing-tight);
    margin: 0;
    min-height: 100vh;
    overflow: auto;
}

button,
.p-btn {
    cursor: pointer;
    display: inline-flex !important;
    background: transparent;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none !important;
    border: none;
    flex-shrink: 0;
    font-size: var(--font-size-sm);

    height: 32px;
    min-width: 32px;
    padding: 0 6px;
    border-radius: var(--border-radius-sm);
    font-weight: var(--font-weight-500);
    transform: scale(1);
    transition: transform 0.1s ease;

    &:not(:disabled) {
        transform: scale(1);
        transition: transform 0.1s ease;
    }

    &:not(:disabled):hover {
        text-decoration: none;
    }

    i.ph {
        font-size: var(--font-size-sm);
    }

    &:disabled,
    &.disabled,
    &.p-btn-disabled {
        cursor: not-allowed;
        opacity: .5;

    }

    &.p-btn-sm {
        font-size: var(--font-size-xs);
        height: 24px;
        min-width: 24px;
        padding: 0 4px;

        i.ph {
            font-size: 16px;
        }

        &.p-btn-overflow {
            width: 24px;
        }
    }

    &.p-btn-primary,
    &.p-btn-primary.loading::after {
        background: var(--action-primary-default);
        color: var(--action-primary-content-default);

        &:not(:disabled):hover {
            background: var(--action-primary-hover);
        }

        &:not(:disabled):active {
            background: var(--action-primary-active);
            transform: scale(0.99);
        }
    }

    &.p-btn-secondary,
    &.p-btn-secondary.loading::after {
        background: var(--surface-primary);
        color: var(--text-primary);
        border: 1px solid var(--border-medium-contrast);
    }

    &.p-btn-tertiary,
    &.p-btn-tertiary.loading::after {
        color: var(--text-primary);
    }

    &.p-btn-overflow {
        border: 0;
        border-radius: var(--border-radius-default);
        width: 32px;

        &::before {
            content: "\E208";
            font-family: "Phosphor-Bold";
            font-size: 16px;
            color: var(--text-primary);
        }

        &::after {
            display: none;
        }
    }

    &.p-btn-secondary,
    &.p-btn-tertiary,
    &.p-btn-overflow {
        &:not(:disabled):hover {
            background: var(--surface-hover);
        }

        &:not(:disabled):active {
            background: var(--action-secondary-active);
            transform: scale(0.99);
        }
    }

    &.p-btn-danger,
    &.p-btn-danger.loading::after {
        background: var(--semantic-danger-surface);
        color: var(--semantic-danger-text);

        &:not(:disabled):hover {
            background: var(--semantic-danger-surface-hover);
        }

        &:not(:disabled):active {
            background: var(--semantic-danger-surface-active);
            transform: scale(0.99);
        }
    }

    &.p-btn-text {
        background: transparent;
        color: var(--text-primary);
        font-weight: var(--font-weight-normal);
        padding: 0;

        &:not(:disabled):hover {
            color: var(--link-hover);
        }

        &:not(:disabled):active {
            color: var(--link-active);
        }
    }

    &.loading {
        position: relative;
        pointer-events: none;
        color: transparent;

        &::after {
            background-color: transparent;
            border: 0 !important;
            content: "\EB44";
            font-family: "Phosphor";
            position: absolute;
            left: 50%;
            top: 50%;
            animation: spin-centered 1s linear infinite;
            font-size: 20px;
            color: var(--surface-primary);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        &.p-btn-sm::after {
            font-size: 16px;
            width: 16px;
            height: 16px;
        }
    }
}

.btn-set {
    display: flex;
    flex-direction: row-reverse;
    flex-grow: 1;
    justify-content: end;
    gap: 8px;
}


/* Split button */

.btn-group>.p-btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.btn-group>.p-btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

code {
    font-size: inherit;
    color: var(--semantic-code);
    word-wrap: break-word;
}

details {
    border-radius: var(--border-radius);
    background-color: var(--surface-primary);

    .details-content {
        padding: 0 var(--p-6, 24px) var(--p-6, 24px);
    }

    &.border {
        border: 1px solid var(--border-default) !important;
    }

    &:hover {
        border-color: var(--border-medium-contrast) !important;
        background-color: var(--surface-hover);
    }

    &[open] {
        animation: growIn 400ms cubic-bezier(0.26, 0.94, 0.26, 1.01);
        border-color: var(--border-medium-contrast);
        outline: none;
        background-color: var(--surface-primary);
    }

    summary {
        cursor: pointer;
        transition: background-color 0.2s ease;
        list-style: none;

        &.p {
            padding: var(--p-6, 24px);
        }

        &::-webkit-details-marker {
            display: none;
        }

        &:hover {
            border-color: var(--border-high-contrast);
        }
    }
}

fieldset {
    border: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 0;
    margin: 0;
    max-width: 768px;
}

.grayscale {
  filter: grayscale(100%);
}

/* Headings */
h1,
h2,
h3,
h4 {
    &::first-letter {
        text-transform: uppercase;
    }
}

h1 {
    font-size: var(--font-size-h2);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-xxl);
}

h2 {
    font-size: var(--font-size-default);
    font-weight: var(--font-weight-500);
    line-height: var(--line-height-lg);
}

h3 {
    font-size: var(--font-size-default);
    font-weight: var(--font-weight-500);
    line-height: var(--line-height-lg);
}

h4 {
    font-size: var(--font-size-default);
    font-weight: var(--font-weight-500);
    line-height: var(--line-height-lg);
}

h5 {
    color: var(--text-secondary);
    font-size: var(--font-size-default);
    font-weight: var(--font-weight-normal);
}

h6 {
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-500);
}

hr {
    opacity: 1;
    height: 1px;
    color: var(--border-default) !important;
}

label {
    margin-bottom: 2px;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-500);
    width: 100%;

    /* Used for hint text in forms */
    & small {
        color: var(--text-secondary);
        display: block;
    }

    &.optional {
        padding-right: 64px;
        position: relative;

        &::after {
            content: "Optional";
            color: var(--text-tertiary);
            position: absolute;
            top: 0;
            right: 0;
        }
    }

    /* Show not-allowed cursor for labels of disabled form elements */
    &:has(+ input:disabled),
    &:has(input:disabled),
    &:has(+ select:disabled),
    &:has(select:disabled),
    &:has(+ textarea:disabled),
    &:has(textarea:disabled),
    &:has(+ div input:disabled),
    &:has(+ div select:disabled),
    &[for]:has(input:disabled),
    &[for]:has(+ input:disabled),
    &[for]:has(select:disabled),
    &[for]:has(+ select:disabled),
    &[for]:has(textarea:disabled),
    &[for]:has(+ textarea:disabled),
    &[for]:has(+ div input:disabled),
    &[for]:has(+ div select:disabled),
    input:disabled + &,
    select:disabled + &,
    textarea:disabled + &,
    div input:disabled + &,
    div select:disabled + & {
        cursor: not-allowed;
        color: var(--text-disabled);
    }

    /* Show pointer cursor for labels of enabled form elements */
    &:has(+ input:not(:disabled)),
    &:has(input:not(:disabled)),
    &:has(+ select:not(:disabled)),
    &:has(select:not(:disabled)),
    &:has(+ textarea:not(:disabled)),
    &:has(textarea:not(:disabled)),
    &:has(+ div input:not(:disabled)),
    &:has(+ div select:not(:disabled)),
    &[for]:has(input:not(:disabled)),
    &[for]:has(+ input:not(:disabled)),
    &[for]:has(select:not(:disabled)),
    &[for]:has(+ select:not(:disabled)),
    &[for]:has(textarea:not(:disabled)),
    &[for]:has(+ textarea:not(:disabled)),
    &[for]:has(+ div input:not(:disabled)),
    &[for]:has(+ div select:not(:disabled)),
    input:not(:disabled) + &,
    select:not(:disabled) + &,
    textarea:not(:disabled) + &,
    div input:not(:disabled) + &,
    div select:not(:disabled) + & {
        cursor: pointer;
    }
}

legend {
    color: var(--text-secondary);
    font-size: var(--font-size-default);
    margin-bottom: 0;
}

form.was-validated {
    input:invalid, .is-invalid {
        border-color: var(--semantic-danger-border);

        &:focus {
            outline: none;
        }
    }

    .invalid-feedback {
        color: var(--semantic-danger-text);
    }
}


input,
select,
textarea {

    &:-webkit-autofill,
    &:-webkit-autofill:hover,
    &:-webkit-autofill:focus,
    &:-webkit-autofill:active {
        -webkit-background-clip: text;
        -webkit-text-fill-color: var(--text-primary);
        transition: background-color 5000s ease-in-out 0s;
        box-shadow: inset 0 0 20px 20px var(--text-areas-form-background-empty);
    }

    border-radius: var(--border-radius-sm, 6px);
    border: 1px solid var(--border-medium-contrast);
    background: var(--surface-primary);
    color: var(--text-primary) !important;
    font-size: var(--font-size-sm);
    display: flex;
    min-height: 32px;
    padding: var(--p-1, 8px);
    align-items: center;
    gap: 8px;
    width: 100%;

    /* STATES */
    &:hover {
        outline: 1px solid var(--border-default);
    }

    &:focus {
        outline: 3px solid var(--surface-brand);
    }

    &::placeholder {
        color: var(--text-tertiary) !important;
    }


    &:disabled {
        background: var(--surface-disabled, #F5F5F5);
        color: var(--text-disabled, #A1A1AA);
        cursor: not-allowed !important;
    }

    /* TYPES OF INPUT */

    &[type="checkbox"],
    &[type="radio"] {

        margin-bottom: 0;

        &:hover {
            outline: none;
        }
    }

    &[type="checkbox"]{
        appearance: none;
        width: 20px;
        height: 20px;
        min-width: 20px;
        min-height: 20px;
        border: 2px solid var(--border-medium-contrast);
        border-radius: 4px;
        background: var(--surface-primary);
        display: inline-block;
        vertical-align: middle;
        position: relative;
        transition: border-color 0.2s, background 0.2s;

        &:not(:disabled):not(:checked):hover {
            background-color: var(--surface-medium-contrast);
        }

        &:checked{
            background: var(--brand-primary);
            border-color: var(--surface-brand);

            &::after {
                content: '\E182';
                color: var(--surface-primary);
                font-family: "Phosphor";
                font-weight: var(--font-weight-600) !important;
                font-size: 16px;
                position: absolute;
                left: -2px;
                top: -2px;
                width: 20px;
                height: 20px;
                display: flex;
                align-items: center;
                justify-content: center;
                pointer-events: none;
            }

            &:disabled::after {
                background-color: var(--surface-disabled);
                color: var(--icon-disabled);
            }
        }

        &.toggle {
        appearance: none;
        background-color: var(--surface-high-contrast);
        border: none;
        border-radius: var(--border-radius-pill);
        display: inline-block;
        height: 20px;
        min-height: 20px;
        position: relative;
        transition: 50ms ease-out;
        vertical-align: middle;
        width: 32px;
        flex: 0 0 32px;

            &::before {
                position: absolute;
                content: "";
                inset: -6px;
            }

            &::after {
                content: "";
                position: absolute;
                top: 3px;
                left: 3px;
                background-color: var(--surface-primary);
                width: 14px;
                height: 14px;
                border-radius: 50%;
                transition: 50ms ease-out;
            }

            &:checked {
                background: var(--brand-primary);
                &::after {
                left: 15px;
            }
            }
        }
    }

    &[type="file"] {
        border-style: dashed;
    }

    &[type="radio"] {
        appearance: none;
        background-color: var(--surface-high-contrast);
        border: none;
        border-radius: var(--border-radius-pill);
        display: inline-block;
        height: 16px;
        min-height: 16px;
        margin-bottom: 0;
        position: relative;
        top: -2px;
        transition: 50ms ease-out;
        width: 16px;
        min-width: 16px;

        &:not(:disabled):not(:checked):hover {
            &::after {
                background-color: var(--surface-medium-contrast);
            }
        }

        &::after {
            content: "";
            position: absolute;
            top: 3px;
            left: 3px;
            background-color: var(--surface-primary);
            width: 10px;
            height: 10px;
            border-radius: 50%;
            transition: 50ms ease-out;
        }

        &:checked {
            background: var(--brand-primary);
        }
    }

    &[type="date"] {
        display: block;

        &::-webkit-calendar-picker-indicator {
            filter: invert(var(--calendar-icon-invert, 0.8)) brightness(var(--calendar-icon-brightness, 0.8));
            cursor: pointer;

            &:hover {
                opacity: 0.7;
            }
        }
    }

    &[type="number"] {
        appearance: textfield;

        &::-webkit-inner-spin-button {
            -webkit-appearance: none;
            appearance: none;
            margin: 0;
        }

        &::-webkit-outer-spin-button {
            -webkit-appearance: none;
            appearance: none;
            margin: 0;
        }
    }

    &.is-invalid {
        border-color: var(--bs-form-invalid-color);

        &:focus {
            outline: none;
        }
    }
}

/* WRAPPER CLASSES */

.input-date-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;

    &::after {
        position: absolute;
        font-family: 'Phosphor-Bold';
        content: '\e10a';
        color: var(--text-primary);
        right: 12px;
        top: 21px;
        transform: translateY(-50%);
        font-size: 16px;
        pointer-events: none;
    }
}

.input-select-wrapper {
    position: relative;

    &::after {
        position: absolute;
        font-family: 'Phosphor-Bold';
        content: '\e136';
        color: var(--text-primary);
        right: 10px;
        top: 17px;
        transform: translateY(-50%);
        font-size: 16px;
        pointer-events: none;
    }
}

.input-search-wrapper {
    position: relative;

    &::after {
        position: absolute;
        font-family: 'Phosphor-Bold';
        content: '\E30C';
        color: var(--text-primary);
        right: 10px;
        top: 17px;
        transform: translateY(-50%);
        font-size: 16px;
        pointer-events: none;
    }
}

.input-checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-radio-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-item {
    display: block;
    padding: var(--p-2, 8px) 0;
}

select {
    appearance: none;
    padding-right: 32px;
}

main {
    max-width: 1440px;

    &.page {
        border: 1px solid var(--border-default, #E5E7EB);
        border-radius: var(--border-radius-lg, 16px);
        background: var(--surface-primary, #FFF);
        padding: var(--p-8) var(--p-6);

        @media (min-width: 992px) {
            margin: 0 var(--p-8);
        }
    }
}

/*  MODALS */

/* Lists */
ol {
    list-style: none;
    counter-reset: item;
    padding-left: 0;
    margin-bottom: 0;


    >li {
        color: var(--text-secondary);
        counter-increment: item;
        position: relative;
        padding-left: 32px;
        margin-bottom: var(--p-2);

        ol {
            margin: var(--p-2) 0;
        }

        &:before {
            content: counter(item);
            background-color: var(--surface-brand);
            color: var(--icon-brand);
            letter-spacing: var(--letter-spacing);
            font-weight: var(--font-weight-bold);
            font-family: var(--font-family);
            border-radius: var(--border-radius-sm);
            position: absolute;
            left: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            text-align: center;
            width: 24px;
            height: 24px;
        }

        >h3,
        >h4 {
            color: var(--text-primary);
        }
    }

    &.large {
        >li {

            &:before {
                width: 32px;
                height: 32px;
            }
        }
    }
}

p {
    margin-bottom: var(--p-2, 8px);

    &:last-child {
        margin-bottom: 0;
    }
}

pre {
    background: var(--surface-secondary);
    border-radius: var(--border-radius);
    color: var(--semantic-code);
    display: block;
    line-height: 1.4em;
    margin-top: 0;
    margin-bottom: 1em;
    overflow: auto;
    -ms-overflow-style: scrollbar;
    padding: var(--p-2);
    white-space: pre-wrap;
}

pre code {
    color: var(--semantic-code);
    word-break: normal;
}

small {
    /* <small>/default */
    display: block;
    font-size: var(--font-size-sm, 14px);
    font-weight: var(--font-weight-400, 400);
    line-height: var(--line-height-sm, 20px);
    letter-spacing: -0.28px;

    &.xs {
        font-size: var(--font-size-xs, 12px);
        font-weight: var(--font-weight-400, 400);
        line-height: var(--line-height-xs, 16px);
        letter-spacing: -0.24px;
    }
}

strong {
    font-weight: var(--font-weight-500);
}

textarea {
    color: var(--text-primary);
}

ul {
    list-style-position: outside;
    padding-left: 16px;
    margin-bottom: 0;

    >li {
        color: var(--text-secondary);
        position: relative;
        line-height: inherit;
        padding-left: 8px;

        &::marker {
            color: var(--border-high-contrast);
            content: "●";
            font-size: 16px;
        }
    }
}

/* SUGGEST MIGRATE BELOW TO A SEPERATE GLOBAL CLASSES DOC */
.avatar {
    border-radius: 50%;
    border: 1px solid var(--brand-200);
    background-color: var(--surface-brand);

    &:hover {
        border-color: var(--action-primary-hover);
    }

    &:active {
        border-color:var(--action-primary-active);
    }
    rect{
        fill: var(--surface-brand)
    }
    text{
        fill: var(--text-primary);
        font-weight: var(--font-weight-500);
    }
}

.container-fluid {
    padding: 0 24px;
}

.box-shadow-sm {
    box-shadow: var(--box-shadow-sm);
}

.box-shadow-md {
    box-shadow: var(--box-shadow);
}

.box-shadow-lg {
    box-shadow: var(--box-shadow-lg);
}

.box-shadow-xl {
    box-shadow: var(--box-shadow-xl);
}

.text-primary {
    color: var(--text-primary, #18181B) !important;
}

.text-secondary {
    color: var(--text-secondary, #71717A) !important;
}

.text-tertiary {
    color: var(--text-tertiary, #A1A1AA) !important;
}

.text-disabled {
    color: var(--text-disabled, #A1A1AA) !important;
}

footer.sticky-footer {
  padding: var(--p-4) 0;
  flex-shrink: 0;
  margin-top: auto;
}

/* Toasts */
.toast-container>:not(:last-child) {
    /* Spacing between toasts */
    margin-bottom: var(--p-2, 8px) !important;
}

.indicator-toast {
    background:var(--surface-primary);
    color: var(--text-primary);
    border-radius: var(--border-radius-default);
    display: flex;
    padding: 0px 8px 0px 0px;
    align-items: stretch;
    gap: 6px;
    border: 1px solid var(--border-default);
    width: 100%;
    justify-content: space-between;
    min-height: 56px;

    .toast-icon{
        background-color: var(--surface-primary);
        padding: 0 10px;
        border-radius:  var(--border-radius-default) 0 0  var(--border-radius-default);

    }

    i {
        color: var(--text-secondary);
    }

    &.toast-success {
        .toast-icon{
            background-color: var(--surface-brand);
        }
        i {
            color: var(--semantic-success-icon);
        }
    }
    &.toast-warning {
        .toast-icon{
            background-color: var(--semantic-warning-surface);
        }
        i {
            color: var(--semantic-warning-icon);
        }
    }
    &.toast-info {
        .toast-icon{
            background-color: var(--semantic-info-surface);
        }
        i {
            color: var(--semantic-info-icon);
        }
    }
    &.toast-error {
        .toast-icon{
            background-color: var(--semantic-danger-surface);
        }
        i {
            color: var(--semantic-danger-icon);
        }
    }

    button {

        background-color: var(--surface-primary);
        border-radius: var(--border-radius);
        border:1px solid var(--border-medium-contrast);
        padding: 6px;

        i.close-toast {
        color: var(--action-secondary-content-default);
        }
    }
}

[data-dismiss="toast"] {
    cursor: pointer;
}

/* Animations */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes spin-centered {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.loading-spinner {
    animation: spin 1s linear infinite;
}


/* INTERNAL DOCUMENTATION STYLES */

.docs-section {
    margin-bottom: 4rem;
}

/* Cursors */
.cursor-not-allowed {
    cursor: not-allowed;
}
