/* ============================================
   POSYANDU FORM CSS - COMPREHENSIVE STYLING
   Untuk semua halaman form: Kaders, Health Records, Immunizations,
   Ibu Hamil, Locations, Nutrition Data, Patient Types, Schedules, Stunting Data
   ============================================ */

/* ===== ROOT VARIABLES ===== */
:root {
    /* Primary Colors */
    --form-primary: #667eea;
    --form-primary-dark: #764ba2;
    --form-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    
    /* Status Colors */
    --status-success: #28a745;
    --status-success-light: #d4edda;
    --status-danger: #dc3545;
    --status-danger-light: #f8d7da;
    --status-warning: #ffc107;
    --status-warning-light: #fff3cd;
    --status-info: #17a2b8;
    --status-info-light: #d1ecf1;
    
    /* Neutral Colors */
    --white: #ffffff;
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --border-gray: #dee2e6;
    --text-gray: #6c757d;
    --text-dark: #495057;
    --text-black: #343a40;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 25px rgba(0, 0, 0, 0.15);
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 15px;
    --radius-xl: 20px;
    --radius-full: 50%;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 2.5rem;
}

/* ===== CONTAINER ===== */
.form-container {
    padding: var(--spacing-md);
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f4ff 0%, #faf9ff 100%);
}

/* ===== FORM HEADER ===== */
.form-header {
    background: var(--form-gradient);
    color: var(--white);
    border-radius: var(--radius-md);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
}

.form-header h1,
.form-header h2 {
    font-weight: 700;
    margin-bottom: var(--spacing-sm);
}

.form-header p {
    opacity: 0.9;
    margin: 0;
}

/* ===== FORM SECTIONS ===== */
.form-section {
    background: var(--white);
    border-radius: var(--radius-md);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.form-section:hover {
    box-shadow: var(--shadow-lg);
}

.section-header {
    border-bottom: 2px solid var(--medium-gray);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.section-header h5,
.section-title {
    color: var(--text-dark);
    font-weight: 600;
    margin: 0;
}

.section-header p {
    color: var(--text-gray);
    margin: var(--spacing-xs) 0 0 0;
    font-size: 0.9rem;
}

/* ===== STEP INDICATOR ===== */
.step-indicator {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: var(--spacing-xl);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.step {
    display: flex;
    align-items: center;
    margin: 0 var(--spacing-sm);
    position: relative;
}

.step::after {
    content: '';
    position: absolute;
    right: -20px;
    width: 20px;
    height: 2px;
    background: var(--medium-gray);
}

.step:last-child::after {
    display: none;
}

.step.completed::after {
    background: var(--status-success);
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--medium-gray);
    color: var(--text-gray);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: var(--spacing-sm);
    transition: all 0.3s ease;
}

.step.active .step-number {
    background: var(--form-gradient);
    color: var(--white);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.step.completed .step-number {
    background: var(--status-success);
    color: var(--white);
}

.step-label {
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.step.active .step-label {
    color: var(--form-primary);
    font-weight: 600;
}

/* ===== FORM STEPS ===== */
.form-step {
    display: none;
}

.form-step.active {
    display: block;
    animation: fadeInSlide 0.5s ease-out;
}

@keyframes fadeInSlide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ===== FORM CONTROLS ===== */
.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--spacing-xs);
    font-size: 0.95rem;
}

.required-field::after,
.form-label.required::after {
    content: " *";
    color: var(--status-danger);
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-gray);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: var(--white);
}

.form-control:focus {
    border-color: var(--form-primary);
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
    outline: none;
}

.form-control:disabled {
    background: var(--light-gray);
    cursor: not-allowed;
}

.form-control.is-invalid {
    border-color: var(--status-danger);
}

.form-control.is-invalid:focus {
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25);
}

.form-control.is-valid {
    border-color: var(--status-success);
}

.form-control.is-valid:focus {
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

/* ===== FORM TEXT ===== */
.form-text {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--text-gray);
}

.invalid-feedback {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--status-danger);
}

.valid-feedback {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--status-success);
}

/* ===== INPUT GROUPS ===== */
.input-group {
    display: flex;
    align-items: stretch;
}

.input-group .form-control {
    flex: 1;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.input-group-append,
.input-group-prepend {
    display: flex;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--light-gray);
    border: 2px solid var(--border-gray);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-gray);
    font-size: 0.95rem;
}

.input-group-prepend .input-group-text {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

/* ===== CHECKBOXES & RADIOS ===== */
.form-check {
    display: flex;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-right: var(--spacing-sm);
    cursor: pointer;
}

.form-check-label {
    font-size: 0.95rem;
    color: var(--text-dark);
    cursor: pointer;
    user-select: none;
}

/* ===== FILE UPLOAD ===== */
.file-upload-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
}

.file-upload-input {
    opacity: 0;
    position: absolute;
    z-index: -1;
}

.file-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    border: 2px dashed var(--border-gray);
    border-radius: var(--radius-md);
    background: var(--light-gray);
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-upload-label:hover {
    border-color: var(--form-primary);
    background: rgba(102, 126, 234, 0.05);
}

.file-upload-label i {
    font-size: 2rem;
    color: var(--form-primary);
    margin-right: var(--spacing-md);
}

.file-preview {
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--light-gray);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.file-preview img {
    max-width: 150px;
    max-height: 150px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

/* ===== PENDUDUK SEARCH ===== */
.penduduk-search {
    position: relative;
}

.penduduk-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 2px solid var(--border-gray);
    border-top: none;
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow-lg);
}

.penduduk-results.show {
    display: block;
}

.penduduk-item {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--light-gray);
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.penduduk-item:hover {
    background-color: var(--light-gray);
}

.penduduk-item:last-child {
    border-bottom: none;
}

.penduduk-item.selected {
    background: rgba(102, 126, 234, 0.1);
}

.selected-penduduk {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid var(--form-primary);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.penduduk-photo {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    object-fit: cover;
    border: 3px solid var(--white);
    box-shadow: var(--shadow-sm);
}

.penduduk-info {
    flex: 1;
}

.penduduk-info h6 {
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.penduduk-info p {
    color: var(--text-gray);
    margin: 0;
    font-size: 0.9rem;
}

/* ===== VITAL SIGNS GRID ===== */
.vital-signs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.vital-sign-card {
    background: var(--light-gray);
    border-radius: var(--radius-sm);
    padding: var(--spacing-lg);
    text-align: center;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.vital-sign-card:hover {
    border-color: var(--form-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.vital-sign-card.focused {
    border-color: var(--form-primary);
    background: rgba(102, 126, 234, 0.05);
}

.vital-sign-label {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: var(--spacing-sm);
    font-size: 0.9rem;
}

.vital-sign-input {
    border: none;
    background: var(--white);
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--form-primary);
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    width: 100%;
}

.vital-sign-input:focus {
    outline: 2px solid var(--form-primary);
}

.vital-sign-unit {
    font-size: 0.85rem;
    color: var(--text-gray);
    margin-top: var(--spacing-xs);
}

/* ===== FORM ACTIONS ===== */
.form-actions {
    background: var(--light-gray);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-top: var(--spacing-xl);
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
    flex-wrap: wrap;
}

.form-actions.sticky {
    position: sticky;
    bottom: 0;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.btn-custom,
.btn-form {
    padding: 12px 24px;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-custom:hover,
.btn-form:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: var(--form-gradient);
    color: var(--white);
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: var(--white);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #218838 100%);
    color: var(--white);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border-gray);
    color: var(--text-dark);
}

.btn-outline:hover {
    background: var(--light-gray);
    border-color: var(--text-dark);
}

/* ===== NAVIGATION BUTTONS (MULTI-STEP) ===== */
.step-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: var(--spacing-xl);
    gap: var(--spacing-md);
}

.btn-prev,
.btn-next {
    padding: 12px 24px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-prev {
    background: var(--medium-gray);
    color: var(--text-dark);
}

.btn-next {
    background: var(--form-gradient);
    color: var(--white);
}

.btn-prev:hover,
.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-prev:disabled,
.btn-next:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== ALERTS ===== */
.alert-custom {
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    border: none;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: var(--status-success-light);
    color: #155724;
    border-left: 4px solid var(--status-success);
}

.alert-danger {
    background: var(--status-danger-light);
    color: #721c24;
    border-left: 4px solid var(--status-danger);
}

.alert-warning {
    background: var(--status-warning-light);
    color: #856404;
    border-left: 4px solid var(--status-warning);
}

.alert-info {
    background: var(--status-info-light);
    color: #0c5460;
    border-left: 4px solid var(--status-info);
}

/* ===== PROGRESS BAR ===== */
.form-progress {
    margin-bottom: var(--spacing-xl);
}

.progress-bar-container {
    height: 8px;
    background: var(--medium-gray);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--form-gradient);
    transition: width 0.5s ease;
    border-radius: var(--radius-xl);
}

.progress-text {
    text-align: center;
    margin-top: var(--spacing-sm);
    font-size: 0.9rem;
    color: var(--text-gray);
    font-weight: 600;
}

/* ===== DYNAMIC FIELDS ===== */
.dynamic-field-group {
    border: 2px solid var(--border-gray);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    position: relative;
}

.dynamic-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.btn-remove-field {
    background: var(--status-danger);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.btn-remove-field:hover {
    background: #c82333;
    transform: scale(1.05);
}

.btn-add-field {
    background: var(--status-success);
    color: var(--white);
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    transition: all 0.3s ease;
}

.btn-add-field:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ===== LOADING STATE ===== */
.form-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid var(--medium-gray);
    border-top-color: var(--form-primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN ===== */
/* Tablet (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .vital-signs-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .step-indicator {
        flex-wrap: wrap;
    }
}

/* Mobile (max-width: 767px) */
@media (max-width: 767px) {
    .form-container {
        padding: var(--spacing-sm);
    }
    
    .form-header {
        padding: var(--spacing-lg);
    }
    
    .form-header h1,
    .form-header h2 {
        font-size: 1.5rem;
    }
    
    .form-section {
        padding: var(--spacing-md);
    }
    
    .step-indicator {
        flex-direction: column;
        align-items: stretch;
    }
    
    .step {
        margin: var(--spacing-xs) 0;
    }
    
    .step::after {
        display: none;
    }
    
    .vital-signs-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .vital-sign-input {
        font-size: 1.25rem;
    }
    
    .form-actions,
    .step-navigation {
        flex-direction: column;
    }
    
    .btn-custom,
    .btn-form,
    .btn-prev,
    .btn-next {
        width: 100%;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .input-group .form-control,
    .input-group-text {
        border-radius: var(--radius-sm);
        border: 2px solid var(--border-gray);
    }
}

/* Extra Small Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .form-header h1,
    .form-header h2 {
        font-size: 1.25rem;
    }
    
    .vital-sign-input {
        font-size: 1rem;
    }
    
    .step-number {
        width: 35px;
        height: 35px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .form-actions,
    .step-navigation,
    .btn-custom,
    .btn-form,
    .btn-add-field,
    .btn-remove-field {
        display: none !important;
    }
    
    .form-section {
        box-shadow: none !important;
        border: 1px solid var(--border-gray) !important;
        page-break-inside: avoid;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-required {
    color: var(--status-danger);
    font-weight: bold;
}

.form-hint {
    display: block;
    margin-top: var(--spacing-xs);
    font-size: 0.85rem;
    color: var(--text-gray);
    font-style: italic;
}

.field-group {
    margin-bottom: var(--spacing-lg);
}

.field-row {
    display: flex;
    gap: var(--spacing-md);
}

.field-row .form-group {
    flex: 1;
}

/* ===== END OF POSYANDU FORM CSS ===== */

