/* ===========================================
   REFERENCES FORM CSS - FORM CREATE/UPDATE
   Khusus untuk form create dan update references
   Bootstrap 5 Compatible
   File: references-form.css
   =========================================== */

/* ===========================================
   CSS VARIABLES
   =========================================== */
:root {
    --form-gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --form-gradient-secondary: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    --form-primary-color: #667eea;
    --form-primary-dark: #764ba2;
    --form-border-color: #e9ecef;
    --form-focus-color: #667eea;
    --form-shadow: 0 4px 20px rgba(0,0,0,0.08);
    --form-shadow-hover: 0 8px 25px rgba(102, 126, 234, 0.3);
    --form-transition: all 0.3s ease;
    --form-radius: 8px;
    --form-radius-lg: 12px;
}

/* ===========================================
   FORM CONTAINER & LAYOUT
   =========================================== */
.penduduk-form-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

.penduduk-form-wrapper .container-fluid {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ===========================================
   CARD COMPONENTS
   =========================================== */
.penduduk-form-card {
    border: none;
    border-radius: var(--form-radius-lg);
    box-shadow: var(--form-shadow);
    margin-bottom: 2rem;
    background: white;
}

.penduduk-form-card .card-header {
    background: var(--form-gradient-primary);
    border-radius: var(--form-radius-lg) var(--form-radius-lg) 0 0 !important;
    border: none;
    padding: 1.5rem;
}

.penduduk-form-card .card-header h6 {
    color: white !important;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.penduduk-form-card .card-header i {
    margin-right: 0.5rem;
}

.penduduk-form-card .card-body {
    padding: 2rem;
}

/* ===========================================
   FORM FIELDS
   =========================================== */
.penduduk-form-field {
    margin-bottom: 1.5rem;
}

.penduduk-form-field .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.penduduk-form-field .form-label .text-danger {
    color: #dc3545;
}

.penduduk-form-field .form-control {
    border: 2px solid var(--form-border-color);
    border-radius: var(--form-radius);
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    transition: var(--form-transition);
    min-height: 45px;
}

.penduduk-form-field .form-control:focus {
    border-color: var(--form-focus-color);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    transform: translateY(-1px);
}

.penduduk-form-field .form-control::placeholder {
    color: #adb5bd;
}

.penduduk-form-field .form-control:disabled,
.penduduk-form-field .form-control[readonly] {
    background-color: #f8f9fa;
    opacity: 0.7;
    cursor: not-allowed;
}

/* Textarea specific */
.penduduk-form-field textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Select dropdown improvements */
.penduduk-form-field select.form-control {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* Input with icon */
.penduduk-form-field .input-group .input-group-text {
    background-color: #f8f9fa;
    border: 2px solid var(--form-border-color);
    border-right: none;
    color: #6c757d;
}

.penduduk-form-field .input-group .form-control {
    border-left: none;
}

.penduduk-form-field .input-group:focus-within .input-group-text {
    border-color: var(--form-focus-color);
    background-color: white;
}

/* Form text / help text */
.penduduk-form-field .form-text {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.25rem;
}

.penduduk-form-field .form-text i {
    margin-right: 0.25rem;
}

/* Invalid feedback */
.penduduk-form-field .invalid-feedback {
    font-size: 0.85rem;
    font-weight: 500;
    display: block;
    margin-top: 0.25rem;
}

.penduduk-form-field .form-control.is-invalid {
    border-color: #dc3545;
}

/* ===========================================
   BUTTONS
   =========================================== */
.penduduk-form-btn {
    border-radius: var(--form-radius);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: var(--form-transition);
    border: none;
    font-size: 0.95rem;
}

.penduduk-form-btn i {
    margin-right: 0.5rem;
}

.penduduk-form-btn-primary {
    background: var(--form-gradient-primary);
    color: white;
    border: none;
}

.penduduk-form-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--form-shadow-hover);
    color: white;
}

.penduduk-form-btn-primary:active {
    transform: translateY(0);
}

.penduduk-form-btn-secondary {
    border: 2px solid #6c757d;
    color: #6c757d;
    background: white;
}

.penduduk-form-btn-secondary:hover {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
    transform: translateY(-2px);
}

.penduduk-form-btn-outline-info {
    border: 2px solid #17a2b8;
    color: #17a2b8;
    background: white;
}

.penduduk-form-btn-outline-info:hover {
    background-color: #17a2b8;
    border-color: #17a2b8;
    color: white;
    transform: translateY(-2px);
}

.penduduk-form-btn-outline-success {
    border: 2px solid #28a745;
    color: #28a745;
    background: white;
}

.penduduk-form-btn-outline-success:hover {
    background-color: #28a745;
    border-color: #28a745;
    color: white;
    transform: translateY(-2px);
}

.penduduk-form-btn-warning {
    background: linear-gradient(135deg, #ffc107, #ff9800);
    color: #000;
    border: none;
    font-weight: 600;
}

.penduduk-form-btn-warning:hover {
    background: linear-gradient(135deg, #ffb300, #ff8f00);
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 152, 0, 0.4);
}

.penduduk-form-btn-warning:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(255, 152, 0, 0.3);
}

.penduduk-form-btn-outline-primary {
    border: 2px solid var(--form-primary-color);
    color: var(--form-primary-color);
    background: white;
}

.penduduk-form-btn-outline-primary:hover {
    background: var(--form-gradient-primary);
    border-color: transparent;
    color: white;
    transform: translateY(-2px);
}

/* Button group */
.penduduk-form-btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===========================================
   PHOTO UPLOAD SECTION
   =========================================== */
.penduduk-photo-container {
    text-align: center;
}

.penduduk-photo-large {
    width: 200px;
    height: 200px;
    margin: 0 auto 1rem;
    border-radius: var(--form-radius-lg);
    overflow: hidden;
    border: 3px solid var(--form-border-color);
    transition: var(--form-transition);
    position: relative;
}

.penduduk-photo-large:hover {
    border-color: var(--form-primary-color);
    transform: scale(1.02);
}

.penduduk-photo-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.penduduk-photo-placeholder-large {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--form-gradient-secondary);
    color: #6c757d;
}

.penduduk-photo-placeholder-large i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.penduduk-photo-placeholder-large p {
    margin: 0;
    font-size: 0.9rem;
}

/* ===========================================
   STATUS SWITCH
   =========================================== */
.penduduk-status-switch {
    padding: 1rem;
}

.penduduk-status-switch .custom-control-label {
    font-weight: 500;
    color: #495057;
}

.penduduk-status-switch .custom-control-input:checked ~ .custom-control-label::before {
    background-color: var(--form-primary-color);
    border-color: var(--form-primary-color);
}

/* ===========================================
   PAGE HEADER
   =========================================== */
.penduduk-form-header {
    margin-bottom: 2rem;
}

.penduduk-form-header h1,
.penduduk-form-header h2 {
    color: #2c3e50;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.penduduk-form-header .text-muted {
    color: #6c757d !important;
    font-size: 0.95rem;
}

.penduduk-form-header i {
    margin-right: 0.5rem;
}

/* ===========================================
   LOADING OVERLAY
   =========================================== */
.penduduk-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--form-radius);
    z-index: 10;
}

.penduduk-loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--form-primary-color);
    border-radius: 50%;
    animation: penduduk-spin 1s linear infinite;
}

@keyframes penduduk-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===========================================
   ALERT / NOTIFICATION
   =========================================== */
.penduduk-form-alert {
    border-radius: var(--form-radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.penduduk-form-alert i {
    margin-right: 0.75rem;
}

.penduduk-form-alert.alert-info {
    border-left-color: #17a2b8;
    background-color: #d1ecf1;
    color: #0c5460;
}

.penduduk-form-alert.alert-success {
    border-left-color: #28a745;
    background-color: #d4edda;
    color: #155724;
}

.penduduk-form-alert.alert-warning {
    border-left-color: #ffc107;
    background-color: #fff3cd;
    color: #856404;
}

.penduduk-form-alert.alert-danger {
    border-left-color: #dc3545;
    background-color: #f8d7da;
    color: #721c24;
}

/* ===========================================
   FORM GRID
   =========================================== */
.penduduk-form-row {
    margin: 0 -10px;
}

.penduduk-form-row > [class*="col"] {
    padding: 0 10px;
}

/* ===========================================
   DROPDOWN MENU
   =========================================== */
.penduduk-form-dropdown .dropdown-menu {
    border-radius: var(--form-radius);
    box-shadow: var(--form-shadow);
    border: 1px solid var(--form-border-color);
}

.penduduk-form-dropdown .dropdown-item {
    padding: 0.75rem 1.25rem;
    transition: var(--form-transition);
}

.penduduk-form-dropdown .dropdown-item:hover {
    background-color: #f8f9fa;
    color: var(--form-primary-color);
}

.penduduk-form-dropdown .dropdown-item i {
    margin-right: 0.5rem;
    width: 1.25rem;
}

/* ===========================================
   RESPONSIVE STYLES
   =========================================== */

/* Tablet */
@media (max-width: 768px) {
    .penduduk-form-wrapper {
        padding: 0 10px;
    }
    
    .penduduk-form-card .card-body {
        padding: 1.5rem;
    }
    
    .penduduk-form-field .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .penduduk-photo-large {
        width: 150px;
        height: 150px;
    }
    
    .penduduk-form-header h1,
    .penduduk-form-header h2 {
        font-size: 1.5rem;
    }
    
    .penduduk-form-btn-group {
        flex-direction: column;
    }
    
    .penduduk-form-btn-group .penduduk-form-btn {
        width: 100%;
    }
}

/* Mobile */
@media (max-width: 576px) {
    .penduduk-form-card .card-body {
        padding: 1rem;
    }
    
    .penduduk-form-btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .penduduk-photo-large {
        width: 120px;
        height: 120px;
    }
    
    .penduduk-form-header {
        margin-bottom: 1.5rem;
    }
    
    .penduduk-form-row {
        margin: 0 -5px;
    }
    
    .penduduk-form-row > [class*="col"] {
        padding: 0 5px;
    }
}

/* ===========================================
   PRINT STYLES
   =========================================== */
@media print {
    .penduduk-form-btn,
    .penduduk-form-dropdown,
    .penduduk-photo-large:hover {
        display: none !important;
    }
    
    .penduduk-form-card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
    
    .penduduk-form-card .card-header {
        background: white !important;
        color: black !important;
        border-bottom: 2px solid #dee2e6;
    }
}

/* ===========================================
   ACCESSIBILITY
   =========================================== */
.penduduk-form-field .form-control:focus-visible {
    outline: 2px solid var(--form-primary-color);
    outline-offset: 2px;
}

.penduduk-form-btn:focus-visible {
    outline: 2px solid var(--form-primary-color);
    outline-offset: 2px;
}

/* Screen reader only */
.penduduk-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===========================================
   UTILITY CLASSES
   =========================================== */
.penduduk-text-primary {
    color: var(--form-primary-color) !important;
}

.penduduk-text-muted {
    color: #6c757d !important;
}

.penduduk-bg-light {
    background-color: #f8f9fa !important;
}

.penduduk-shadow {
    box-shadow: var(--form-shadow) !important;
}

.penduduk-shadow-lg {
    box-shadow: var(--form-shadow-hover) !important;
}

.penduduk-rounded {
    border-radius: var(--form-radius) !important;
}

.penduduk-rounded-lg {
    border-radius: var(--form-radius-lg) !important;
}

/* Gap utilities for flex */
.penduduk-gap-2 {
    gap: 0.5rem;
}

.penduduk-gap-3 {
    gap: 1rem;
}

/* ===========================================
   ANIMATION CLASSES
   =========================================== */
@keyframes penduduk-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.penduduk-fade-in {
    animation: penduduk-fadeIn 0.3s ease-in-out;
}

@keyframes penduduk-slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

.penduduk-slide-in {
    animation: penduduk-slideIn 0.3s ease-out;
}

/* ===========================================
   RESPONSIVE - MOBILE FIRST
   =========================================== */

/* Tablet dan ke bawah (992px) */
@media (max-width: 991.98px) {
    .penduduk-form-wrapper {
        padding: 1rem;
    }
    
    .penduduk-form-header {
        margin-bottom: 1.5rem;
    }
    
    .penduduk-form-header h1 {
        font-size: 1.5rem;
    }
    
    .penduduk-form-btn-group {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .penduduk-form-btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
    }
    
    .penduduk-form-card {
        margin-bottom: 1rem;
    }
    
    .penduduk-form-card .card-header h6 {
        font-size: 0.95rem;
    }
    
    .penduduk-form-card .card-body {
        padding: 1rem;
    }
    
    .penduduk-form-field {
        margin-bottom: 0.875rem;
    }
    
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.375rem;
    }
    
    .form-control,
    .form-select {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    textarea.form-control {
        min-height: 80px;
    }
}

/* Mobile (576px ke bawah) */
@media (max-width: 575.98px) {
    .penduduk-form-wrapper {
        padding: 0.75rem;
    }
    
    .penduduk-form-header {
        margin-bottom: 1rem;
    }
    
    .penduduk-form-header h1 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
    
    .penduduk-form-header p {
        font-size: 0.8rem;
    }
    
    .penduduk-form-btn-group {
        width: 100%;
        flex-direction: column;
    }
    
    .penduduk-form-btn,
    .penduduk-form-dropdown {
        width: 100%;
    }
    
    .penduduk-form-btn {
        padding: 0.625rem 1rem;
        font-size: 0.85rem;
        justify-content: center;
    }
    
    .penduduk-form-btn i {
        margin-right: 0.375rem;
    }
    
    /* Card styling mobile */
    .penduduk-form-card {
        border-radius: 8px;
        margin-bottom: 0.875rem;
    }
    
    .penduduk-form-card .card-header {
        padding: 0.75rem 1rem;
    }
    
    .penduduk-form-card .card-header h6 {
        font-size: 0.9rem;
        margin-bottom: 0;
    }
    
    .penduduk-form-card .card-body {
        padding: 0.875rem;
    }
    
    /* Form fields mobile */
    .penduduk-form-field {
        margin-bottom: 0.75rem;
    }
    
    .penduduk-form-field .form-label {
        font-size: 0.8rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
    }
    
    .penduduk-form-field .form-control,
    .penduduk-form-field .form-select {
        font-size: 0.85rem;
        padding: 0.5rem 0.625rem;
        height: auto;
        min-height: 38px;
    }
    
    .penduduk-form-field textarea.form-control {
        min-height: 70px;
        padding: 0.5rem 0.625rem;
    }
    
    .penduduk-form-field small {
        font-size: 0.7rem;
    }
    
    .penduduk-form-field .invalid-feedback {
        font-size: 0.75rem;
    }
    
    /* Photo upload mobile */
    .penduduk-form-card img {
        max-width: 150px !important;
    }
    
    /* Switch mobile */
    .penduduk-status-switch .custom-control-label {
        font-size: 0.85rem;
    }
    
    /* Alert mobile */
    .penduduk-form-alert {
        padding: 0.625rem 0.875rem;
        font-size: 0.8rem;
    }
    
    .penduduk-form-alert i {
        font-size: 0.85rem;
    }
    
    /* Action buttons sidebar mobile */
    .d-grid .penduduk-form-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    /* Row spacing mobile */
    .penduduk-form-row .row {
        margin-left: -0.5rem;
        margin-right: -0.5rem;
    }
    
    .penduduk-form-row .row > [class*='col-'] {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
}

/* Extra small mobile (400px ke bawah) */
@media (max-width: 399.98px) {
    .penduduk-form-wrapper {
        padding: 0.5rem;
    }
    
    .penduduk-form-header h1 {
        font-size: 1.1rem;
    }
    
    .penduduk-form-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .penduduk-form-card .card-header {
        padding: 0.625rem 0.75rem;
    }
    
    .penduduk-form-card .card-header h6 {
        font-size: 0.85rem;
    }
    
    .penduduk-form-card .card-body {
        padding: 0.75rem;
    }
    
    .penduduk-form-field {
        margin-bottom: 0.625rem;
    }
    
    .penduduk-form-field .form-label {
        font-size: 0.75rem;
    }
    
    .penduduk-form-field .form-control,
    .penduduk-form-field .form-select {
        font-size: 0.8rem;
        padding: 0.425rem 0.5rem;
        min-height: 36px;
    }
    
    .penduduk-form-field small {
        font-size: 0.65rem;
    }
}

/* Large desktop optimization (1400px ke atas) */
@media (min-width: 1400px) {
    .penduduk-form-wrapper {
        max-width: 1320px;
        margin: 0 auto;
    }
    
    .penduduk-form-card .card-body {
        padding: 2rem;
    }
    
    .penduduk-form-field {
        margin-bottom: 1.5rem;
    }
}

/* Action buttons cards at bottom - better spacing */
.penduduk-form-card .d-grid .penduduk-form-btn {
    padding: 0.75rem 1.5rem;
}

.penduduk-form-card .d-grid {
    gap: 0.75rem !important;
}

/* Additional mobile optimizations */
@media (max-width: 575.98px) {
    /* Stack buttons vertically on mobile header */
    .penduduk-form-header .d-flex {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .penduduk-form-header .mb-3 {
        margin-bottom: 0.75rem !important;
    }
    
    /* Full width dropdowns on mobile */
    .penduduk-form-dropdown .dropdown-menu {
        min-width: 100%;
    }
    
    /* Better touch targets for mobile */
    .penduduk-form-field .form-control:focus,
    .penduduk-form-field .form-select:focus {
        border-width: 2px;
        padding: calc(0.5rem - 1px) calc(0.625rem - 1px);
    }
    
    /* Reduce gap between label and input on mobile */
    .penduduk-form-field .form-label + .form-control,
    .penduduk-form-field .form-label + .form-select {
        margin-top: 0.25rem;
    }
    
    /* Better checkbox/switch on mobile */
    .custom-control {
        padding-left: 2rem;
        min-height: 1.75rem;
    }
    
    .custom-control-label::before,
    .custom-control-label::after {
        width: 1.5rem;
        height: 1.5rem;
        left: -2rem;
    }
    
    /* Sidebar cards stacking on mobile */
    .col-lg-4.col-12 .penduduk-form-card:last-child {
        margin-bottom: 1rem;
    }
    
    /* Action button cards on mobile - full width and compact */
    .penduduk-form-card .d-grid .penduduk-form-btn {
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    
    .penduduk-form-card .card-header h6 i {
        font-size: 0.85rem;
    }
}

/* Portrait mode specific adjustments */
@media (max-width: 575.98px) and (orientation: portrait) {
    .penduduk-form-header h1 {
        font-size: 1.2rem;
    }
    
    .penduduk-form-card .card-header h6 {
        font-size: 0.875rem;
    }
}

/* Landscape mode specific adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .penduduk-form-wrapper {
        padding: 0.75rem;
    }
    
    .penduduk-form-card {
        margin-bottom: 0.75rem;
    }
    
    .penduduk-form-field {
        margin-bottom: 0.625rem;
    }
}

/* ===========================================
   DROPDOWN SEARCH RESULTS STYLING
   Untuk semua dropdown pencarian penduduk
   =========================================== */

/* Dropdown container */
#ketua_lorong_dropdown,
#ketua_rt_dropdown,
#ketua_rw_dropdown,
#kepala_dusun_dropdown,
#disPendudukDropdown,
#pelajarPendudukDropdown {
    position: absolute;
    width: 100%;
    max-height: 400px;
    overflow-y: auto;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: var(--form-radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    margin-top: 4px;
}

/* Search results container */
#ketua_lorong_results,
#ketua_rt_results,
#ketua_rw_results,
#searchResults {
    padding: 4px;
}

/* Individual result item */
.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    background: white;
}

.search-result-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: var(--form-primary-color);
    transform: translateX(2px);
}

.search-result-item:last-child {
    margin-bottom: 0;
}

.search-result-item.selected {
    background: linear-gradient(135deg, #e7f3ff 0%, #d4e9ff 100%);
    border-color: var(--form-primary-color);
}

/* Avatar placeholder */
.avatar-placeholder {
    width: 48px;
    height: 48px;
    background: var(--form-gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.avatar-placeholder i {
    color: white;
    font-size: 20px;
}

/* Result info */
.result-info {
    flex: 1;
    min-width: 0;
}

.result-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.result-details {
    font-size: 0.875rem;
    color: #6c757d;
    line-height: 1.6;
}

.result-details i {
    margin-right: 6px;
    width: 14px;
    color: var(--form-primary-color);
}

/* Loading state */
.loading,
.no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 0.9rem;
}

.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Penduduk item (untuk Bootstrap dropdown) */
.dropdown-item.penduduk-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    margin: 2px 4px;
}

.dropdown-item.penduduk-item:hover {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-color: var(--form-primary-color);
}

.dropdown-item.penduduk-item .d-flex {
    align-items: center;
}

.dropdown-item.penduduk-item .fw-bold {
    font-size: 0.95rem;
    color: #2c3e50;
    margin-bottom: 2px;
}

.dropdown-item.penduduk-item .text-muted {
    font-size: 0.85rem;
    line-height: 1.4;
}

/* ===========================================
   GLOBAL MOBILE RESPONSIVE FOR ALL FORMS
   Extra compact untuk mobile dengan 2 kolom button layout
   =========================================== */

/* Mobile: Compact header dengan smaller buttons */
@media (max-width: 767.98px) {
    /* Page header lebih compact */
    .row.mb-4 {
        margin-bottom: 1rem !important;
    }
    
    /* Title lebih kecil */
    h1.h4, h1.h3 {
        font-size: 1.1rem !important;
    }
    
    /* Subtitle lebih kecil */
    .text-muted.mb-0 {
        font-size: 0.8rem !important;
    }
    
    /* Button group header - flex column on mobile */
    .d-flex.gap-2 {
        gap: 0.5rem !important;
    }
    
    /* Card spacing lebih compact */
    .card {
        margin-bottom: 1rem !important;
        border-radius: 8px !important;
    }
    
    .card-header {
        padding: 0.875rem 1rem !important;
        border-radius: 8px 8px 0 0 !important;
    }
    
    .card-header h6 {
        font-size: 0.9rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
    
    .card-body.p-3 {
        padding: 0.75rem !important;
    }
    
    /* Form fields lebih compact */
    .form-label {
        font-size: 0.85rem !important;
        margin-bottom: 0.375rem !important;
    }
    
    .form-control,
    .form-select {
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
        min-height: 38px !important;
    }
    
    textarea.form-control {
        padding: 0.5rem 0.75rem !important;
    }
    
    /* Small text */
    small, .small {
        font-size: 0.75rem !important;
    }
    
    /* Buttons lebih compact */
    .btn-sm {
        padding: 0.375rem 0.75rem !important;
        font-size: 0.8rem !important;
    }
    
    /* 2 kolom button layout */
    .row.g-2 {
        row-gap: 0.5rem !important;
        column-gap: 0.5rem !important;
    }
    
    /* Custom switch/checkbox lebih compact */
    .custom-control-label {
        font-size: 0.875rem !important;
    }
    
    /* Form sections spacing */
    .mb-3, .mb-4 {
        margin-bottom: 0.75rem !important;
    }
    
    .mb-2 {
        margin-bottom: 0.5rem !important;
    }
    
    /* Dropdown menu */
    .dropdown-menu {
        font-size: 0.875rem !important;
        max-height: 250px !important;
    }
    
    .dropdown-item {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.85rem !important;
    }
    
    /* Dropdown search results container on mobile */
    #ketua_lorong_dropdown,
    #ketua_rt_dropdown,
    #ketua_rw_dropdown,
    #kepala_dusun_dropdown,
    #disPendudukDropdown,
    #pelajarPendudukDropdown {
        max-height: 300px !important;
        border-radius: 6px !important;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* Avatar placeholder smaller */
    .avatar-placeholder {
        width: 32px !important;
        height: 32px !important;
    }
    
    .avatar-placeholder i {
        font-size: 14px !important;
    }
    
    /* Search results compact */
    .search-result-item,
    .penduduk-item {
        padding: 0.5rem 0.75rem !important;
    }
    
    .result-name {
        font-size: 0.875rem !important;
    }
    
    .result-details {
        font-size: 0.8rem !important;
        line-height: 1.5 !important;
    }
    
    .result-details i {
        width: 12px !important;
        font-size: 0.75rem !important;
        margin-right: 4px !important;
    }
    
    /* Selected item compact */
    .selected-item {
        padding: 0.5rem !important;
    }
    
    /* Badge smaller */
    .badge {
        font-size: 0.7rem !important;
        padding: 0.25rem 0.5rem !important;
    }
    
    /* Invalid/valid feedback */
    .invalid-feedback,
    .valid-feedback {
        font-size: 0.75rem !important;
    }
}

/* Extra small mobile (< 576px) - ultra compact */
@media (max-width: 575.98px) {
    /* Container padding minimal */
    .container-fluid {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Title extra small */
    h1.h4, h1.h3 {
        font-size: 1rem !important;
    }
    
    /* Icon di header lebih kecil */
    h1 i {
        font-size: 0.9rem !important;
    }
    
    /* Card extra compact */
    .card {
        margin-bottom: 0.75rem !important;
    }
    
    .card-header {
        padding: 0.75rem !important;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    /* Row padding */
    .row {
        margin-left: -0.375rem !important;
        margin-right: -0.375rem !important;
    }
    
    .row > * {
        padding-left: 0.375rem !important;
        padding-right: 0.375rem !important;
    }
    
    /* Button icon + text spacing */
    .btn i {
        margin-right: 0.25rem !important;
    }
    
    /* Form field margin minimal */
    .form-group,
    .mb-3 {
        margin-bottom: 0.625rem !important;
    }
}

/* Gap utility untuk Bootstrap 4 compatibility */
.gap-2 {
    gap: 0.5rem;
}

@media (max-width: 575.98px) {
    .gap-2 {
        gap: 0.375rem;
    }
}

/* W-100 utility for width 100% */
.w-100 {
    width: 100% !important;
}

/* W-md-auto: auto width on medium and up */
@media (min-width: 768px) {
    .w-md-auto {
        width: auto !important;
    }
}

