/**
 * Star Rating Input Styles - Final Production Version
 *
 * Styles for input-based star rating component
 * All classes prefixed with 'sri-' (Star Rating Input)
 * @version 2.1.0
 */

/* Main container */
.sri-input {
    display: inline-block;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    line-height: 1;
    /* Match typical input height */
    min-height: 34px;
    padding: 5px 0;
}

/* Stars wrapper */
.sri-input__stars {
    display: inline-flex;
    position: relative;
    font-size: 0;
    gap: 4px;
}

/* Individual star */
.sri-input__star {
    position: relative;
    display: inline-block;
    width: 24px;
    height: 24px;
    cursor: pointer;
    transition: transform 0.15s ease;
}

/* Star character - default */
.sri-input__star::before {
    content: "★";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    font-size: 24px;
    line-height: 1;
    color: #d3d3d3;
    text-align: center;
    transition: color 0.15s ease;
}

/* Filled star */
.sri-input__star--filled::before {
    color: #ffc107;
}

/* Hover state */
.sri-input__star--hover::before {
    color: #ffdb58;
}

.sri-input__star:hover {
    transform: scale(1.1);
}

/* Half star support */
.sri-input__half {
    position: absolute;
    top: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
    cursor: pointer;
}

.sri-input__half--left {
    left: 0;
}

.sri-input__half--right {
    right: 0;
}

/* Half star filled */
.sri-input__star--half::before {
    color: #d3d3d3;
}

.sri-input__star--half::after {
    content: "★";
    position: absolute;
    top: 0;
    left: 0;
    /* Overlay the gold star exactly on top of the grey one — SAME width + alignment as
       ::before — then clip it to the left half. Works for every icon set. The old
       width:50% + text-align:center rendered a misaligned centre slice that looked like
       a broken/whole star, which made half ratings appear impossible to set. */
    width: 100%;
    height: 100%;
    font-size: 24px;
    line-height: 1;
    color: #ffc107;
    text-align: center;
    overflow: hidden;
    clip-path: inset(0 50% 0 0);
}

/* Hover for half stars */
.sri-input__star--half.sri-input__star--hover::after {
    color: #ffdb58;
}

/* Disabled state */
.sri-input--disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sri-input--disabled .sri-input__star,
.sri-input--disabled .sri-input__half {
    cursor: not-allowed;
    pointer-events: none;
}

/* Readonly state */
.sri-input--readonly .sri-input__star,
.sri-input--readonly .sri-input__half {
    cursor: default;
}

.sri-input--readonly .sri-input__star:hover {
    transform: none;
}

/* Required state - optional visual indicator */
.sri-input--required::after {
    content: "*";
    color: #dc3545;
    margin-left: 4px;
    font-weight: bold;
}

/* Focus styles for accessibility */
.sri-input:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Size variants based on input classes */
.sri-input.form-control-sm .sri-input__star,
.sri-input.input-sm .sri-input__star {
    width: 18px;
    height: 18px;
}

.sri-input.form-control-sm .sri-input__star::before,
.sri-input.form-control-sm .sri-input__star--half::after,
.sri-input.input-sm .sri-input__star::before,
.sri-input.input-sm .sri-input__star--half::after {
    font-size: 18px;
}

.sri-input.form-control-lg .sri-input__star,
.sri-input.input-lg .sri-input__star {
    width: 32px;
    height: 32px;
}

.sri-input.form-control-lg .sri-input__star::before,
.sri-input.form-control-lg .sri-input__star--half::after,
.sri-input.input-lg .sri-input__star::before,
.sri-input.input-lg .sri-input__star--half::after {
    font-size: 32px;
}

/* Animation for value changes */
@keyframes sri-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.sri-input__star--filled {
    animation: sri-pulse 0.3s ease;
}

/* Custom colors through CSS variables */
.sri-input {
    --sri-star-color: #d3d3d3;
    --sri-star-filled: #ffc107;
    --sri-star-hover: #ffdb58;
}

.sri-input__star::before {
    color: var(--sri-star-color, #d3d3d3);
}

.sri-input__star--filled::before,
.sri-input__star--half::after {
    color: var(--sri-star-filled, #ffc107);
}

.sri-input__star--hover::before,
.sri-input__star--half.sri-input__star--hover::after {
    color: var(--sri-star-hover, #ffdb58);
}

/* ==========================================
   ICON FONT CONFIGURATIONS
   ========================================== */

/* Heroicons configuration */
.sri-input--heroicons .sri-input__star::before,
.sri-input--heroicons .sri-input__star--half::after {
    font-family: 'heroicons-solid' !important;
    content: "\ea0a";
    speak: never;
    font-style: normal;
    font-weight: normal;
    font-variant: normal;
    text-transform: none;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Font Awesome configuration */
.sri-input--fa .sri-input__star::before,
.sri-input--fa .sri-input__star--half::after {
    font-family: "Font Awesome 5 Free", "Font Awesome 6 Free";
    font-weight: 900;
    content: "\f005"; /* fa-star */
}

/* Material Icons configuration */
.sri-input--material .sri-input__star::before,
.sri-input--material .sri-input__star--half::after {
    font-family: 'Material Icons';
    font-weight: normal;
    content: "\e838"; /* star */
    font-feature-settings: 'liga';
}

/* Bootstrap Icons configuration */
.sri-input--bootstrap .sri-input__star::before,
.sri-input--bootstrap .sri-input__star--half::after {
    font-family: 'bootstrap-icons';
    content: "\f586"; /* star-fill */
}

/* Custom SVG star (alternative to fonts) */
.sri-input--svg .sri-input__star::before,
.sri-input--svg .sri-input__star--half::after {
    content: "";
    width: 100%;
    height: 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23d3d3d3'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.sri-input--svg .sri-input__star--filled::before,
.sri-input--svg .sri-input__star--half::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffc107'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
}

.sri-input--svg .sri-input__star--hover::before,
.sri-input--svg .sri-input__star--half.sri-input__star--hover::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffdb58'%3E%3Cpath d='M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z'/%3E%3C/svg%3E");
}
