/**
 * Frontend Styles for General Rating Plugin
 * RTL Support - Professional Design - Matches event-auction-items style
 */

/* Container */
.gr-rating-container {
    direction: rtl;
    text-align: right;
    font-family: 'Segoe UI', 'Cairo', 'Tajawal', Tahoma, Arial, sans-serif;
    line-height: 1.6;
    margin: 40px 0;
    padding: 30px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Header */
.gr-rating-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e5e7eb;
}

.gr-rating-title {
    font-size: 24px;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 15px 0;
}

.gr-rating-stats {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.gr-stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 15px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 14px;
}

.gr-stat-label {
    color: #6b7280;
}

.gr-stat-value {
    font-weight: 600;
    color: #1a1a1a;
}

/* Already Submitted */
.gr-already-submitted {
    padding: 20px;
    background: #e8f5e9;
    border: 2px solid #4caf50;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
}

.gr-already-submitted p {
    margin: 0;
    font-size: 16px;
    color: #2e7d32;
    font-weight: 500;
}

/* Hide form when already submitted */
.gr-rating-container:has(.gr-already-submitted) .gr-rating-form {
    display: none !important;
}
    padding: 20px;
    background: #d1fae5;
    border: 2px solid #10b981;
    border-radius: 8px;
    text-align: center;
    color: #065f46;
    font-weight: 500;
}

/* Form */
.gr-rating-form {
    margin-top: 20px;
}

.gr-questions-list {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.gr-question-item {
    padding: 20px;
    background: #f9fafb;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.gr-question-label {
    display: block;
    font-weight: 600;
    font-size: 16px;
    color: #1a1a1a;
    margin-bottom: 12px;
}

.gr-question-weight {
    font-size: 13px;
    color: #6b7280;
    font-weight: normal;
}

/* Star Rating */
.gr-star-rating {
    display: flex;
    gap: 8px;
    flex-direction: row-reverse;
    justify-content: flex-end;
    align-items: center;
    pointer-events: auto !important;
    position: relative;
    min-height: 40px;
    visibility: hidden; /* Hide initially to prevent flash */
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Show stars only after initialization is complete */
.gr-star-rating.gr-star-rating-ready {
    visibility: visible;
    opacity: 1;
}

/* Fallback: Show stars after 1 second if JS fails (accessibility) */
@media (prefers-reduced-motion: no-preference) {
    .gr-star-rating:not(.gr-star-rating-ready) {
        animation: gr-show-fallback 0.1s ease 1s forwards;
    }
}

@keyframes gr-show-fallback {
    to {
        visibility: visible;
        opacity: 1;
    }
}

.gr-star-label {
    cursor: pointer !important;
    display: inline-block;
    line-height: 1;
    pointer-events: auto !important;
    position: relative;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.gr-star-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
    z-index: -1;
}

.gr-star-icon {
    font-size: 32px;
    display: inline-block;
    line-height: 1;
    pointer-events: none;
    transition: filter 0.2s ease, color 0.2s ease, opacity 0.2s ease, transform 0.1s ease;
}

/* DEFAULT INACTIVE COLOR - #5f6368 (Gray) */
.gr-star-rating .gr-star-label:not(.is-active) .gr-star-icon {
    color: #5f6368 !important;
    opacity: 1;
}

/* For images/SVG - convert to gray color #5f6368 */
.gr-star-rating .gr-star-label:not(.is-active) .gr-star-icon img,
.gr-star-rating .gr-star-label:not(.is-active) .gr-star-icon svg {
    filter: brightness(0) saturate(100%) invert(37%) sepia(0%) saturate(0%) hue-rotate(0deg) brightness(100%);
    transition: filter 0.2s ease;
}

/* ACTIVE (SELECTED) STATE – #FFAC33 (Gold/Orange) */
.gr-star-rating .gr-star-label.is-active .gr-star-icon {
    color: #FFAC33 !important;
    opacity: 1;
}

/* For images/SVG - convert to gold color #FFAC33 */
.gr-star-rating .gr-star-label.is-active .gr-star-icon img,
.gr-star-rating .gr-star-label.is-active .gr-star-icon svg {
    filter: brightness(0) saturate(100%) invert(67%) sepia(95%) saturate(2000%) hue-rotate(350deg) brightness(105%);
}

/* Hover preview (only when no star is active) - lighter version of gold */
.gr-star-rating:not(:has(.gr-star-label.is-active)) .gr-star-label:hover .gr-star-icon {
    color: #FFAC33 !important;
    opacity: 0.8;
}

.gr-star-rating:not(:has(.gr-star-label.is-active)) .gr-star-label:hover .gr-star-icon img,
.gr-star-rating:not(:has(.gr-star-label.is-active)) .gr-star-label:hover .gr-star-icon svg {
    filter: brightness(0) saturate(100%) invert(67%) sepia(95%) saturate(1500%) hue-rotate(350deg) brightness(120%);
}

/* Fallback for browsers without :has() support */
.gr-star-label.gr-star-hover:not(.is-active) .gr-star-icon {
    color: #FFAC33 !important;
    opacity: 0.8;
}

.gr-star-label.gr-star-hover:not(.is-active) .gr-star-icon img,
.gr-star-label.gr-star-hover:not(.is-active) .gr-star-icon svg {
    filter: brightness(0) saturate(100%) invert(67%) sepia(95%) saturate(1500%) hue-rotate(350deg) brightness(120%);
}
/* This ensures stars only turn gold when JavaScript explicitly sets the class */

/* Active state */
.gr-star-label:active .gr-star-icon {
    transform: scale(0.95);
}

/* True/False */
.gr-true-false-field {
    display: flex;
    gap: 20px;
}

.gr-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.gr-radio-label:hover {
    border-color: #3b82f6;
    background: #eff6ff;
}

.gr-radio-label input[type="radio"]:checked + span {
    font-weight: 600;
}

.gr-radio-label input[type="radio"]:checked ~ span,
.gr-radio-label:has(input[type="radio"]:checked) {
    border-color: #3b82f6;
    background: #eff6ff;
}

/* Multiple Choice - Pills UI (Compact & Professional) */
.gr-choice-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    direction: rtl;
    align-items: flex-start;
    margin-top: 8px;
}

.gr-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

.gr-pill-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
    z-index: -1;
}

.gr-pill-text {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    border-radius: 20px;
    border: 1.5px solid #e5e7eb;
    background: #ffffff;
    color: #374151;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    min-height: 40px;
    box-sizing: border-box;
    text-align: center;
}

/* Default state - White background, light border, dark text */
.gr-pill .gr-pill-text {
    background: #ffffff;
    border-color: #e5e7eb;
    color: #374151;
}

/* Hover state - Slight background highlight */
.gr-pill:hover .gr-pill-text {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #1f2937;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Selected state - Colored background (green/teal), white text */
.gr-pill-input:checked + .gr-pill-text {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);
}

.gr-pill-input:checked + .gr-pill-text:hover {
    background: #059669;
    border-color: #059669;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(16, 185, 129, 0.3);
}

/* Active/pressed state */
.gr-pill:active .gr-pill-text {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.gr-pill-input:checked:active + .gr-pill-text {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

/* Focus state for accessibility */
.gr-pill-input:focus + .gr-pill-text {
    outline: 2px solid #10b981;
    outline-offset: 2px;
}

/* Disabled state (if needed) */
.gr-pill-input:disabled + .gr-pill-text {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* No options message */
.gr-no-options {
    color: #6b7280;
    font-size: 14px;
    font-style: italic;
    padding: 10px 0;
    width: 100%;
}

/* Rating Messages */
.gr-rating-message {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.gr-rating-message p {
    margin: 0 0 15px;
    font-size: 15px;
    color: #1d2327;
}

.gr-rating-message p:last-child {
    margin-bottom: 0;
}

.gr-login-required {
    background: #fff3cd;
    border-color: #f59e0b;
}

.gr-login-required p {
    color: #856404;
    font-weight: 500;
}

.gr-login-required .button {
    margin-top: 10px;
}

.gr-rating-disabled {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
}

.gr-rating-disabled p {
    color: #6b7280;
    font-size: 14px;
    font-style: italic;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .gr-choice-pills {
        gap: 6px;
    }
    
    .gr-pill-text {
        padding: 10px 16px;
        font-size: 13px;
        min-height: 38px;
    }
}

@media (max-width: 480px) {
    .gr-choice-pills {
        gap: 6px;
    }
    
    .gr-pill-text {
        padding: 9px 14px;
        font-size: 13px;
        min-height: 36px;
    }
}

/* Dropdown - Now uses pills UI (same as multiple choice) */
/* Styles are in .gr-choice-pills section above */

/* Direct Score */
.gr-direct-score-field {
    display: flex;
    align-items: center;
    gap: 10px;
}

.gr-score-input {
    width: 120px;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    text-align: center;
}

.gr-score-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.gr-score-label {
    color: #6b7280;
    font-size: 14px;
}

/* Text Field */
.gr-text-field {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;
}

.gr-text-field:focus {
    outline: none;
    border-color: #3b82f6;
}

/* Form Actions */
.gr-form-actions {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #e5e7eb;
}

.gr-submit-button {
    padding: 14px 30px;
    /* Match main template CTA button (e.g. عرض العقار / eai-property-link-button) */
    background: #3e9799;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(62, 151, 153, 0.2);
}

.gr-submit-button:hover {
    background: #2d7a7c;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(62, 151, 153, 0.3);
}

.gr-submit-button:active {
    transform: translateY(0);
}

.gr-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.gr-button-loader {
    display: inline-block;
}

/* Form Message */
.gr-form-message {
    margin-top: 15px;
    padding: 12px 15px;
    border-radius: 8px;
    font-weight: 500;
}

.gr-form-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 2px solid #10b981;
}

.gr-form-message.error {
    background: #fee2e2;
    color: #991b1b;
    border: 2px solid #ef4444;
}

/* Responsive */
@media (max-width: 768px) {
    .gr-rating-container {
        padding: 20px;
        margin: 20px 0;
    }
    
    .gr-rating-title {
        font-size: 20px;
    }
    
    .gr-star-label {
        font-size: 28px;
    }
    
    .gr-true-false-field {
        flex-direction: column;
    }
    
    .gr-submit-button {
        width: 100%;
        justify-content: center;
    }
}

