/*
 * ratinghc.css — RS Karitas Waitabula
 * Halaman Rating / Penilaian Home Care
 *
 * Design system selaras dengan tooplate-style.css & hcstyle.css
 *  - Variabel warna konsisten: --primary #0b3d91, --accent #42b2a6
 *  - Font: Poppins (sama dengan tooplate-style)
 *  - Mobile-first: breakpoint 768px & 480px
 *  - Support light mode & dark mode (body.dark-mode)
 *  - Touch-friendly: tap target minimal 44px
 */


/* ============================================================
   CSS VARIABLES (lokal — fallback jika tooplate-style tidak di-load)
   ============================================================ */
:root {
    --primary:       #0b3d91;
    --accent:        #42b2a6;
    --soft-bg:       #f0f7ff;
    --text-dark:     #1a1a1a;
    --text-muted:    #555;
    --white:         #ffffff;
    --dark-bg:       #0f172a;
    --dark-card:     #1e293b;
    --dark-border:   #334155;
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     18px;
    --radius-pill:   50px;
    --shadow-sm:     0 4px 12px rgba(0,0,0,0.07);
    --shadow-md:     0 8px 25px rgba(0,0,0,0.11);
    --shadow-lg:     0 16px 40px rgba(0,0,0,0.15);
    --transition:    0.3s ease;
    --bounce:        0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}


/* ============================================================
   BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Poppins', Arial, sans-serif;
    background: var(--soft-bg);
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Dark mode base */
body.dark-mode {
    background: #0a0f1e !important;
    color: #e2e8f0;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
    margin-top: 0;
}

h2 { font-size: 1.75rem; color: var(--primary); }
h3 { font-size: 1.35rem; color: var(--primary); }
h4 { font-size: 1.1rem;  color: var(--text-dark); }

body.dark-mode h2,
body.dark-mode h3,
body.dark-mode h4 { color: #7dd3fc !important; }

p  { font-size: 14px; line-height: 1.75; color: var(--text-muted); margin: 0 0 12px; }
a  { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary); text-decoration: underline; }

body.dark-mode p { color: #94a3b8; }
body.dark-mode a { color: #38bdf8; }
body.dark-mode a:hover { color: #7dd3fc; }


/* ============================================================
   PAGE WRAPPER
   ============================================================ */
.rating-page {
    min-height: 100vh;
    padding: 30px 0 60px;
    background: var(--soft-bg);
    transition: background-color 0.4s ease;
}

body.dark-mode .rating-page { background: #0a0f1e; }

.rating-container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 20px;
}


/* ============================================================
   PAGE HEADER
   ============================================================ */
.rating-page-header {
    text-align: center;
    margin-bottom: 32px;
}

.rating-page-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 6px 18px;
    border-radius: var(--radius-pill);
    margin-bottom: 14px;
}

.rating-page-header h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 8px;
}

.rating-page-header p {
    font-size: 14px;
    color: var(--text-muted);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.7;
}

body.dark-mode .rating-page-header h2 { color: #7dd3fc !important; }
body.dark-mode .rating-page-header p  { color: #94a3b8; }


/* ============================================================
   CARD UTAMA (wrapper form)
   ============================================================ */
.rating-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid rgba(11,61,145,0.07);
    margin-bottom: 24px;
    transition: background-color 0.4s ease, border-color 0.4s ease;
}

/* Garis aksen di atas card */
.rating-card::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--primary));
}

.rating-card-body {
    padding: 28px 32px 32px;
}

body.dark-mode .rating-card {
    background: var(--dark-card) !important;
    border-color: var(--dark-border);
}

/* ---- Section label dalam card ---- */
.rating-section-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #eef2ff;
}

.rating-section-label .label-icon {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

body.dark-mode .rating-section-label {
    color: #38bdf8;
    border-bottom-color: var(--dark-border);
}

.divider-line {
    border: none;
    border-top: 1.5px solid #eef2ff;
    margin: 22px 0;
}

body.dark-mode .divider-line { border-top-color: var(--dark-border); }


/* ============================================================
   INFO KUNJUNGAN (readonly summary)
   ============================================================ */
.visit-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 4px;
}

.visit-info-item {
    background: #f6faff;
    border: 1.5px solid #e0eaff;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    transition: border-color var(--transition);
}

.visit-info-item:hover { border-color: var(--accent); }

.visit-info-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 14px;
    flex-shrink: 0;
}

.visit-info-text { flex: 1; min-width: 0; }

.visit-info-text .vi-label {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 3px;
}

.visit-info-text .vi-value {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--primary);
    word-break: break-word;
    line-height: 1.3;
}

body.dark-mode .visit-info-item {
    background: #0f172a;
    border-color: var(--dark-border);
}
body.dark-mode .visit-info-item:hover { border-color: #38bdf8; }
body.dark-mode .visit-info-text .vi-label { color: #64748b; }
body.dark-mode .visit-info-text .vi-value { color: #7dd3fc; }


/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.form-group label .req  { color: #dc2626; margin-left: 2px; }
.form-group label .opt  { color: #9ca3af; font-weight: 400; font-size: 11.5px; margin-left: 4px; }
.form-group label .lbl-icon { color: var(--accent); margin-right: 5px; }

body.dark-mode .form-group label { color: #cbd5e1; }

.form-control {
    width: 100%;
    padding: 11px 16px;
    font-size: 14px;
    font-family: 'Poppins', Arial, sans-serif;
    border: 1.5px solid #e2e8f0;
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--text-dark);
    transition: border-color var(--transition), box-shadow var(--transition);
    -webkit-appearance: none;
    appearance: none;
    /* Tap target minimal 44px untuk mobile */
    min-height: 44px;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(66,178,166,0.18);
    outline: none;
}

.form-control::placeholder { color: #b0bec5; }

textarea.form-control {
    resize: vertical;
    min-height: 110px;
    line-height: 1.65;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2342b2a6' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-color: #fff;
    padding-right: 36px;
    cursor: pointer;
}

body.dark-mode .form-control {
    background: #0f172a !important;
    border-color: var(--dark-border) !important;
    color: #e2e8f0 !important;
}
body.dark-mode .form-control:focus {
    border-color: #38bdf8 !important;
    box-shadow: 0 0 0 3px rgba(56,189,248,0.18) !important;
}
body.dark-mode .form-control::placeholder { color: #475569 !important; }
body.dark-mode select.form-control        { background-color: #0f172a; }
body.dark-mode select.form-control option { background: #1e293b; color: #e2e8f0; }

/* Error state */
.form-control.is-error  { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,0.12) !important; }
.field-error {
    color: #dc2626;
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 18px;
}
body.dark-mode .field-error { color: #fca5a5; }


/* ============================================================
   STAR RATING
   ============================================================ */
.star-rating-wrap {
    background: #f6faff;
    border: 1.5px solid #e0eaff;
    border-radius: var(--radius-lg);
    padding: 22px 20px 18px;
    text-align: center;
    transition: border-color var(--transition), background-color var(--transition);
}

.star-rating-wrap.has-rating {
    border-color: var(--accent);
    background: linear-gradient(135deg, #f0fffe, #edfcfa);
}

.star-rating-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 14px;
}

body.dark-mode .star-rating-title { color: #94a3b8; }

/* Bintang — urutan terbalik agar klik kiri = bintang 1 */
.star-rating {
    display: inline-flex;
    flex-direction: row-reverse;
    gap: 6px;
    justify-content: center;
    margin-bottom: 12px;
}

.star-rating input[type="radio"] { display: none; }

.star-rating label {
    font-size: 38px;
    color: #d1d5db;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    line-height: 1;
    /* Touch target */
    padding: 4px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* Hover & checked — semua bintang ke kiri label yang di-hover/checked */
.star-rating label:hover,
.star-rating label:hover ~ label,
.star-rating input:checked ~ label {
    color: #f59e0b;
    transform: scale(1.15);
}

.star-rating label:hover { transform: scale(1.25); }

.star-rating-desc {
    font-size: 13.5px;
    font-weight: 700;
    min-height: 22px;
    color: var(--primary);
    transition: color var(--transition);
}

/* Warna desc per jumlah bintang */
.star-rating-desc.s1 { color: #dc2626; }
.star-rating-desc.s2 { color: #f97316; }
.star-rating-desc.s3 { color: #eab308; }
.star-rating-desc.s4 { color: #22c55e; }
.star-rating-desc.s5 { color: #0b3d91; }

body.dark-mode .star-rating-wrap {
    background: #0f172a;
    border-color: var(--dark-border);
}
body.dark-mode .star-rating-wrap.has-rating {
    background: #0c2a2a;
    border-color: #38bdf8;
}
body.dark-mode .star-rating label { color: #334155; }
body.dark-mode .star-rating label:hover,
body.dark-mode .star-rating label:hover ~ label,
body.dark-mode .star-rating input:checked ~ label { color: #fbbf24; }
body.dark-mode .star-rating-desc { color: #7dd3fc; }


/* ============================================================
   ASPEK PENILAIAN (checkbox pills)
   ============================================================ */
.aspek-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
}

.aspek-item {
    position: relative;
}

.aspek-item input[type="checkbox"] { display: none; }

.aspek-label {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    border: 1.5px solid #e0eaff;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    background: #f8faff;
    transition: all 0.22s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
}

.aspek-label .aspek-icon {
    width: 28px; height: 28px;
    border-radius: 8px;
    background: #e0eaff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    color: var(--primary);
    flex-shrink: 0;
    transition: all 0.22s;
}

.aspek-label:hover {
    border-color: var(--accent);
    background: #f0fffe;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.aspek-item input:checked + .aspek-label {
    border-color: var(--accent);
    background: linear-gradient(135deg, #f0fffe, #e6fcf8);
    color: var(--primary);
    box-shadow: 0 4px 14px rgba(66,178,166,0.18);
}

.aspek-item input:checked + .aspek-label .aspek-icon {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
}

body.dark-mode .aspek-label {
    background: #0f172a;
    border-color: var(--dark-border);
    color: #cbd5e1;
}
body.dark-mode .aspek-label .aspek-icon { background: #1e293b; color: #38bdf8; }
body.dark-mode .aspek-label:hover { background: #1e3a3a; border-color: #38bdf8; }
body.dark-mode .aspek-item input:checked + .aspek-label {
    background: #0c2a2a;
    border-color: #38bdf8;
    color: #7dd3fc;
}
body.dark-mode .aspek-item input:checked + .aspek-label .aspek-icon {
    background: linear-gradient(135deg, #22d3ee, #3b82f6);
}


/* ============================================================
   SKALA SLIDER (NPS / kepuasan 0-10)
   ============================================================ */
.skala-wrap {
    padding: 6px 0;
}

.skala-input {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%);
    outline: none;
    cursor: pointer;
    margin: 10px 0 14px;
}

.skala-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border: 3px solid #fff;
    box-shadow: 0 3px 10px rgba(11,61,145,0.35);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.skala-input::-moz-range-thumb {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border: 3px solid #fff;
    box-shadow: 0 3px 10px rgba(11,61,145,0.35);
    cursor: pointer;
}

.skala-input:focus::-webkit-slider-thumb { transform: scale(1.2); }

.skala-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11.5px;
    color: #94a3b8;
    font-weight: 600;
    padding: 0 2px;
}

.skala-value-display {
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 6px;
    transition: color 0.2s;
}

body.dark-mode .skala-input {
    background: linear-gradient(90deg, #22d3ee 0%, #3b82f6 100%);
}
body.dark-mode .skala-input::-webkit-slider-thumb {
    background: linear-gradient(135deg, #22d3ee, #3b82f6);
    border-color: #0f172a;
}
body.dark-mode .skala-labels      { color: #475569; }
body.dark-mode .skala-value-display{ color: #38bdf8; }


/* ============================================================
   TOMBOL PILIHAN (radio pills — misal: Ya/Tidak)
   ============================================================ */
.radio-pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.radio-pill input[type="radio"] { display: none; }

.radio-pill-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border: 1.5px solid #e0eaff;
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: #4a5568;
    background: #f8faff;
    transition: all 0.22s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    white-space: nowrap;
}

.radio-pill-label i { font-size: 15px; }

.radio-pill-label:hover {
    border-color: var(--accent);
    background: #f0fffe;
    box-shadow: var(--shadow-sm);
}

.radio-pill input:checked + .radio-pill-label {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 5px 16px rgba(11,61,145,0.25);
}

body.dark-mode .radio-pill-label {
    background: #0f172a;
    border-color: var(--dark-border);
    color: #cbd5e1;
}
body.dark-mode .radio-pill-label:hover {
    background: #1e3a3a;
    border-color: #38bdf8;
}
body.dark-mode .radio-pill input:checked + .radio-pill-label {
    background: linear-gradient(135deg, #22d3ee, #3b82f6);
    border-color: transparent;
}


/* ============================================================
   ALERT / NOTIFIKASI
   ============================================================ */
.alert-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    line-height: 1.6;
    margin-bottom: 18px;
}

.alert-box .alert-icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* Variant info */
.alert-box.alert-info {
    background: linear-gradient(135deg, #eff8ff, #e0f4ff);
    border: 1px solid #bae6fd;
    color: #0369a1;
}
.alert-box.alert-info .alert-icon { background: linear-gradient(135deg, var(--primary), var(--accent)); color: #fff; }

/* Variant sukses */
.alert-box.alert-success {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 1px solid #86efac;
    color: #15803d;
}
.alert-box.alert-success .alert-icon { background: linear-gradient(135deg, #22c55e, #15803d); color: #fff; }

/* Variant error */
.alert-box.alert-error {
    background: #fff5f5;
    border: 1px solid #fca5a5;
    color: #dc2626;
}
.alert-box.alert-error .alert-icon { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }

/* Variant warning */
.alert-box.alert-warning {
    background: #fffbeb;
    border-left: 4px solid #f59e0b;
    color: #92400e;
    border-radius: var(--radius-sm);
}
.alert-box.alert-warning .alert-icon { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }

body.dark-mode .alert-box.alert-info    { background: #0c2a3a; border-color: #0369a1; color: #7dd3fc; }
body.dark-mode .alert-box.alert-success { background: #052e16; border-color: #166534; color: #86efac; }
body.dark-mode .alert-box.alert-error   { background: #2d0f0f; border-color: #991b1b; color: #fca5a5; }
body.dark-mode .alert-box.alert-warning { background: #1c1400; border-color: #d97706; color: #fcd34d; }


/* ============================================================
   TABEL (hasil/riwayat rating)
   ============================================================ */
.rating-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(11,61,145,0.08);
}

.rating-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    min-width: 480px;
}

.rating-table thead tr {
    background: linear-gradient(135deg, var(--primary) 0%, #1a5cb8 50%, var(--accent) 100%);
}

.rating-table thead th {
    color: #fff;
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 15px 18px;
    border: none;
    text-align: left;
    white-space: nowrap;
}

.rating-table thead th i { margin-right: 7px; opacity: 0.85; }

.rating-table tbody tr {
    border-bottom: 1px solid #e8f0fb;
    transition: background-color var(--transition), transform 0.15s ease;
}

.rating-table tbody tr:last-child { border-bottom: none; }
.rating-table tbody tr:nth-child(odd)  { background: #ffffff; }
.rating-table tbody tr:nth-child(even) { background: #f6faff; }

.rating-table tbody tr:hover {
    background: linear-gradient(90deg, #e3f2fd, #f0fbfa) !important;
    box-shadow: inset 4px 0 0 var(--accent);
    transform: translateX(2px);
    position: relative;
}

.rating-table tbody td {
    padding: 13px 18px;
    font-size: 13.5px;
    color: #2d3748;
    border: none;
    vertical-align: middle;
}

/* Badge nilai bintang di tabel */
.star-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 700;
}
.star-badge.s5 { background: #dbeafe; color: #1e40af; }
.star-badge.s4 { background: #dcfce7; color: #15803d; }
.star-badge.s3 { background: #fef9c3; color: #854d0e; }
.star-badge.s2 { background: #fed7aa; color: #9a3412; }
.star-badge.s1 { background: #fee2e2; color: #991b1b; }
.star-badge i  { font-size: 11px; }

body.dark-mode .rating-table-wrap { border-color: var(--dark-border); }
body.dark-mode .rating-table { background: #1e2433; }
body.dark-mode .rating-table tbody tr:nth-child(odd)  { background: #1e2433; }
body.dark-mode .rating-table tbody tr:nth-child(even) { background: #242a3a; }
body.dark-mode .rating-table tbody tr { border-bottom-color: #2c3347; }
body.dark-mode .rating-table tbody tr:hover { background: #2a3550 !important; transform: none; box-shadow: inset 4px 0 0 var(--accent); }
body.dark-mode .rating-table tbody td { color: #d0d8e8; }


/* ============================================================
   TOMBOL UTAMA
   ============================================================ */
.btn-rating {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    padding: 13px 32px;
    border-radius: var(--radius-pill);
    font-family: 'Poppins', Arial, sans-serif;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    letter-spacing: 0.3px;
    /* Tap target */
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Primary */
.btn-rating-primary {
    background: linear-gradient(135deg, var(--accent), var(--primary));
    color: #fff;
    box-shadow: 0 6px 20px rgba(11,61,145,0.25);
}
.btn-rating-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(11,61,145,0.35);
    filter: brightness(1.07);
}
.btn-rating-primary:active { transform: scale(0.97); }

/* Outline */
.btn-rating-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-rating-outline:hover {
    background: var(--primary);
    color: #fff;
    transform: translateY(-2px);
}

/* Ghost */
.btn-rating-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid #e2e8f0;
}
.btn-rating-ghost:hover { border-color: var(--accent); color: var(--accent); background: #f0fffe; }

/* Disabled */
.btn-rating:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    filter: none !important;
    box-shadow: none !important;
}

/* Full width helper */
.btn-full { width: 100%; }

/* Button group */
.btn-group-rating {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

body.dark-mode .btn-rating-primary { background: linear-gradient(135deg, #22d3ee, #3b82f6); }
body.dark-mode .btn-rating-outline {
    color: #38bdf8;
    border-color: #38bdf8;
}
body.dark-mode .btn-rating-outline:hover { background: #38bdf8; color: #0f172a; }
body.dark-mode .btn-rating-ghost { border-color: var(--dark-border); color: #94a3b8; }
body.dark-mode .btn-rating-ghost:hover { border-color: #38bdf8; color: #38bdf8; background: #0c2a3a; }


/* ============================================================
   MODAL KONFIRMASI / SUKSES
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,20,50,0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: fadeModalBg 0.25s ease;
}

@keyframes fadeModalBg {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: #fff;
    border-radius: 22px;
    width: 100%;
    max-width: 480px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 30px 80px rgba(0,0,0,0.25);
    animation: slideModalUp 0.3s var(--bounce);
    scrollbar-width: thin;
}

@keyframes slideModalUp {
    from { transform: translateY(40px) scale(0.95); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* Header modal */
.modal-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px 16px;
    border-bottom: 1.5px solid #eef2ff;
    position: sticky;
    top: 0;
    background: #fff;
    border-radius: 22px 22px 0 0;
    z-index: 2;
}

.modal-header-icon {
    width: 44px; height: 44px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px; flex-shrink: 0;
}

.modal-header h4 { margin: 0 0 2px; font-size: 15px; font-weight: 800; color: var(--primary); }
.modal-header p  { margin: 0; font-size: 12px; color: #94a3b8; }

.modal-close {
    margin-left: auto;
    background: #f1f5f9;
    border: none;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #94a3b8; cursor: pointer; font-size: 14px;
    transition: all 0.2s; flex-shrink: 0;
}
.modal-close:hover { background: #fee2e2; color: #dc2626; }

/* Body modal */
.modal-body { padding: 18px 24px; }

/* Footer modal */
.modal-footer {
    display: flex;
    gap: 12px;
    padding: 14px 24px 22px;
    border-top: 1.5px solid #eef2ff;
    flex-wrap: wrap;
}

/* Dark mode modal */
body.dark-mode .modal-box    { background: var(--dark-card); }
body.dark-mode .modal-header { background: var(--dark-card); border-color: var(--dark-border); }
body.dark-mode .modal-header h4 { color: #38bdf8; }
body.dark-mode .modal-header p  { color: #64748b; }
body.dark-mode .modal-close     { background: #334155; color: #94a3b8; }
body.dark-mode .modal-close:hover { background: #7f1d1d; color: #fca5a5; }
body.dark-mode .modal-footer    { border-color: var(--dark-border); }


/* ============================================================
   SUKSES STATE (setelah submit)
   ============================================================ */
.success-state {
    text-align: center;
    padding: 40px 24px;
}

.success-icon-wrap {
    width: 80px; height: 80px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 36px;
    margin: 0 auto 22px;
    box-shadow: 0 10px 30px rgba(11,61,145,0.25);
    animation: popIn 0.5s var(--bounce);
}

@keyframes popIn {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

.success-state h3 {
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.success-state p {
    color: var(--text-muted);
    font-size: 14px;
    max-width: 380px;
    margin: 0 auto 28px;
    line-height: 1.7;
}

body.dark-mode .success-state h3 { color: #38bdf8 !important; }
body.dark-mode .success-state p  { color: #94a3b8; }


/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

.spinner-ring {
    width: 24px; height: 24px;
    border: 3px solid rgba(11,61,145,0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

body.dark-mode .spinner-ring {
    border-color: rgba(56,189,248,0.15);
    border-top-color: #38bdf8;
}


/* ============================================================
   RESPONSIVE — MOBILE FRIENDLY
   ============================================================ */

/* ---------- 768px — tablet ---------- */
@media (max-width: 768px) {

    .rating-container { padding: 0 16px; }
    .rating-page { padding: 20px 0 50px; }

    .rating-page-header h2 { font-size: 1.5rem; }
    .rating-page-header p  { font-size: 13px; }

    .rating-card-body { padding: 20px 18px 24px; }

    .visit-info-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .visit-info-item { padding: 10px 13px; }
    .visit-info-icon { width: 30px; height: 30px; font-size: 12px; border-radius: 8px; }
    .visit-info-text .vi-value { font-size: 13px; }

    .star-rating label { font-size: 32px; }

    .aspek-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
    .aspek-label { font-size: 12.5px; padding: 9px 12px; }

    .btn-group-rating { flex-direction: column; }
    .btn-group-rating .btn-rating { width: 100%; justify-content: center; }

    .modal-box { max-width: 100%; border-radius: 18px; }
    .modal-header { padding: 16px 18px 14px; }
    .modal-body   { padding: 14px 18px; }
    .modal-footer { padding: 12px 18px 18px; flex-direction: column; }
    .modal-footer .btn-rating { width: 100%; }

    .rating-table thead th { font-size: 11px; padding: 12px 12px; }
    .rating-table tbody td { font-size: 12.5px; padding: 10px 12px; }
}


/* ---------- 480px — HP besar ---------- */
@media (max-width: 480px) {

    .rating-page { padding: 16px 0 40px; }
    .rating-container { padding: 0 12px; }

    .rating-page-badge { font-size: 10px; padding: 5px 14px; }
    .rating-page-header h2 { font-size: 1.3rem; }
    .rating-page-header p  { font-size: 12.5px; }

    .rating-card-body { padding: 16px 14px 20px; }

    /* Info kunjungan — 1 kolom */
    .visit-info-grid { grid-template-columns: 1fr; }

    .star-rating { gap: 4px; }
    .star-rating label { font-size: 28px; padding: 3px; }

    .aspek-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .aspek-label { font-size: 12px; padding: 8px 10px; gap: 7px; }
    .aspek-label .aspek-icon { width: 24px; height: 24px; font-size: 11px; }

    .radio-pill-group { gap: 8px; }
    .radio-pill-label { font-size: 13px; padding: 9px 18px; }

    .skala-value-display { font-size: 1.6rem; }

    .btn-rating { font-size: 13px; padding: 12px 22px; }

    .rating-table thead th { font-size: 10.5px; padding: 10px 10px; }
    .rating-table tbody td { font-size: 12px; padding: 9px 10px; }

    .alert-box { font-size: 13px; padding: 12px 14px; }
}


/* ---------- 360px — HP kecil ---------- */
@media (max-width: 360px) {

    .rating-page-header h2 { font-size: 1.15rem; }
    .rating-card-body { padding: 14px 12px 18px; }
    .rating-card::before { height: 3px; }

    .star-rating label { font-size: 24px; }

    .aspek-grid { grid-template-columns: 1fr 1fr; }
    .aspek-label { font-size: 11px; padding: 7px 9px; }

    .btn-rating { font-size: 12px; min-height: 44px; }

    .modal-box { border-radius: 14px; }
    .modal-header { padding: 14px 14px 12px; }
    .modal-body   { padding: 12px 14px; }
    .modal-footer { padding: 10px 14px 16px; }
}


/* ============================================================
   ACCESSIBILITY
   ============================================================ */
.btn-rating:focus-visible,
.aspek-label:focus-visible,
.radio-pill-label:focus-visible,
.star-rating label:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}


/* ============================================================
   DATA RATING — Statistik & Distribusi
   (dipakai di data_rating_homecare.php)
   ============================================================ */

/* ── Dark Mode Toggle Button ── */
.dm-toggle {
    position: fixed;
    top: 16px; right: 16px;
    z-index: 9999;
    width: 44px; height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(11,61,145,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}
.dm-toggle:hover { transform: scale(1.12); box-shadow: 0 8px 22px rgba(11,61,145,0.45); }

/* ── Grid kartu statistik ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 0;
}

.stat-card {
    background: #f6faff;
    border: 1.5px solid #e0eaff;
    border-radius: 14px;
    padding: 18px 16px;
    text-align: center;
    transition: border-color var(--transition), transform var(--transition);
}

.stat-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.stat-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--accent), var(--primary));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
    margin: 0 auto 10px;
}

.stat-num {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: #6b7a99;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dark mode stat */
body.dark-mode .stat-card           { background: #0f172a; border-color: var(--dark-border); }
body.dark-mode .stat-card:hover     { border-color: #38bdf8; }
body.dark-mode .stat-num            { color: #38bdf8; }
body.dark-mode .stat-label          { color: #64748b; }

/* ── Rata-rata bintang besar ── */
.avg-stars {
    color: #f59e0b;
    font-size: 22px;
    letter-spacing: 3px;
}

/* ── Distribusi bar per bintang ── */
.dist-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 9px;
    font-size: 13px;
}

.dist-label {
    width: 90px;
    font-weight: 600;
    color: #4a5568;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dist-bar-wrap {
    flex: 1;
    background: #eef2ff;
    border-radius: 20px;
    height: 10px;
    overflow: hidden;
}

.dist-bar {
    height: 100%;
    border-radius: 20px;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    transition: width 0.8s ease;
    min-width: 4px;
}

.dist-count {
    width: 30px;
    text-align: right;
    font-weight: 700;
    color: var(--primary);
    font-size: 13px;
    flex-shrink: 0;
}

/* Dark mode distribusi */
body.dark-mode .dist-label      { color: #94a3b8; }
body.dark-mode .dist-bar-wrap   { background: #1e293b; }
body.dark-mode .dist-count      { color: #38bdf8; }

/* ── Search box wrapper ── */
.search-wrap {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-wrap .form-control {
    max-width: 280px;
}

/* ── Responsive statistik ── */
@media (max-width: 480px) {
    .stats-grid                         { grid-template-columns: 1fr 1fr; }
    .stats-grid .stat-card:last-child   { grid-column: 1 / -1; }
    .avg-stars                          { font-size: 18px; }
    .dist-label                         { width: 70px; font-size: 12px; }
    .dist-count                         { font-size: 12px; }
}

@media (max-width: 360px) {
    .stats-grid    { grid-template-columns: 1fr; }
    .stat-card     { padding: 14px 12px; }
    .stat-num      { font-size: 1.6rem; }
    .search-wrap .form-control { max-width: 100%; }
}