/*  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;
    }
}

/* IMPORTANT LAYOUT CLASSES */
#wrapper {
    display: flex;

    #content-wrapper {
        display: flex;
        flex-direction: column;
        min-height: 89vh;
        height: calc(100vh - var(--layout-heading-bar-body-margin));
        position: relative;
        margin-top: var(--layout-heading-bar-body-margin);
        overflow-x: hidden;
        width: 100%;

        @media (min-width: 768px) {
            margin-left: var(--layout-heading-bar-left-margin);
        }

        #content {
            width: 100%;
            display: flex;
            justify-content: center;
        }
    }
}

/* BEGIN ELEMENT STYLING */
a {
    color: inherit;
    text-decoration: none;

    &.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);
    }

    &.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;
    background: transparent;
    align-items: center;
    justify-content: center;
    gap: 4px;
    text-decoration: none !important;
    border: none;

    height: 48px;
    padding: 0 16px;
    border-radius: var(--border-radius);
    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: 20px;
    }

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

    }

    &.p-btn-sm {
        height: 40px;
        min-width: 40px;
        padding: 0 8px;

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

    &.p-btn-primary {
        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 {
        background: var(--surface-primary);
        color: var(--text-primary);
        border: 1px solid var(--border-medium-contrast);
    }

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

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

        &::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 {
        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;
        height: auto;

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

        &:not(:disabled):active {
            color: var(--link-active);
        }
    }
    &.dropdown-btn {
        justify-content: space-between;
        min-width: 192px;
    }
}

.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;
}

.dropdown-toggle-split {
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    margin-left: -1px;
    border-radius: 0 6px 6px 0;

    &::after {
        color: var(--text-primary);
        margin-left: 0;
    }

    &.p-btn-sm {
        height: 40px;
        padding: 0 8px;
    }
}

.dropdown-item {
    color: var(--text-primary);
    padding: 12px 8px;
    text-decoration: none;
    display: block;

    &:first-child {
        border-top-left-radius: var(--border-radius-default);
        border-top-right-radius: var(--border-radius-default);
    }

    &:last-child {
        border-bottom-left-radius: var(--border-radius-default);
        border-bottom-right-radius: var(--border-radius-default);
    }

    &:not(:disabled):hover {
        background: var(--surface-hover);
        color: var(--text-primary);
    }

    &:not(:disabled):active {
        background: var(--action-secondary-active);
        color: var(--text-primary);
    }
}

.dropdown-menu {
    min-width: 192px;
    padding: 0;
    background-color: var(--surface-primary);
    border: 1px solid var(--border-medium-contrast);
    border-radius: var(--border-radius-default);
    box-shadow: var(--box-shadow-sm);
}

.btn-group {
    display: flex;
}

code {
    font-size: 87.5%;
    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;
    }

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

    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;
}

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

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

h2 {
    font-size: var(--font-size-h3);
    font-weight: var(--font-weight-600);
    line-height: var(--line-height-xl);
}

h3 {
    font-size: var(--heading-03-font-size);
    font-weight: var(--font-weight-600);
    line-height: var(--line-height-lg);
}

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

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

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-semibold);
    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;
        }
    }
}

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 {

    /* Eliminate the different styles when it's autocomplete */
    &:-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;
    display: flex;
    min-height: 40px;
    padding: var(--p-2, 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;
    }

    /* TYPES OF INPUT */

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

        margin-bottom: 0;

        &:hover {
            outline: none;
        }
    }

    &[type="checkbox"] {
        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: 100ms ease-out;
        width: 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: 100ms ease-out;
        }

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

            &:after {
                left: 13px;
            }
        }
    }

    &[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: 100ms ease-out;
        width: 16px;
        min-width: 16px;

        &::after {
            content: "";
            position: absolute;
            top: 3px;
            left: 3px;
            background-color: var(--surface-primary);
            width: 10px;
            height: 10px;
            border-radius: 50%;
            transition: 100ms 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;
            }
        }
    }

    &.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: 21px;
        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: 21px;
        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;
}

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 */

.modal {

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 0 var(--p-6);
    }

    .modal-header,
    .modal-footer {
        border: 0;
        padding: var(--p-6);
    }

    .modal-content {
        background-color: var(--surface-primary);

        .btn-close {
            background: none;
        }

        .btn-close::before {
            content: "\E4F6";
            color: var(--text-primary);
            font-family: "Phosphor";
            font-weight: normal;
        }
    }

    .modal-lead-in {
        color: var(--text-secondary);
    }

    .modal-footer {
        .btn-set {
            margin: 0;
        }
    }
}

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

ol>li {
    color: var(--text-secondary);
    counter-increment: item;
    position: relative;
    padding-left: 50px;
    margin-bottom: 20px;

    &: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);
        position: absolute;
        left: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        width: 28px;
        height: 28px;
    }
}

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-bold);
}

/* Tables (we use classes to not lose specificity vs Bootstrap) */
.table {
    background-color: var(--surface-primary);
    border: 1px solid var(--border-default) !important;
    border-radius: var(--border-radius);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    --bs-table-bg: var(--surface-primary);

    > :not(caption) > * > * {
        border-bottom: 1px solid var(--border-default);
        color: var(--text-secondary);
        padding: 0.75rem;
    }

    &.table-sm {
        > :not(caption) > * > * {
            font-size: var(--font-size-sm);
            padding: 8px;
        }
    }

    > thead {
        vertical-align: bottom;
        border-bottom: 2px solid var(--border-default);
    }

    th {
        color: var(--text-primary);
        font-weight: var(--font-weight-normal);
        white-space: nowrap;

        &.sortable {
            cursor: pointer;

            &:hover {
                color: var(--link-hover) !important;
            }

            &:active,
            .active {
                color: var(--link-active) !important;
            }
        }
    }

    th,
    td {
        background-color: unset;
        border-top: none;
        vertical-align: middle;
    }

    > tbody {
        vertical-align: inherit;
    }

    tr {
        &[data-href] {
            cursor: pointer;

            &:hover {
                background-color: var(--background-default);
            }
        }
    }
}

.table-responsive {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;

    > .table {
        margin-bottom: 0;
    }
}

.table-responsive,
.table {
    max-width: 100%;
}

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

ul {
    list-style: none;
    margin-bottom: 0;
}

ul>li {
    font-family: var(--font-family);
    color: var(--text-secondary);
    position: relative;
    margin-bottom: 20px;

    &:before {
        content: "";
        background-color: var(--border-medium-contrast);
        border-radius: 100px;
        position: absolute;
        top: 8px;
        left: -32px;
        width: 8px;
        height: 8px;
    }
}


/* SUGGEST MIGRATE BELOW TO A SEPERATE GLOBAL CLASSES DOC */
.avatar {
    border-radius: 50%;
    border: 1px solid #E8EDEA;

    &:hover {
        border-color: #1BA853;
    }

    &:active {
        border-color: #138A42;
    }
}

.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);
}

.pen-card {
    background: var(--surface-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-default, #E5E7EB);
    border-radius: var(--border-radius-default, 8px);
    word-break: break-word;

    .pen-card-header {
        padding: var(--p-6, 24px) var(--p-6, 24px) 0;

        .pen-card-header-title {
            color: var(--text-secondary);
        }

        .pen-card-header-description {
            color: var(--text-secondary, #71717A);
            font-weight: var(--font-weight-400, 400);
        }
    }

    .pen-card-body {
        padding: var(--p-6, 24px)var(--p-6, 24px);
    }
}

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

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

footer.sticky-footer {
  padding: 2rem 0;
  flex-shrink: 0;
  margin-top: auto;
}

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

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

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