/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.4;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 700px;
    margin: 0 auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 1.8rem;
    margin-bottom: 5px;
    font-weight: 600;
}

header p {
    font-size: 1rem;
    opacity: 0.9;
}

.consent-form {
    padding: 20px;
}

.form-section {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #3498db;
}

.form-section h2 {
    color: #2c3e50;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
}

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

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.9rem;
}

.form-group input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.1);
}

.form-group input:valid {
    border-color: #27ae60;
}

.form-group small {
    color: #7f8c8d;
    font-size: 0.8rem;
    display: block;
    margin-top: 3px;
}

/* File input styling */
input[type="file"] {
    padding: 8px;
    border: 2px dashed #3498db;
    border-radius: 6px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.9rem;
}

input[type="file"]:hover {
    border-color: #2980b9;
    background: #e8f4f8;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

button {
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

#generatePdf {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

#generatePdf:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

#applyLeave {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

#applyLeave:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

#resetForm {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

#resetForm:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 15px rgba(231, 76, 60, 0.3);
}

.loading {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    margin: 10px;
    border-radius: 8px;
    border: 2px solid #3498db;
}

.loading p {
    font-size: 1rem;
    color: #3498db;
    font-weight: 500;
}

.hidden {
    display: none !important;
}

/* Signature preview styling */
.signature-preview-wrap {
    margin-top: 8px;
    padding: 15px;
    border: 2px dashed #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    text-align: center;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#signaturePreview {
    max-width: 200px;
    max-height: 120px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    background: white;
    display: block;
}

#signaturePreview.hidden {
    display: none !important;
}

/* Upload button styling */
.upload-btn {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
    padding: 8px 16px;
    margin-top: 8px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(243, 156, 18, 0.3);
}

/* Signature Editor Modal */
.signature-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.signature-modal.active {
    display: flex;
    opacity: 1;
    visibility: visible;
}

.signature-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(2px);
}

.signature-modal-container {
    position: relative;
    margin: auto;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 850px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.signature-modal.active .signature-modal-container {
    transform: scale(1);
}

.signature-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: linear-gradient(135deg, #2c3e50, #3498db);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.signature-modal-header h3 {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.signature-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.signature-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
}

.signature-close-btn span {
    font-size: 24px;
    line-height: 1;
}

.signature-modal-content {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.signature-editor-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.toolbar-btn {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(108, 92, 231, 0.2);
}

.toolbar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

.toolbar-btn:active {
    transform: translateY(0);
}

.signature-editor-workspace {
    text-align: center;
    margin: 20px auto;
    width: 60%;
    max-width: 400px;
    height: 250px;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    background: #f8f9fa;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#signatureEditImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.signature-modal-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid #dee2e6;
}

.btn-cancel {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(116, 185, 255, 0.3);
}

.btn-cancel:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(116, 185, 255, 0.4);
}

.btn-apply {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 184, 148, 0.3);
}

.btn-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 184, 148, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .signature-modal-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .signature-modal-header {
        padding: 16px 20px;
    }
    
    .signature-modal-header h3 {
        font-size: 1.2rem;
    }
    
    .signature-modal-content {
        padding: 20px;
    }
    
    .signature-editor-toolbar {
        flex-direction: column;
        align-items: center;
    }
    
    .toolbar-btn {
        width: 100%;
        max-width: 200px;
        justify-content: center;
    }
    
    .signature-editor-workspace {
        width: 90%;
        height: 200px;
    }
    
    .signature-modal-actions {
        flex-direction: column;
    }
    
    .btn-cancel,
    .btn-apply {
        width: 100%;
        padding: 14px 20px;
    }
}

/* Responsive design */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }
    
    .container {
        margin: 5px;
        border-radius: 8px;
    }
    
    header {
        padding: 15px;
    }
    
    .consent-form {
        padding: 15px;
    }
    
    .form-section {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .form-group {
        margin-bottom: 10px;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    header p {
        font-size: 0.9rem;
    }
    
    .form-actions {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    button {
        width: 100%;
        max-width: 250px;
        padding: 10px 15px;
    }
}

/* Loading animation */
.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #3498db;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
}

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