/**
 * Rating System - Mobile Responsive Styles
 * Optimized cho mobile devices
 */

/* ===== Simple Toast Notification (Native-like) ===== */
.simple-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(51, 40, 30, 0.95);
    color: #fff;
    padding: 20px 30px;
    border-radius: 12px;
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
    z-index: 999999;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 85vw;
    min-width: 280px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    font-weight: 400;
    pointer-events: none;
}

.simple-toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.simple-toast-success {
    background: rgba(51, 40, 30, 0.95);
}

.simple-toast-error {
    background: rgba(176, 0, 32, 0.95);
}

@media (max-width: 768px) {
    .simple-toast {
        padding: 18px 24px;
        font-size: 15px;
        max-width: 90vw;
        min-width: 260px;
        border-radius: 10px;
    }
}

/* ===== Tablet (iPad) - 768px to 991px ===== */
@media (max-width: 991px) {
    .rating-overview-left,
    .customer-images {
        flex: 0 0 100% !important;
        padding: 0 !important;
        margin-bottom: 16px;
    }

    .rating-overview-listdetail-item {
        gap: 12px;
        padding: 4px 0;
    }

    .rating-overview-listdetail-item-rating {
        flex: 0 0 90px;
    }

    .rating-overview-listdetail-item-progress {
        margin: 0 12px;
        height: 10px;
    }

    .rating-overview-listdetail-item-text {
        flex: 0 0 80px;
        font-size: 14px;
    }
}

/* ===== Mobile - 767px and below ===== */
@media (max-width: 767px) {
    /* Container */
    .container {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* Remove top spacing */
    body {
        padding-top: 0 !important;
    }

    .container.mt-4 {
        margin-top: 0 !important;
        padding-top: 0;
    }

    /* Cards */
    .card {
        margin-top: 8px;
        margin-bottom: 1rem;
        border-radius: 12px;
        box-shadow: none;
        border: 1px solid #e0e0e0;
    }

    .card-body {
        padding: 12px;
    }

    .card-title {
        font-size: 17px;
        margin-bottom: 12px !important;
    }

    /* Rating Overview */
    .rating-overview h5 {
        font-size: 16px !important;
    }

    .rating-overview-listdetail {
        margin-top: 12px;
    }

    .rating-overview-listdetail-item {
        gap: 8px;
        padding: 2px 0;
    }

    .rating-overview-listdetail-item-rating {
        flex: 0 0 75px;
    }

    .rating-overview-listdetail-item-rating i {
        font-size: 12px;
    }

    .rating-overview-listdetail-item-progress {
        flex: 1;
        min-width: 0;
        margin: 0 8px;
        height: 6px;
    }

    .rating-overview-listdetail-item-text {
        flex: 0 0 70px;
        font-size: 12px;
    }

    .rating-overview-btn {
        width: 100%;
        margin-top: 12px;
        padding: 12px;
        font-size: 15px;
    }

    /* Customer Images */
    .customer-images {
        margin-top: -40px;
        padding: 0;
        background: transparent;
    }

    .customer-images h6 {
        font-size: 15px;
        margin-bottom: 12px;
    }

    #customerImagesStrip {
        gap: 10px;
        margin: 0 -16px;
        padding: 0 16px 8px;
    }

    .strip-item {
        width: 120px;
        height: 120px;
        border-radius: 10px;
        box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    }

    .strip-item:active {
        transform: scale(0.95);
    }

    .strip-item .overlay-more {
        font-size: 13px;
        background: rgba(0, 0, 0, 0.55);
    }

    /* Filter & Sort Container */
    .d-flex.align-items-center.justify-content-between.flex-wrap.gap-3.mb-3 {
        gap: 12px !important;
    }
    
    .d-flex.align-items-center.justify-content-between.flex-wrap.gap-3.mb-3 > div:first-child {
        flex: 1 1 100%;
        order: 1;
    }
    
    .d-flex.align-items-center.justify-content-between.flex-wrap.gap-3.mb-3 > .ms-auto {
        margin-left: 0 !important;
        order: 2;
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
    
    .fw-semibold.mb-2 {
        font-size: 14px !important;
        margin-bottom: 8px !important;
    }

    /* Rating Items */
    .rating-item {
        padding: 16px;
        margin-bottom: 0;
        border-top: 1px solid rgba(0, 0, 0, 0.08);
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    }
    
    .rating-item + .rating-item {
        border-top: none;
    }
    
    .rating-item:last-child {
        margin-bottom: 12px;
    }

    .rating-item .rounded-circle {
        width: 36px !important;
        height: 36px !important;
    }

    .rating-item .fw-bold {
        font-size: 14px;
    }

    .rating-item .text-muted.small {
        font-size: 12px;
    }

    .rating-content {
        font-size: 14px;
        line-height: 1.6;
    }

    /* Rating Images - Grid */
    .rating-images {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
        margin: 12px 0;
    }

    .rating-image-item {
        width: 100% !important;
        height: 80px !important;
        border-radius: 8px;
    }

    /* Stars in Modal */
    #ratingStars {
        gap: 16px;
        margin: 24px 0;
        padding: 12px 0;
    }

    #ratingStars .rating-star {
        width: 52px;
        height: 52px;
        font-size: 36px;
    }

    #ratingStars .rating-star:active {
        transform: scale(0.85);
    }

    #chosenStars i {
        font-size: 22px;
        margin: 0 4px;
    }

    #ratingLabel {
        font-size: 15px;
        margin-top: 8px;
    }

    /* Filter & Sort */
    #filterStars {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    #filterStars .btn {
        font-size: 13px;
        padding: 6px 12px;
        border-radius: 20px;
        flex: 0 0 auto;
    }

    .btn-sort {
        font-size: 12px !important;
        padding: 6px 10px !important;
        min-width: auto !important;
        white-space: nowrap;
        display: inline-flex !important;
        align-items: center !important;
        gap: 3px !important;
        border: 1px solid #dee2e6 !important;
        background: white !important;
    }

    .btn-sort .label {
        display: none !important;
    }
    
    .btn-sort .value {
        font-size: 12px !important;
        margin: 0 !important;
        font-weight: 500;
    }
    
    .btn-sort i:first-child {
        font-size: 11px !important;
    }
    
    .btn-sort i:last-child {
        font-size: 9px !important;
        margin-left: 2px !important;
    }

    /* Dropdown Menu */
    .sort-dropdown {
        position: relative !important;
    }
    
    .sort-dropdown .dropdown-menu {
        position: absolute !important;
        top: 100% !important;
        right: 0 !important;
        left: auto !important;
        z-index: 1050 !important;
        min-width: 150px !important;
        max-width: 170px !important;
        margin-top: 6px !important;
        border-radius: 8px !important;
        box-shadow: 0 3px 12px rgba(0,0,0,.12) !important;
        padding: 4px !important;
        background: white !important;
        border: 1px solid #dee2e6 !important;
        opacity: 0;
        transform: scale(0.95) translateY(-8px);
        transition: opacity 0.2s ease,
                    transform 0.2s ease;
        pointer-events: none;
        visibility: hidden;
        will-change: opacity, transform;
        display: block !important;
    }

    .sort-dropdown .dropdown-menu.show {
        opacity: 1 !important;
        transform: scale(1) translateY(0) !important;
        pointer-events: auto !important;
        visibility: visible !important;
    }
    
    .sort-dropdown .dropdown-item {
        font-size: 13px !important;
        padding: 10px 12px !important;
        border-radius: 5px !important;
        margin: 1px 0 !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        cursor: pointer !important;
        transition: background-color 0.15s ease;
        min-height: 44px !important;
        -webkit-tap-highlight-color: transparent;
        user-select: none;
        -webkit-user-select: none;
    }
    
    .sort-dropdown .dropdown-item i {
        font-size: 12px !important;
        width: 14px !important;
        flex-shrink: 0;
        pointer-events: none;
    }
    
    .sort-dropdown .dropdown-item:hover {
        background-color: #f8f9fa !important;
    }
    
    .sort-dropdown .dropdown-item:active {
        background-color: #e9ecef !important;
        transform: scale(0.98);
    }
    
    .sort-dropdown .dropdown-item.active {
        background-color: #0d6efd !important;
        color: white !important;
    }
    
    .sort-dropdown .dropdown-item.active:active {
        background-color: #0b5ed7 !important;
    }

    /* Pagination */
    #ratingPager {
        margin-top: 24px;
        gap: 6px;
    }

    #ratingPager .page-link {
        padding: 10px 14px;
        min-width: 44px;
        font-size: 14px;
        border-radius: 8px;
    }

    /* Modal */
    .modal-dialog {
        margin: 12px;
    }

    .modal-header {
        padding: 16px 12px 10px;
    }

    .modal-body {
        padding: 16px 12px;
    }

    .modal-title {
        font-size: 17px;
    }

    /* Form Controls */
    .form-control,
    textarea.form-control {
        font-size: 16px;
        padding: 12px 16px;
        border-radius: 12px;
    }

    textarea.form-control {
        min-height: 110px;
    }

    .form-label {
        font-size: 14px;
        margin-bottom: 8px;
    }

    /* Buttons */
    .btn {
        font-size: 16px;
        padding: 12px 24px;
        border-radius: 12px;
    }

    .btn-sm {
        font-size: 14px;
        padding: 8px 16px;
        border-radius: 8px;
    }

    /* Uploader */
    .uploader {
        padding: 16px;
        border-radius: 12px;
    }

    .thumb {
        width: 80px;
        height: 80px;
        border-radius: 10px;
    }

    /* Gallery Grid */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 8px 0;
    }

    .gallery-card {
        width: 100%;
        min-height: auto;
        border-radius: 8px;
    }

    .gallery-img {
        height: 140px;
    }

    .gallery-meta {
        padding: 6px;
    }

    .gallery-stars {
        font-size: 13px;
    }

    /* All Images Modal */
    #allImagesModal .modal-dialog {
        max-width: 95%;
        margin: 0.5rem auto;
    }

    #allImagesModal .modal-content {
        border-radius: 12px;
    }

    #allImagesModal .modal-header {
        padding: 12px 16px;
    }

    #allImagesModal .modal-title {
        font-size: 16px;
    }

    #allImagesModal .modal-body {
        padding: 12px;
        min-height: auto;
    }

    #allImagesModal #imgFilters {
        gap: 6px;
        padding: 8px 0;
    }

    #allImagesModal .chip {
        font-size: 12px;
        padding: 5px 10px;
    }

    /* Helpful Section - Mobile Layout */
    .rating-item .d-flex.align-items-center.gap-3.mt-2 {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        flex-wrap: nowrap !important;
    }

    .rating-item .d-flex.align-items-center.gap-2 {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
    }

    .rating-item .btn-like-icon {
        width: 32px;
        height: 32px;
        flex-shrink: 0;
    }

    .rating-item .like-text,
    .rating-item .like-count {
        font-size: 13px;
    }

    .rating-item .used-days-text {
        font-size: 12px;
    }

    .rating-item .used-days-text i {
        font-size: 11px;
    }
}

/* ===== Small Mobile - 576px and below ===== */
@media (max-width: 576px) {
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    .card-body {
        padding: 16px 14px;
    }

    .card-title {
        font-size: 18px;
    }

    .strip-item {
        width: 100px !important;
        height: 100px !important;
    }

    .rating-overview-listdetail-item-rating {
        flex: 0 0 70px;
    }

    .rating-overview-listdetail-item-rating i {
        font-size: 11px;
    }

    .rating-overview-listdetail-item-text {
        flex: 0 0 65px;
        font-size: 11px;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .gallery-img {
        height: 120px;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 13px;
        padding: 10px 12px;
    }

    .breadcrumb-item {
        max-width: 90px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* ===== Touch Devices - Optimize for touch ===== */
@media (hover: none) and (pointer: coarse) {
    /* Minimum touch target size */
    .btn,
    .page-link,
    .rating-star,
    .js-chosen-star,
    .js-star {
        min-height: 44px;
        min-width: 44px;
    }

    .btn-sm {
        min-height: 40px;
        min-width: 40px;
    }

    /* Visual feedback on touch */
    .btn:active,
    .page-link:active {
        transform: scale(0.96);
        opacity: 0.9;
    }

    .image-preview,
    .rating-image-item img {
        border: 2px solid transparent;
        transition: border-color 0.15s ease;
    }

    .image-preview:active,
    .rating-image-item img:active {
        border-color: #0d6efd;
    }

    /* Larger form inputs */
    .form-check-input {
        width: 20px;
        height: 20px;
        margin-top: 2px;
    }

    .dropdown-item {
        padding: 14px 16px;
        font-size: 15px;
    }

    /* Remove hover effects */
    .btn:hover,
    .card:hover {
        transform: none;
    }
}

/* ===== Landscape Mobile ===== */
@media (max-width: 767px) and (orientation: landscape) {
    .modal-dialog {
        max-width: 92%;
        margin: 8px auto;
    }

    .rating-list {
        max-height: 450px;
        overflow-y: auto;
    }

    .modal-body {
        max-height: 70vh;
        overflow-y: auto;
    }
}

/* ===== Additional Mobile Styles ===== */
@media (max-width: 767px) {
    /* Fix white space at top */
    .bgmain_min {
        margin-top: 0;
        margin-bottom: 0;
        padding-top: 0;
    }

    .bgmain__breadcrumb {
        padding-top: 8px;
        margin-bottom: 0;
    }

    .breadcrumb {
        padding: 6px 10px;
        margin-bottom: 0;
        font-size: 12px;
        background: transparent;
    }

    /* Card container on mobile */
    .card-body > .d-flex:first-of-type {
        flex-direction: column !important;
    }

    /* Rating overview */
    .rating-overview-left {
        display: block !important;
    }

    .customer-images {
        display: block !important;
    }

    /* Image strip hình vuông */
    .rating-images .rating-image-item {
        width: 100px !important;
        height: 100px !important;
        flex-shrink: 0;
    }

    .rating-images .rating-image-item img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: 8px;
    }
}

