/* CSS Variables for consistent theming */
:root {
    --primary-color: #0f172a;
    --primary-dark: #0c1322;
    --primary-light: #f1f5f9;
    --accent-color: #e94560;
    --secondary-color: #64748b;
    --success-color: #16a34a;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --background-color: #f8fafc;
    --card-background: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
}

header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Country Banner */
.country-banner {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius-lg);
    padding: 24px 28px;
    margin-bottom: 28px;
    color: white;
    box-shadow: var(--shadow-lg);
}
.country-banner h3 { font-size: 1.1rem; margin-bottom: 14px; opacity: 0.9; }
.country-buttons { display: flex; gap: 12px; flex-wrap: wrap; }
.country-btn {
    flex: 1; min-width: 100px;
    padding: 14px 12px;
    border-radius: var(--radius-md);
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s ease;
    text-align: center; -webkit-tap-highlight-color: transparent;
}
.country-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.6); }
.country-btn.active {
    background: var(--accent-color); border-color: var(--accent-color);
    color: white; box-shadow: 0 4px 12px rgba(233,69,96,0.35);
    transform: translateY(-2px);
}
.country-btn .flag { font-size: 1.3rem; display: block; margin-bottom: 4px; }
.bank-field { display: none; }

/* Form Sections */
.form-section {
    background: var(--card-background);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.3s ease;
}

.form-section:hover {
    box-shadow: var(--shadow-lg);
}

.form-section h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
}

.section-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 50%;
    font-size: 0.9rem;
    font-weight: 600;
}

.section-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    margin-top: -8px;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

/* Labels */
label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.required {
    color: var(--error-color);
    font-weight: 600;
}

.optional {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 0.85rem;
}

.field-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Form Inputs */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
textarea,
select {
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
    color: var(--text-primary);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
    border-color: var(--error-color);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

/* Checkbox Styling */
.checkbox-group {
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-weight: 400;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--primary-color);
    cursor: pointer;
    flex-shrink: 0;
}

.checkbox-label span {
    line-height: 1.5;
}

/* Signature Canvas */
.signature-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#signatureCanvas {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: #fafafa;
    cursor: crosshair;
    touch-action: none;
    max-width: 100%;
}

#signatureCanvas:hover {
    border-color: var(--primary-color);
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 14px 28px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-light);
}

#clearSignature {
    align-self: flex-start;
    padding: 8px 16px;
    font-size: 0.875rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 32px;
    flex-wrap: wrap;
}

/* Terms Section */
.terms-section {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-color: var(--warning-color);
}

.terms-section .checkbox-label span {
    color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
    padding: 20px;
}

.modal-content {
    background: white;
    max-width: 800px;
    margin: 40px auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-content h2 {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
    font-size: 1.5rem;
}

.close-modal {
    float: right;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--error-color);
}

#previewContent {
    padding: 28px;
    max-height: 60vh;
    overflow-y: auto;
}

#previewContent h4 {
    color: var(--primary-color);
    margin-top: 20px;
    margin-bottom: 12px;
    font-size: 1.1rem;
}

#previewContent h4:first-child {
    margin-top: 0;
}

#previewContent p {
    margin-bottom: 8px;
    color: var(--text-primary);
}

#previewContent strong {
    color: var(--text-secondary);
    font-weight: 500;
}

.modal-actions {
    padding: 20px 28px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
    }
    
    .logo h1 {
        font-size: 2rem;
    }
    
    header h2 {
        font-size: 1.25rem;
    }
    
    .form-section {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    #signatureCanvas {
        width: 100%;
        height: 120px;
    }
}

/* Loading State */
.btn-primary.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Success Message */
.success-message {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border: 1px solid var(--success-color);
    color: #065f46;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Error Message */
.error-message {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border: 1px solid var(--error-color);
    color: #991b1b;
    padding: 16px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    margin-top: 20px;
}

/* Share Modal Styles */
.share-modal-content {
    max-width: 500px;
    text-align: center;
}

.share-modal-content h2 {
    border-bottom: none;
    padding-bottom: 0;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.share-description {
    color: var(--text-secondary);
    margin-bottom: 24px;
    padding: 0 20px;
}

.share-options {
    padding: 0 28px 20px;
}

.share-options .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.share-options .form-group input {
    width: 100%;
    background: var(--background-color);
}

.share-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-share {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-success {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    border: none;
    box-shadow: var(--shadow-md);
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.share-note {
    background: var(--primary-light);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.share-note p {
    margin: 0;
}

/* Signature Section Highlight */
.signature-section {
    border: 2px solid var(--primary-color);
    background: linear-gradient(135deg, #ffffff 0%, var(--primary-light) 100%);
}

.signature-section h3 {
    color: var(--primary-color);
}

/* Mobile Optimizations for POS */
@media (max-width: 480px) {
    .container {
        padding: 12px;
    }
    
    header {
        margin-bottom: 20px;
    }
    
    header h2 {
        font-size: 1.1rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
    
    .form-section {
        padding: 16px;
        margin-bottom: 16px;
    }
    
    .form-section h3 {
        font-size: 1.1rem;
    }
    
    .section-number {
        width: 28px;
        height: 28px;
        font-size: 0.8rem;
    }
    
    label {
        font-size: 0.85rem;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    input[type="number"],
    textarea,
    select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .modal-content {
        margin: 20px auto;
        border-radius: var(--radius-md);
    }
    
    .share-modal-content {
        margin: 10px;
    }
    
    .btn-share {
        padding: 14px 16px;
        font-size: 1rem;
    }
    
    #signatureCanvas {
        height: 100px;
    }
}

/* Touch-friendly styles */
@media (pointer: coarse) {
    .btn-primary,
    .btn-secondary,
    .btn-share {
        min-height: 48px;
    }
    
    .checkbox-label input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }
    
    select {
        min-height: 48px;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .container {
        max-width: 100%;
    }
    
    .form-section {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .form-actions,
    .btn-primary,
    .btn-secondary {
        display: none;
    }
}

