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

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 90vh;
}

/* =================== FORM PANEL (KIRI) =================== */
.form-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    max-height: 90vh;
}

.form-header {
    margin-bottom: 30px;
    border-bottom: 3px solid #667eea;
    padding-bottom: 15px;
}

.form-header h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 5px;
}

.form-header p {
    color: #666;
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: bold;
    color: #333;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

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

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* UPLOAD AREA */
.upload-area {
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background-color: #f8f9ff;
}

.upload-area:hover {
    border-color: #764ba2;
    background-color: #f0f2ff;
}

.upload-area input[type="file"] {
    display: none;
}

.upload-area p {
    color: #667eea;
    font-size: 14px;
    font-weight: 500;
    margin: 0;
}

.form-group small {
    display: block;
    color: #999;
    font-size: 12px;
    margin-top: 5px;
}

/* FORM BUTTONS */
.form-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 30px;
}

.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-preview {
    background-color: #667eea;
    color: white;
}

.btn-preview:hover {
    background-color: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-print {
    background-color: #007bff;
    color: white;
}

.btn-print:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
}

/* =================== PREVIEW PANEL (KANAN) =================== */
.preview-panel {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow-y: auto;
    max-height: 90vh;
}

.preview-header {
    margin-bottom: 20px;
    border-bottom: 3px solid #667eea;
    padding-bottom: 15px;
}

.preview-header h2 {
    color: #333;
    font-size: 22px;
}

/* A4 CONTAINER */
.a4-container {
    display: flex;
    justify-content: center;
}

.a4-page {
    width: 210mm;
    height: 297mm;
    background-color: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    padding: 25px 20px;
    border: 1px solid #ddd;
    margin: 0 auto;
}

/* =================== CERTIFICATE CONTENT =================== */
.certificate-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Times New Roman', serif;
    color: #333;
}

/* LOGO */
.logo-section {
    margin-bottom: 8px;
    text-align: center;
}

.logo-section .logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    display: none;
}

.logo-section .logo[src]:not([src=""]) {
    display: inline-block;
}

/* TAJUK */
.tajuk {
    font-size: 28px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
    margin-top: 5px;
    text-align: center;
    color: #000;
}

/* ALASAN SECTION */
.alasan-section {
    text-align: center;
    margin-top: 20px;
    margin-bottom: 20px;
    flex-grow: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.alasan-section p {
    font-size: 12px;
    line-height: 1.5;
    color: #333;
    max-width: 450px;
    margin: 0;
}

/* NAMA SECTION */
.nama-section {
    text-align: center;
    margin-bottom: 20px;
}

.nama-section .value {
    font-size: 13px;
    padding: 3px 0;
    min-width: 250px;
    text-transform: uppercase;
}

/* IC SECTION */
.ic-section {
    text-align: center;
    margin-bottom: 15px;
}

.ic-section .value {
    font-size: 12px;
    padding: 3px 0;
    min-width: 200px;
}

/* BOTTOM SECTION */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    width: 100%;
    margin-top: 12px;
    flex-grow: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
}

.left-section, .right-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
}

/* TANDATANGAN BOX */
.tandatangan-box {
    height: 50px;
    width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 3px;
}

.tandatangan-box .tandatangan {
    max-height: 45px;
    max-width: 115px;
    object-fit: contain;
    display: none;
}

.tandatangan-box .tandatangan[src]:not([src=""]) {
    display: block;
}

.nama-pengesah {
    font-size: 11px;
    text-align: center;
    width: 120px;
    word-wrap: break-word;
    padding-top: 3px;
    min-height: 15px;
    line-height: 1.2;
}

/* COP BOX */
.cop-box {
    height: 80px;
    width: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-bottom: 3px;
}

.cop-box .cop {
    width: 75px;
    height: 75px;
    border-radius: 50%;
    object-fit: contain;
    display: none;
}

.cop-box .cop[src]:not([src=""]) {
    display: block;
}

/* =================== PRINT & RESPONSIVE =================== */
@media print {
    body {
        background: white;
        padding: 0;
    }

    .container {
        display: block;
        gap: 0;
        max-width: 100%;
    }

    .form-panel {
        display: none;
    }

    .preview-panel {
        padding: 0;
        box-shadow: none;
        max-height: 100%;
    }

    .a4-page {
        width: 210mm;
        height: 297mm;
        box-shadow: none;
        margin: 0;
        padding: 40px 30px;
        page-break-after: always;
    }
}

@media (max-width: 1400px) {
    .container {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .form-panel, .preview-panel {
        max-height: 80vh;
    }

    .a4-page {
        width: 100%;
        height: auto;
        min-height: 500px;
    }
}

/* SCROLLBAR STYLING */
.form-panel::-webkit-scrollbar,
.preview-panel::-webkit-scrollbar {
    width: 8px;
}

.form-panel::-webkit-scrollbar-track,
.preview-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.form-panel::-webkit-scrollbar-thumb,
.preview-panel::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.form-panel::-webkit-scrollbar-thumb:hover,
.preview-panel::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}
