/* ========================================
   APU PPT - Custom Responsive CSS
   Backend: PHP 8.x with PDO
   Frontend: Vanilla JS + CSS3
   ======================================== */

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --success: #10b981;
    --success-light: #34d399;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-light: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ========================================
   Navbar
   ======================================== */
.navbar-custom {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 18px 30px;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-custom h4 {
    font-weight: 700;
    letter-spacing: -0.5px;
    margin: 0;
}

.navbar-custom small {
    opacity: 0.85;
    font-weight: 500;
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1280px;
    margin: 0 auto;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

/* ========================================
   Main Container
   ======================================== */
.main-container {
    max-width: 1280px;
    margin: 30px auto;
    padding: 0 24px;
}

/* ========================================
   Tab Navigation
   ======================================== */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 32px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.tab-btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transform: translateY(-1px);
}

.tab-btn:not(.active):hover {
    background: var(--bg-light);
    color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ========================================
   Form Container
   ======================================== */
.form-container {
    max-width: 900px;
    margin: auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.form-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 24px 32px;
}

.form-header h3 {
    color: white;
    margin: 0;
    font-weight: 700;
    font-size: 1.3rem;
}

.form-body {
    padding: 32px;
}

/* ========================================
   Section Cards
   ======================================== */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    transition: all 0.3s ease;
}

.section-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.section-card h4 {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-card h4 i {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

/* ========================================
   Form Controls
   ======================================== */
label {
    display: block;
    margin: 16px 0 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

label .optional {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 12px;
}

input[type="text"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--bg-card);
    color: var(--text-primary);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

input[readonly] {
    background: #f1f5f9;
    color: var(--text-secondary);
    cursor: not-allowed;
}

/* ========================================
   Buttons
   ======================================== */
.btn-submit {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 20px;
    width: 100%;
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-add-rekening {
    background: linear-gradient(135deg, var(--success), #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-add-rekening:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-save {
    background: linear-gradient(135deg, var(--success), #059669);
    padding: 14px 28px;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.btn-save:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

/* ========================================
   Rekening Item
   ======================================== */
.rekening-item {
    background: #f8fafc;
    padding: 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    position: relative;
    transition: all 0.2s ease;
}

.rekening-item:hover {
    border-color: var(--primary-light);
}

.rekening-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 12px;
    align-items: end;
}

.btn-remove-rekening {
    background: var(--danger);
    color: white;
    border: none;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove-rekening:hover {
    background: #dc2626;
}

/* ========================================
   Risk Assessment Items - Radio Cards
   ======================================== */
.risk-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 14px;
    transition: all 0.3s ease;
}

.risk-item:hover {
    border-color: var(--primary-light);
}

.risk-item > label {
    margin: 0 0 10px 0;
    color: var(--primary-dark);
    font-weight: 700;
    display: block;
}

/* Radio card grid - 3 columns */
.risk-cards {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 8px;
}

.risk-card {
    position: relative;
    cursor: pointer;
}

.risk-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.risk-card-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    font-size: 12px;
    line-height: 1.4;
    font-weight: 600;
    transition: all 0.2s ease;
    background: white;
    height: 100%;
}

.risk-card-label .score-badge {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    color: white;
}

/* Skor 1 - Hijau (Risiko Rendah) */
.risk-card-rendah .risk-card-label {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}
.risk-card-rendah .score-badge {
    background: #16a34a;
}
.risk-card-rendah input[type="radio"]:checked + .risk-card-label {
    border-color: #16a34a;
    background: #dcfce7;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* Skor 2 - Kuning/Oranye (Risiko Menengah) */
.risk-card-sedang .risk-card-label {
    border-color: #fde68a;
    background: #fffbeb;
    color: #92400e;
}
.risk-card-sedang .score-badge {
    background: #d97706;
}
.risk-card-sedang input[type="radio"]:checked + .risk-card-label {
    border-color: #d97706;
    background: #fef3c7;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

/* Skor 3 - Merah (Risiko Tinggi) */
.risk-card-tinggi .risk-card-label {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}
.risk-card-tinggi .score-badge {
    background: #dc2626;
}
.risk-card-tinggi input[type="radio"]:checked + .risk-card-label {
    border-color: #dc2626;
    background: #fee2e2;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.15);
}

/* Alasan input */
.risk-item .alasan-input {
    margin-top: 6px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-primary);
    transition: border-color 0.2s;
}
.risk-item .alasan-input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .risk-cards {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Audit Log Table
   ======================================== */
.audit-log-container {
    overflow-x: auto;
}

.audit-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.audit-log-table thead {
    background: #f1f5f9;
}

.audit-log-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
}

.audit-log-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.audit-log-table tr:hover {
    background: #f8fafc;
}

.audit-log-table code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    color: #475569;
}

.audit-log-table small {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
}

/* ========================================
   Summary Card
   ======================================== */
.summary-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #bae6fd;
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
}

.summary-card h5 {
    color: var(--primary-dark);
    font-weight: 700;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-item {
    background: white;
    padding: 12px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.summary-item .label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.summary-item .value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.summary-item.full-width {
    grid-column: 1 / -1;
}

/* ========================================
   Stats Cards
   ======================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 8px;
}

.stat-card.total {
    border-color: var(--primary);
}

.stat-card.total .stat-value {
    color: var(--primary);
}

.stat-card.rendah {
    border-color: var(--success);
}

.stat-card.rendah .stat-value {
    color: var(--success);
}

.stat-card.sedang {
    border-color: var(--warning);
}

.stat-card.sedang .stat-value {
    color: var(--warning);
}

.stat-card.tinggi {
    border-color: var(--danger);
}

.stat-card.tinggi .stat-value {
    color: var(--danger);
}

/* ========================================
   Data Table
   ======================================== */
.data-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.data-card-header {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    color: white;
    padding: 20px 24px;
    font-weight: 700;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table thead th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    border-bottom: 2px solid var(--border);
    text-align: left;
}

table tbody td {
    padding: 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

table tbody tr:hover {
    background: #f8fafc;
}

/* ========================================
   Badges
   ======================================== */
.badge-risk {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge-rendah {
    background: #d1fae5;
    color: #065f46;
}

.badge-sedang {
    background: #fef3c7;
    color: #92400e;
}

.badge-tinggi {
    background: #fee2e2;
    color: #991b1b;
}

.badge-belum-lengkap {
    background: #f1f5f9;
    color: #64748b;
    border: 1px dashed #94a3b8;
}

/* ========================================
   Action Buttons
   ======================================== */
.action-btn {
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    margin: 2px;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    border: none;
    cursor: pointer;
}

.action-btn:hover {
    transform: translateY(-1px);
}

.btn-edit {
    background: var(--warning);
    color: white;
}

.btn-print {
    background: var(--success);
    color: white;
}

.btn-delete {
    background: var(--danger);
    color: white;
}

/* ========================================
   Form Grid Layout
   ======================================== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ========================================
   Step Indicator
   ======================================== */
.step-indicator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    transition: all 0.3s ease;
}

.step-dot.active {
    background: var(--primary);
    width: 32px;
    border-radius: 5px;
}

/* ========================================
   Empty State
   ======================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    color: var(--border);
    margin-bottom: 16px;
}

/* ========================================
   Login Page
   ======================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 900px;
    width: 100%;
    overflow: hidden;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.login-left {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 50px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.login-left i {
    font-size: 4rem;
    margin-bottom: 20px;
}

.login-right {
    padding: 50px;
}

.login-right h4 {
    margin-bottom: 10px;
    color: var(--text-primary);
}

.login-right p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .main-container {
        padding: 0 12px;
    }
    
    .navbar-content {
        flex-direction: column;
        gap: 15px;
    }
    
    .login-card {
        grid-template-columns: 1fr;
    }
    
    .login-left {
        display: none;
    }
    
    .rekening-row {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 12px;
    }
    
    table thead th,
    table tbody td {
        padding: 10px 8px;
    }
}

@media (max-width: 480px) {
    .tab-nav {
        flex-direction: column;
    }
    
    .form-body {
        padding: 20px;
    }
    
    .section-card {
        padding: 16px;
    }
}

/* ========================================
   Print Styles
   ======================================== */
 @media print {
.no-print {
 display: none;
 }

 body {
 background: white;
 }

.navbar-custom {
 display: none;
 }
 }

 /* ========================================
 Audit Log Timeline & Snapshot
 ======================================== */
.audit-timeline {
 position: relative;
 padding-left: 20px;
}

.audit-entry {
 position: relative;
 margin-bottom: 24px;
 padding: 20px;
 background: white;
 border: 2px solid var(--border);
 border-radius: var(--radius-md);
 transition: all 0.3s ease;
}

.audit-entry:hover {
 border-color: var(--primary-light);
 box-shadow: var(--shadow-md);
}

.audit-entry::before {
 content: '';
 position: absolute;
 left: -20px;
 top: 24px;
 width: 12px;
 height: 12px;
 border-radius: 50%;
 background: var(--primary);
 border: 3px solid white;
 box-shadow: 0 0 0 2px var(--primary);
}

.audit-create::before {
 background: var(--success);
 box-shadow: 0 0 0 2px var(--success);
}

.audit-update::before {
 background: var(--primary);
 box-shadow: 0 0 0 2px var(--primary);
}

.audit-delete::before {
 background: var(--danger);
 box-shadow: 0 0 0 2px var(--danger);
}

.audit-entry-header {
 display: flex;
 align-items: center;
 gap: 12px;
 margin-bottom: 16px;
 flex-wrap: wrap;
}

.audit-version-badge {
 display: flex;
 align-items: center;
 gap: 6px;
 padding: 6px 12px;
 background: linear-gradient(135deg, var(--primary), var(--primary-dark));
 color: white;
 border-radius: 20px;
 font-size: 12px;
 font-weight: 700;
}

.audit-meta {
 display: flex;
 flex-direction: column;
 gap: 4px;
 flex: 1;
}

.audit-date,
.audit-user {
 font-size: 12px;
 color: var(--text-secondary);
 display: flex;
 align-items: center;
 gap: 6px;
}

.audit-action-badge {
 padding: 6px 12px;
 border-radius: 16px;
 font-size: 11px;
 font-weight: 700;
 text-transform: uppercase;
}

.audit-action-badge.audit-create {
 background: #d1fae5;
 color: #065f46;
}

.audit-action-badge.audit-update {
 background: #dbeafe;
 color: #1e40af;
}

.audit-action-badge.audit-delete {
 background: #fee2e2;
 color: #991b1b;
}

.audit-detail {
 margin-top: 12px;
}

.audit-summary {
 margin: 0 0 12px 0;
 font-size: 13px;
 color: var(--text-secondary);
}

.audit-change-table {
 width: 100%;
 border-collapse: collapse;
 font-size: 12px;
 margin-top: 12px;
}

.audit-change-table thead th {
 background: #f8fafc;
 padding: 8px 12px;
 text-align: left;
 font-weight: 600;
 border-bottom: 2px solid var(--border);
}

.audit-change-table tbody td {
 padding: 8px 12px;
 border-bottom: 1px solid var(--border);
}

.audit-change-table tr:hover {
 background: #f8fafc;
}

.audit-old-value {
 color: #dc2626;
 text-decoration: line-through;
 opacity: 0.7;
}

.audit-new-value {
 color: #16a34a;
 font-weight: 600;
}

.btn-view-snapshot {
 margin-top: 12px;
 padding: 8px 16px;
 background: linear-gradient(135deg, #3b82f6, #2563eb);
 color: white;
 border: none;
 border-radius: var(--radius-sm);
 font-size: 12px;
 font-weight: 600;
 cursor: pointer;
 display: inline-flex;
 align-items: center;
 gap: 6px;
 transition: all 0.3s ease;
}

.btn-view-snapshot:hover {
 transform: translateY(-2px);
 box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-view-snapshot i {
 font-size: 11px;
}

.snapshot-detail {
 margin-top: 16px;
 padding: 16px;
 background: #f8fafc;
 border: 1px solid var(--border);
 border-radius: var(--radius-sm);
 animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
 from {
 opacity: 0;
 transform: translateY(-10px);
 }
 to {
 opacity: 1;
 transform: translateY(0);
 }
}

.snapshot-detail strong {
 display: block;
 margin-bottom: 12px;
 color: var(--primary-dark);
 font-size: 13px;
}

.changes-summary {
 margin-top: 16px;
}

.changes-summary strong {
 display: block;
 margin-bottom: 8px;
 color: var(--text-primary);
 font-size: 12px;
}

.highlight-changed {
 Background: #fef08a !important;
}

.highlight-changed td {
 Border-left: 4px solid #f59e0b;
 Background: #fef08a !important;
 Font-weight: 600;
 Color: #854d0e;
}
