/* =====================================================
SPI UI
File        : input.css
Component   : Input / Form
Version     : 1.0.0
Author      : StudioProjectID
===================================================== */


/* =====================================================
FORM GROUP
===================================================== */

.spi-form-group {
    width: 100%;

    margin-bottom: 20px;
}


/* =====================================================
LABEL
===================================================== */

.spi-label {
    display: inline-flex;

    align-items: center;

    gap: 4px;

    margin-bottom: 8px;

    color:
        var(--spi-text, #334155);

    font-size: 12px;

    line-height: 1.4;

    font-weight: 650;
}


/* =====================================================
REQUIRED
===================================================== */

.spi-required {
    color:
        #ef4444;

    font-size: 12px;

    font-weight: 700;
}


/* =====================================================
INPUT WRAPPER
===================================================== */

.spi-input-wrapper {
    position: relative;

    width: 100%;
}


/* =====================================================
BASE INPUT
===================================================== */

.spi-input {

    width: 100%;

    min-height: 44px;

    padding:
        0 14px;

    border:
        1px solid
        var(--spi-border, #e2e8f0);

    border-radius:
        var(--spi-radius-md, 12px);

    outline: none;

    background:
        rgba(255, 255, 255, .95);

    color:
        var(--spi-text, #0f172a);

    font-family: inherit;

    font-size: 13px;

    font-weight: 500;

    line-height: 1.4;

    box-sizing: border-box;

    box-shadow:
        0 1px 2px rgba(15, 23, 42, .015);

    transition:
        border-color .22s ease,
        box-shadow .22s ease,
        background .22s ease,
        transform .22s ease;
}


/* =====================================================
PLACEHOLDER
===================================================== */

.spi-input::placeholder {

    color:
        #94a3b8;

    opacity: 1;

    font-weight: 400;
}


/* =====================================================
HOVER
===================================================== */

.spi-input:hover:not(:disabled) {

    border-color:
        #cbd5e1;

    background:
        #ffffff;
}


/* =====================================================
FOCUS
===================================================== */

.spi-input:focus {

    border-color:
        #22c55e;

    background:
        #ffffff;

    box-shadow:
        0 0 0 3px
        rgba(34, 197, 94, .10);
}


/* =====================================================
FOCUS VISIBLE
===================================================== */

.spi-input:focus-visible {

    outline: none;
}


/* =====================================================
DISABLED
===================================================== */

.spi-input:disabled {

    background:
        #f8fafc;

    color:
        #94a3b8;

    border-color:
        #e2e8f0;

    cursor:
        not-allowed;

    opacity:
        .75;
}


/* =====================================================
READONLY
===================================================== */

.spi-input[readonly] {

    background:
        #f8fafc;

    cursor:
        default;
}


/* =====================================================
INVALID
===================================================== */

.spi-input.is-invalid,
.spi-input.spi-input-error {

    border-color:
        #ef4444;

    background:
        #fffafa;
}


.spi-input.is-invalid:focus,
.spi-input.spi-input-error:focus {

    border-color:
        #ef4444;

    box-shadow:
        0 0 0 3px
        rgba(239, 68, 68, .10);
}


/* =====================================================
VALID
===================================================== */

.spi-input.is-valid,
.spi-input.spi-input-success {

    border-color:
        #22c55e;
}


.spi-input.is-valid:focus,
.spi-input.spi-input-success:focus {

    box-shadow:
        0 0 0 3px
        rgba(34, 197, 94, .10);
}


/* =====================================================
TEXTAREA
===================================================== */

textarea.spi-input {

    min-height: 110px;

    padding:
        12px 14px;

    resize: vertical;

    line-height: 1.6;
}


/* =====================================================
SELECT
===================================================== */

select.spi-input {

    appearance: none;

    -webkit-appearance: none;

    padding-right: 42px;

    cursor: pointer;

    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");

    background-repeat: no-repeat;

    background-position:
        right 14px center;

    background-size:
        16px;
}


/* =====================================================
SELECT DISABLED
===================================================== */

select.spi-input:disabled {

    cursor:
        not-allowed;
}


/* =====================================================
INPUT WITH ICON
===================================================== */

.spi-input-icon {

    position: relative;

    width: 100%;
}


.spi-input-icon .spi-input {

    padding-left:
        42px;
}


.spi-input-icon-right .spi-input {

    padding-right:
        42px;
}


/* =====================================================
INPUT ICON
===================================================== */

.spi-input-icon-left {

    position: absolute;

    top: 50%;
    left: 14px;

    width: 17px;
    height: 17px;

    display: flex;

    align-items: center;
    justify-content: center;

    color:
        #94a3b8;

    pointer-events:
        none;

    transform:
        translateY(-50%);

    transition:
        color .2s ease;
}


.spi-input-icon-right {

    position: absolute;

    top: 50%;
    right: 14px;

    width: 17px;
    height: 17px;

    display: flex;

    align-items: center;
    justify-content: center;

    color:
        #94a3b8;

    cursor:
        pointer;

    transform:
        translateY(-50%);
}


.spi-input-icon-left svg,
.spi-input-icon-right svg {

    width: 17px;

    height: 17px;

    stroke:
        currentColor;
}


.spi-input-icon:focus-within
.spi-input-icon-left {

    color:
        #22c55e;
}


/* =====================================================
PASSWORD
===================================================== */

.spi-password {

    position: relative;

    width: 100%;
}


.spi-password .spi-input {

    padding-right:
        46px;
}


.spi-password-toggle {

    position: absolute;

    top: 50%;
    right: 8px;

    width: 34px;
    height: 34px;

    display: flex;

    align-items: center;
    justify-content: center;

    border:
        none;

    border-radius:
        9px;

    background:
        transparent;

    color:
        #94a3b8;

    cursor:
        pointer;

    transform:
        translateY(-50%);

    transition:
        background .2s ease,
        color .2s ease;
}


.spi-password-toggle:hover {

    background:
        #f8fafc;

    color:
        #475569;
}


.spi-password-toggle svg {

    width:
        17px;

    height:
        17px;
}


/* =====================================================
HELPER TEXT
===================================================== */

.spi-form-help {

    margin-top:
        6px;

    color:
        #94a3b8;

    font-size:
        11px;

    line-height:
        1.5;
}


/* =====================================================
ERROR
===================================================== */

.spi-form-error {

    display: flex;

    align-items: center;

    gap: 5px;

    margin-top:
        6px;

    color:
        #dc2626;

    font-size:
        11px;

    line-height:
        1.5;

    font-weight:
        500;
}


.spi-form-error::before {

    content:
        "!";

    width:
        14px;

    height:
        14px;

    display:
        inline-flex;

    align-items:
        center;

    justify-content:
        center;

    flex-shrink:
        0;

    border-radius:
        50%;

    background:
        #fee2e2;

    color:
        #dc2626;

    font-size:
        9px;

    font-weight:
        800;
}


/* =====================================================
SUCCESS MESSAGE
===================================================== */

.spi-form-success {

    margin-top:
        6px;

    color:
        #16a34a;

    font-size:
        11px;

    font-weight:
        500;
}


/* =====================================================
CHARACTER COUNTER
===================================================== */

.spi-input-counter {

    display:
        flex;

    justify-content:
        flex-end;

    margin-top:
        5px;

    color:
        #94a3b8;

    font-size:
        10px;
}


/* =====================================================
INPUT SM
===================================================== */

.spi-input-sm {

    min-height:
        36px;

    padding:
        0 12px;

    border-radius:
        10px;

    font-size:
        12px;
}


/* =====================================================
INPUT LG
===================================================== */

.spi-input-lg {

    min-height:
        52px;

    padding:
        0 16px;

    border-radius:
        14px;

    font-size:
        14px;
}


/* =====================================================
SEARCH
===================================================== */

.spi-search {

    position:
        relative;

    width:
        100%;
}


.spi-search .spi-input {

    padding-left:
        42px;

    padding-right:
        42px;
}


.spi-search-icon {

    position:
        absolute;

    top:
        50%;

    left:
        14px;

    width:
        17px;

    height:
        17px;

    color:
        #94a3b8;

    pointer-events:
        none;

    transform:
        translateY(-50%);
}


.spi-search-icon svg {

    width:
        17px;

    height:
        17px;

    stroke:
        currentColor;
}


.spi-search-clear {

    position:
        absolute;

    top:
        50%;

    right:
        9px;

    width:
        28px;

    height:
        28px;

    display:
        flex;

    align-items:
        center;

    justify-content:
        center;

    border:
        none;

    border-radius:
        8px;

    background:
        transparent;

    color:
        #94a3b8;

    cursor:
        pointer;

    transform:
        translateY(-50%);
}


.spi-search-clear:hover {

    background:
        #f1f5f9;

    color:
        #475569;
}


/* =====================================================
CHECKBOX
===================================================== */

.spi-checkbox {

    position:
        relative;

    display:
        inline-flex;

    align-items:
        center;

    gap:
        9px;

    color:
        #475569;

    font-size:
        12px;

    font-weight:
        500;

    cursor:
        pointer;

    user-select:
        none;
}


.spi-checkbox input {

    position:
        absolute;

    opacity:
        0;

    pointer-events:
        none;
}


.spi-checkbox span {

    position:
        relative;

    width:
        18px;

    height:
        18px;

    display:
        inline-flex;

    align-items:
        center;

    justify-content:
        center;

    border:
        1px solid
        #cbd5e1;

    border-radius:
        5px;

    background:
        #fff;

    transition:
        background .2s ease,
        border-color .2s ease,
        box-shadow .2s ease;
}


.spi-checkbox span::after {

    content:
        "";

    width:
        8px;

    height:
        4px;

    border-left:
        2px solid #fff;

    border-bottom:
        2px solid #fff;

    opacity:
        0;

    transform:
        rotate(-45deg)
        translateY(-1px);

    transition:
        opacity .15s ease;
}


.spi-checkbox input:checked + span {

    border-color:
        #22c55e;

    background:
        #22c55e;

    box-shadow:
        0 2px 7px
        rgba(34, 197, 94, .16);
}


.spi-checkbox input:checked + span::after {

    opacity:
        1;
}


/* =====================================================
RADIO
===================================================== */

.spi-radio {

    position:
        relative;

    display:
        inline-flex;

    align-items:
        center;

    gap:
        9px;

    color:
        #475569;

    font-size:
        12px;

    cursor:
        pointer;

    user-select:
        none;
}


.spi-radio input {

    position:
        absolute;

    opacity:
        0;

    pointer-events:
        none;
}


.spi-radio span {

    position:
        relative;

    width:
        18px;

    height:
        18px;

    border:
        1px solid
        #cbd5e1;

    border-radius:
        50%;

    background:
        #fff;

    transition:
        border-color .2s ease,
        box-shadow .2s ease;
}


.spi-radio span::after {

    content:
        "";

    position:
        absolute;

    top:
        50%;

    left:
        50%;

    width:
        8px;

    height:
        8px;

    border-radius:
        50%;

    background:
        #22c55e;

    opacity:
        0;

    transform:
        translate(-50%, -50%)
        scale(.5);

    transition:
        opacity .15s ease,
        transform .15s ease;
}


.spi-radio input:checked + span {

    border-color:
        #22c55e;

    box-shadow:
        0 0 0 3px
        rgba(34, 197, 94, .08);
}


.spi-radio input:checked + span::after {

    opacity:
        1;

    transform:
        translate(-50%, -50%)
        scale(1);
}


/* =====================================================
FORM ROW
===================================================== */

.spi-form-row {

    display:
        grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap:
        18px;
}


/* =====================================================
FORM ROW 3
===================================================== */

.spi-form-row-3 {

    display:
        grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap:
        18px;
}


/* =====================================================
FORM ACTIONS
===================================================== */

.spi-form-actions {

    display:
        flex;

    align-items:
        center;

    justify-content:
        flex-end;

    gap:
        10px;

    padding-top:
        8px;
}


/* =====================================================
FORM DIVIDER
===================================================== */

.spi-form-divider {

    display:
        flex;

    align-items:
        center;

    gap:
        14px;

    margin:
        24px 0;

    color:
        #94a3b8;

    font-size:
        11px;
}


.spi-form-divider::before,
.spi-form-divider::after {

    content:
        "";

    flex:
        1;

    height:
        1px;

    background:
        #e2e8f0;
}


/* =====================================================
MOBILE
===================================================== */

@media (max-width: 768px) {

    .spi-form-row,
    .spi-form-row-3 {

        grid-template-columns:
            1fr;
    }

    .spi-form-actions {

        flex-direction:
            column-reverse;

        align-items:
            stretch;
    }

    .spi-form-actions .spi-btn {

        width:
            100%;
    }

}


/* =====================================================
REDUCED MOTION
===================================================== */

@media (prefers-reduced-motion: reduce) {

    .spi-input,
    .spi-password-toggle,
    .spi-checkbox span,
    .spi-radio span,
    .spi-radio span::after {

        transition:
            none !important;
    }

}