/* 
 * KUA BLANGKO GENERATOR - BEAUTIFUL DESIGN
 * Tema: Modern Teal/Green dengan Animasi Smooth
 * Version: 1.0 FINAL
 */

/* ============================================
   VARIABLES & RESET
   ============================================ */
:root {
    --primary: #14b8a6;        /* Teal 500 */
    --primary-dark: #0d9488;   /* Teal 600 */
    --primary-light: #5eead4;  /* Teal 300 */
    --secondary: #06b6d4;      /* Cyan 500 */
    --success: #10b981;        /* Green 500 */
    --warning: #f59e0b;        /* Amber 500 */
    --danger: #ef4444;         /* Red 500 */
    --dark: #1f2937;           /* Gray 800 */
    --light: #f9fafb;          /* Gray 50 */
    --border: #e5e7eb;         /* Gray 200 */
    --shadow: rgba(20, 184, 166, 0.1);
    --shadow-lg: rgba(20, 184, 166, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark);
    background: linear-gradient(135deg, #f0fdfa 0%, #ecfeff 100%);
}

/* ============================================
   CONTAINER
   ============================================ */
.kua-blangko-container {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-top: 8px;
    margin-bottom: 8px;
    padding: 24px 32px;
    background: white;
    border-radius: 24px;
    box-shadow: 0 20px 60px var(--shadow-lg);
    animation: fadeInUp 0.6s ease-out;
    box-sizing: border-box;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.kua-blangko-container h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-dark);
    text-align: center;
    margin-bottom: 6px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 20px;
}

/* ============================================
   PROGRESS BAR - BEAUTIFUL ANIMATED
   ============================================ */
.progress-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    position: relative;
    padding: 0 20px;
}

.progress-bar::before {
    content: '';
    position: absolute;
    top: 26px;
    left: 50px;
    right: 50px;
    height: 3px;
    background: var(--border);
    z-index: 0;
    transition: all 0.4s ease;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
    flex: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.progress-step:hover {
    transform: translateY(-5px);
}

.progress-step-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    font-weight: 700;
    color: #9ca3af;
    margin-bottom: 8px;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.progress-step-circle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: var(--primary-light);
    transform: translate(-50%, -50%);
    transition: all 0.5s ease;
}

.progress-step.active .progress-step-circle {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-color: var(--primary);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 8px 25px var(--shadow-lg);
}

.progress-step.active .progress-step-circle::before {
    width: 100%;
    height: 100%;
    opacity: 0.3;
}

.progress-step.completed .progress-step-circle {
    background: var(--success);
    border-color: var(--success);
    color: white;
    animation: successPulse 0.6s ease;
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.progress-step.completed .progress-step-circle::after {
    content: '✓';
    position: absolute;
    font-size: 32px;
    animation: checkmark 0.4s ease;
}

@keyframes checkmark {
    from {
        opacity: 0;
        transform: scale(0) rotate(-45deg);
    }
    to {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.progress-step-label {
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
    transition: all 0.3s ease;
}

.progress-step.active .progress-step-label {
    color: var(--primary-dark);
    font-weight: 700;
    transform: scale(1.1);
}

/* ============================================
   FORM STEPS
   ============================================ */
.form-step {
    display: none;
    animation: slideIn 0.5s ease;
}

.form-step.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.step-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 8px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-light);
    position: relative;
}

.step-title::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 80px;
    height: 3px;
    background: var(--primary);
    animation: slideRight 0.6s ease;
}

@keyframes slideRight {
    from {
        width: 0;
    }
    to {
        width: 80px;
    }
}

.step-description {
    color: #6b7280;
    margin-bottom: 16px;
    font-size: 14px;
}

.form-step h4 {
    font-size: 16px;
    font-weight: 700;
}

/* ============================================
   FORM ELEMENTS - MODERN & CLEAN
   ============================================ */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    position: relative;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.required {
    color: var(--danger);
    margin-left: 4px;
    font-size: 16px;
}

.form-control {
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: white;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--shadow);
    transform: translateY(-2px);
}

.form-control:hover {
    border-color: var(--primary-light);
}

/* Textarea - Border Tebal untuk Alamat */
textarea.form-control {
    min-height: 100px;
    resize: vertical;
    border-width: 3px;
    font-family: inherit;
    line-height: 1.6;
}

textarea.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--shadow);
}

/* Select Dropdown */
select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2314b8a6' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
    font-size: 10px !important;
    line-height: 1.2;
    height: 42px;
}

select.form-control option {
    font-size: 10px !important;
    padding: 5px;
    line-height: 1.2;
}


/* Input disabled (untuk agama Islam) */
.form-control:disabled {
    background-color: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
    border-color: var(--border);
}

/* Help Text */
.help-text {
    font-size: 13px;
    color: #6b7280;
    margin-top: 6px;
    display: flex;
    align-items: center;
}

.help-text::before {
    content: 'ℹ️';
    margin-right: 6px;
}

/* ============================================
   BUTTONS - BEAUTIFUL GRADIENTS
   ============================================ */
.form-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    gap: 15px;
}

.btn {
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--primary-dark);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background: var(--light);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   LOADING OVERLAY - SMOOTH ANIMATION
   ============================================ */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.loading-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

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

.loading-content {
    text-align: center;
    animation: zoomIn 0.5s ease;
}

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

.spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    border: 6px solid rgba(255, 255, 255, 0.2);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-content p {
    color: white;
    font-size: 18px;
    font-weight: 600;
}

/* ============================================
   DOWNLOAD MODAL - BEAUTIFUL CARDS
   ============================================ */

/* Modal Base - CRITICAL: Hidden by default */
.modal {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal.active {
    display: flex !important;
    animation: fadeIn 0.3s ease;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    z-index: 10000;
    animation: fadeIn 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 24px;
    padding: 40px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
    animation: modalSlideUp 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(100px) scale(0.8);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border);
}

.modal-header h3 {
    font-size: 26px;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--light);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
    transform: rotate(90deg);
}

/* File Cards */
.file-card {
    background: linear-gradient(135deg, var(--light) 0%, white 100%);
    border: 2px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 20px var(--shadow);
    transform: translateX(5px);
}

.file-checkbox {
    width: 24px;
    height: 24px;
    cursor: pointer;
    accent-color: var(--primary);
}

.file-icon {
    width: 50px;
    height: 50px;
    background: var(--primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 700;
    color: var(--dark);
    font-size: 16px;
    margin-bottom: 4px;
}

.file-desc {
    color: #6b7280;
    font-size: 13px;
}

.file-actions {
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 8px;
}

.btn-preview {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-preview:hover {
    background: var(--primary);
    color: white;
}

.btn-download {
    background: var(--success);
    color: white;
}

.btn-download:hover {
    background: #059669;
    transform: scale(1.05);
}

/* Badge Warning untuk N5 */
.badge-warning {
    background: var(--warning);
    color: white;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .kua-blangko-container {
        width: 100vw;
        max-width: 100vw;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        margin-top: 4px;
        margin-bottom: 4px;
        padding: 16px;
        border-radius: 14px;
        box-sizing: border-box;
    }

    .kua-blangko-container h2 {
        font-size: 19px;
    }

    .subtitle {
        font-size: 12px;
        margin-bottom: 14px;
    }

    .progress-bar {
        flex-wrap: nowrap;
        justify-content: space-between;
        margin-bottom: 10px;
        padding: 0;
    }

    .progress-bar::before {
        display: none;
    }

    .progress-step {
        flex: 1 1 0;
        width: auto;
        margin-bottom: 0;
        min-width: 0;
    }

    .progress-step-circle {
        width: 34px;
        height: 34px;
        font-size: 13px;
        margin: 0 auto 4px;
    }

    .progress-step-label {
        font-size: 8.5px;
        line-height: 1.15;
        padding: 0 2px;
    }

    .step-title {
        font-size: 17px;
        margin-bottom: 4px;
        padding-bottom: 6px;
    }

    .step-description {
        font-size: 13px;
        margin-bottom: 12px;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .form-navigation {
        flex-direction: column;
    }

    .modal-content {
        padding: 25px;
    }

    .file-card {
        flex-direction: column;
        text-align: center;
    }

    .file-actions {
        width: 100%;
        flex-direction: column;
    }

    .btn-sm {
        width: 100%;
    }

    .sub-tabs {
        gap: 4px;
    }

    .sub-tab {
        flex: 1 1 auto;
        text-align: center;
        padding: 8px 10px;
        font-size: 13px;
    }

    .wilayah-suggestions {
        max-height: 180px;
    }

    .form-control,
    .wilayah-input {
        font-size: 16px;
    }
}

@media (max-width: 400px) {
    .progress-step-circle {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }

    .progress-step-label {
        font-size: 7.5px;
    }
}

/* ============================================
   CUSTOM SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--light);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ============================================
   ANIMATIONS - MICRO INTERACTIONS
   ============================================ */
.form-control:focus {
    animation: inputFocus 0.3s ease;
}

@keyframes inputFocus {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-2px);
    }
}

.btn:active {
    animation: btnPress 0.2s ease;
}

@keyframes btnPress {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
}

/* ============ KTP SCAN OTOMATIS - v2.0 ============ */
.ktp-scan-box {
    margin-bottom: 18px;
}
.btn-scan-ktp {
    display: inline-block;
    cursor: pointer;
    background-color: #eef2ff;
    color: #4338ca;
    border: 1px dashed #6366f1;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}
.btn-scan-ktp:hover {
    background-color: #e0e7ff;
}
.ktp-scan-box .help-text {
    display: block;
    margin-top: 6px;
}
.draft-restored-notice {
    font-size: 14px;
}

.ktp-scan-progress-track {
    width: 100%;
    max-width: 280px;
    height: 6px;
    background: #e0e7ff;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 8px;
}
.ktp-scan-progress-bar {
    width: 35%;
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #a5b4fc);
    border-radius: 999px;
    animation: kuaScanProgress 1.1s ease-in-out infinite;
}
@keyframes kuaScanProgress {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(385%); }
}

/* ============ SUB-TAB (dalam satu step) - v2.1 ============ */
.sub-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 20px;
}
.sub-tab {
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f9fafb;
    margin-bottom: -2px;
}
.sub-tab.active {
    color: #0d9488;
    background: #fff;
    border-color: #0d9488;
    border-bottom: 2px solid #fff;
}
.sub-tab-content {
    display: none;
}
.sub-tab-content.active {
    display: block;
}

/* ============ DROPDOWN WILAYAH BERJENJANG (bisa diketik, tampilan sendiri) - v2.3 ============ */
.wilayah-autocomplete {
    position: relative;
}
.wilayah-input:disabled {
    background-color: #f3f4f6;
    cursor: not-allowed;
}
.wilayah-suggestions {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: #fff;
    border: 2px solid #0d9488;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 220px;
    overflow-y: auto;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.wilayah-suggestion-item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
}
.wilayah-suggestion-item:last-child {
    border-bottom: none;
}
.wilayah-suggestion-item:hover {
    background: #f0fdfa;
    color: #0d9488;
}

/* Wali hakim: kolom selain nama dan NIP terkunci */
.wali-data-block.wali-locked .ktp-scan-box{opacity:.45;pointer-events:none}
.wali-data-block.wali-locked input:disabled,.wali-data-block.wali-locked select:disabled{background:#f3f4f6;cursor:not-allowed}
