/* ===== UI Checkbox Component Styles ===== */

/* Base Checkbox Wrapper */
.ui-checkbox-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.ui-checkbox-container {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* Hide native checkbox */
.ui-checkbox-input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Custom Checkbox Label */
.ui-checkbox-label {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    margin-bottom: 0;
    line-height: 1.5;
    transition: all 0.2s ease;
}

/* Custom Checkbox */
.ui-checkbox-custom {
    box-sizing: border-box !important;
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: var(--layout);
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    margin-top: 2px;
}

.ui-checkbox-wrapper:hover .ui-checkbox-custom{
    background-color: var(--gray-50);
}

/* Checkbox Check Mark */
.ui-checkbox-check {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    color: #fff;
    font-size: 11px;
    line-height: 24px;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    opacity: 0;
}

/* Text Label */
.ui-checkbox-text {
    color: var(--foreground) !important;
    transition: color 0.2s ease;
    font-weight: 500;
}

/* Description */
.ui-checkbox-description {
    font-size: 14px;
    font-weight: 400;
    color: var(--icon);
    margin-top: 4px;
    line-height: 1.4;
    margin-left: 32px;
}

/* ===== STATES ===== */

/* Checked State */
.ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-custom {
    background-color: var(--primary);
    border-color: var(--primary);
}

.ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-check {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* Focus State */
.ui-checkbox-input:focus+.ui-checkbox-label .ui-checkbox-custom {
    border: 2px solid var(--primary);
    outline: 2px solid var(--primary-focus);
}

/* Disabled State */
.ui-checkbox-input:disabled+.ui-checkbox-label,
.ui-checkbox-wrapper.disabled .ui-checkbox-input.disabled+.ui-checkbox-label {
    cursor: not-allowed;
}

.ui-checkbox-input:disabled+.ui-checkbox-label .ui-checkbox-custom,
.ui-checkbox-wrapper.disabled .ui-checkbox-input+.ui-checkbox-label .ui-checkbox-custom{
    background-color: var(--disabled);
    border-color: var(--border);
}

.ui-checkbox-input:disabled .ui-checkbox-check,
.ui-checkbox-wrapper.disabled .ui-checkbox-check {
    color: var(--icon-disabled)
}

    /* ===== VARIANTS ===== */

/* Outline Primary */
.ui-checkbox-wrapper.outline-primary .ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-custom {
    background-color: var(--background);
    border-color: var(--primary);
}

.ui-checkbox-wrapper.outline-primary .ui-checkbox-check {
    color: var(--primary);
}


/* ===== SIZE VARIATIONS ===== */

/* Small Size */
.ui-checkbox-wrapper[data-size="small"] .ui-checkbox-custom,
.ui-checkbox-wrapper.ckb-small .ui-checkbox-custom {
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.ui-checkbox-wrapper[data-size="small"] .ui-checkbox-check,
.ui-checkbox-wrapper.ckb-small .ui-checkbox-check {
    font-size: 10px;
}

.ui-checkbox-wrapper[data-size="small"] .ui-checkbox-text,
.ui-checkbox-wrapper.ckb-small .ui-checkbox-text {
    font-size: 0.875rem;
}

.ui-checkbox-wrapper[data-size="small"] .ui-checkbox-description,
.ui-checkbox-wrapper.ckb-small .ui-checkbox-description {
    font-size: 0.75rem;
    margin-left: 28px;
}

/* Large Size */
.ui-checkbox-wrapper[data-size="large"] .ui-checkbox-custom,
.ui-checkbox-wrapper.ckb-large .ui-checkbox-custom {
    width: 22px;
    height: 22px;
}

.ui-checkbox-wrapper[data-size="large"] .ui-checkbox-check,
.ui-checkbox-wrapper.ckb-large .ui-checkbox-check {
    font-size: 14px;
}

.ui-checkbox-wrapper[data-size="large"] .ui-checkbox-text,
.ui-checkbox-wrapper.ckb-large .ui-checkbox-text {
    font-size: 1.125rem;
}

.ui-checkbox-wrapper[data-size="large"] .ui-checkbox-description,
.ui-checkbox-wrapper.ckb-large .ui-checkbox-description {
    font-size: 1rem;
    margin-left: 36px;
}

/* ===== VALIDATION STYLES ===== */

.ui-checkbox-wrapper .validation-message {
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--danger);
    display: block;
}

.ui-checkbox-wrapper.input-validation-error .ui-checkbox-custom {
    border-color: var(--border-danger);
}

.ui-checkbox-wrapper.input-validation-error .ui-checkbox-text {
    color: var(--danger);
}

/* ===== ANIMATIONS ===== */

/* Bounce Animation */
.ui-checkbox-container.animated .ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-custom {
    animation: checkboxBounce 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes checkboxBounce {
    0% {
        transform: scale(1);
    }

    30% {
        transform: scale(1.15);
    }

    60% {
        transform: scale(0.95);
    }

    100% {
        transform: scale(1.05);
    }
}

/* Check Mark Animation */
.ui-checkbox-container.animated .ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-check {
    animation: checkMarkSlide 0.3s ease 0.1s both;
}

@keyframes checkMarkSlide {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-45deg);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.2) rotate(0deg);
        opacity: 0.8;
    }

    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Ripple Effect Animation */
.ui-checkbox-container.animated .ui-checkbox-custom:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background-color: var(--primary);
    opacity: 0.3;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    pointer-events: none;
}

.ui-checkbox-container.animated .ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-custom:after {
    animation: rippleEffect 0.6s ease;
}

@keyframes rippleEffect {
    0% {
        width: 0;
        height: 0;
        opacity: 0.3;
    }

    50% {
        width: 40px;
        height: 40px;
        opacity: 0.1;
    }

    100% {
        width: 60px;
        height: 60px;
        opacity: 0;
    }
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
    .ui-checkbox-container {
        gap: 10px;
    }

    .ui-checkbox-description {
        margin-left: 30px;
        font-size: 0.8rem;
    }

    .ui-checkbox-wrapper[data-size="small"] .ui-checkbox-description {
        margin-left: 26px;
    }

    .ui-checkbox-wrapper[data-size="large"] .ui-checkbox-description {
        margin-left: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .ui-checkbox-custom,
    .ui-checkbox-check,
    .ui-checkbox-label {
        transition: none;
    }

    .ui-checkbox-container.animated .ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-custom,
    .ui-checkbox-container.animated .ui-checkbox-input:checked+.ui-checkbox-label .ui-checkbox-check {
        animation: none;
    }

    .ui-checkbox-container.animated .ui-checkbox-custom:after {
        display: none;
    }
}
