/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: linear-gradient(135deg, #0E6973 0%, #118C8C 50%, #BAD9CE 100%);
    min-height: 100vh;
    /* Mobile first - reduced padding */
    padding: 10px;
    font-weight: 400;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    position: relative;
}

/* Language Toggle */
.language-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.lang-btn {
    background: #0E6973;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 14px;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 6px;
}

.lang-btn .flag {
    font-size: 16px;
    line-height: 1;
}

.lang-btn:hover {
    background: #118C8C;
    transform: translateY(-2px);
}

/* Form Styles - Mobile First */
.consent-form {
    /* Mobile first - comfortable padding */
    padding: 15px;
    padding-top: 70px;
}

.consent-form h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 40px;
    font-size: 2.5rem;
    font-weight: 600;
    background: linear-gradient(135deg, #0E6973, #118C8C);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Form Sections - Mobile First */
.form-section {
    /* Mobile first - more generous spacing */
    margin-bottom: 25px;
    padding: 20px 15px;
    background: #f8f9fa;
    border-radius: 12px;
    border-left: 4px solid #0E6973;
}

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

/* Form Rows and Groups */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #34495e;
    font-size: 0.95rem;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 16px;
    transition: all 0.3s ease;
    background: white;
    font-family: 'Outfit', sans-serif;
}

.form-group input:focus {
    outline: none;
    border-color: #0E6973;
    box-shadow: 0 0 0 3px rgba(14, 105, 115, 0.1);
    transform: translateY(-1px);
}

.form-group input:valid:not(:placeholder-shown) {
    border-color: #27ae60;
}

.form-group input.error {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* Error Messages */
.error-message {
    display: none;
    color: #e74c3c;
    font-size: 0.85rem;
    margin-top: 5px;
    font-weight: 500;
}

.form-group.error .error-message,
.signature-container.error .signature-error {
    display: block;
}

/* Consent Text - Mobile First Design */
.consent-text {
    background: #fff;
    /* Mobile first - generous padding */
    padding: 20px 15px;
    border-radius: 12px;
    border: 1px solid #e1e8ed;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.consent-text .consent-header {
    /* Mobile first - larger, more readable */
    font-size: 1rem;
    font-weight: 600;
    color: #0E6973;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #BAD9CE;
    text-align: center;
    line-height: 1.4;
}

.consent-text p {
    font-size: 0.9rem;
    line-height: 1.8;
    color: #2c3e50;
    margin-bottom: 20px;
    text-align: left;
}

.consent-text .numbered-list {
    counter-reset: consent-counter;
    margin: 25px 0;
    padding: 0;
    list-style: none;
}

.consent-text .numbered-list li {
    counter-increment: consent-counter;
    /* Mobile first - much more spacious */
    margin-bottom: 25px;
    padding: 20px 15px;
    background: #f8fffe;
    border-left: 3px solid #118C8C;
    border-radius: 10px;
    position: relative;
    font-size: 0.9rem;
    line-height: 1.8;
    color: #2c3e50;
    text-align: left;
    /* Remove margin-left on mobile to prevent circle overflow */
    margin-left: 0;
}

.consent-text .numbered-list li::before {
    content: counter(consent-counter);
    position: absolute;
    /* Mobile first - position circle inside the card */
    left: 15px;
    top: -12px;
    background: #0E6973;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(14, 105, 115, 0.3);
    border: 3px solid white;
}

.consent-text .legal-section {
    margin: 30px 0;
    padding: 25px 20px;
    background: linear-gradient(135deg, #f8fffe, #BAD9CE15);
    border-radius: 12px;
    border: 1px solid #BAD9CE;
}

.consent-text .legal-section p {
    font-size: 0.9rem;
    line-height: 1.8;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: left;
}

.consent-text .important-notice {
    background: linear-gradient(135deg, #FFF3CD, #F2BB1615);
    border: 2px solid #F2BB16;
    border-radius: 12px;
    padding: 25px 20px;
    margin: 30px 0;
}

.consent-text .important-notice p {
    margin-bottom: 15px;
    font-weight: 500;
    color: #856404;
    font-size: 0.9rem;
    line-height: 1.8;
}

.consent-text .highlight-text {
    background: linear-gradient(135deg, #0E6973, #118C8C);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

/* Tablet adjustments */
@media (min-width: 576px) {
    .consent-text {
        padding: 25px 20px;
        border-radius: 15px;
    }
    
    .consent-text .consent-header {
        font-size: 1.1rem;
        margin-bottom: 30px;
    }
    
    .consent-text p {
        font-size: 0.95rem;
    }
    
    .consent-text .numbered-list li {
        padding: 20px 25px;
        font-size: 0.95rem;
        margin-left: 15px;
    }
    
    .consent-text .numbered-list li::before {
        left: -12px;
        top: 20px;
    }
    
    .consent-text .legal-section {
        padding: 25px;
    }
    
    .consent-text .important-notice {
        padding: 25px;
    }
}

/* Desktop adjustments */
@media (min-width: 768px) {
    .consent-text {
        padding: 30px;
        border: 2px solid #e1e8ed;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    }
    
    .consent-text .consent-header {
        font-size: 1.2rem;
        text-align: left;
    }
    
    .consent-text p {
        text-align: justify;
    }
    
    .consent-text .numbered-list li {
        text-align: justify;
        margin-left: 20px;
    }
    
    .consent-text .legal-section p,
    .consent-text .important-notice p {
        text-align: justify;
    }
}

/* Signature Section */
.signature-container {
    text-align: center;
}

.signature-container label {
    display: block;
    margin-bottom: 15px;
    font-weight: 500;
    color: #34495e;
}

#signatureCanvas {
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    cursor: crosshair;
    background: white;
    max-width: 100%;
    height: auto;
    transition: border-color 0.3s ease;
    touch-action: none;
}

#signatureCanvas:hover {
    border-color: #0E6973;
}

#signatureCanvas.signed {
    border-color: #27ae60;
}

.signature-container.error #signatureCanvas {
    border-color: #e74c3c;
}

.signature-controls {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#clearSignature {
    background: #BF820F;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

#clearSignature:hover {
    background: #F2BB16;
    color: #2c3e50;
    transform: translateY(-1px);
}

.signature-status {
    font-size: 0.9rem;
    color: #7f8c8d;
    font-weight: 500;
}

.signature-status.signed {
    color: #27ae60;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    background: linear-gradient(135deg, #0E6973, #118C8C);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-family: 'Outfit', sans-serif;
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(14, 105, 115, 0.3);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loading {
    display: none;
}

.submit-btn.loading .btn-text {
    display: none;
}

.submit-btn.loading .btn-loading {
    display: inline;
}

/* Success and Error Messages */
.success-message {
    text-align: center;
    padding: 60px 40px;
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.success-message h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    font-weight: 600;
}

.success-message p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

#submitAnother {
    background: white;
    color: #27ae60;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

#submitAnother:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.error-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.error-popup::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
}

.error-popup h3 {
    color: #e74c3c;
    margin-bottom: 15px;
    font-size: 1.3rem;
    font-weight: 600;
}

.error-popup p {
    margin-bottom: 20px;
    color: #2c3e50;
}

#closeError {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
}

#closeError:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

/* Responsive Design - Mobile First Approach */

/* Small mobile devices and up (576px+) */
@media (min-width: 576px) {
    body {
        padding: 15px;
    }
    
    .consent-form {
        padding: 25px;
        padding-top: 70px;
    }
    
    .form-section {
        padding: 25px 20px;
        margin-bottom: 30px;
    }
}

/* Tablets and up (768px+) */
@media (min-width: 768px) {
    body {
        padding: 20px;
    }
    
    .container {
        border-radius: 20px;
    }
    
    .consent-form {
        padding: 40px;
        padding-top: 60px;
    }
    
    .consent-form h1 {
        font-size: 2.5rem;
        margin-bottom: 40px;
    }
    
    .form-section {
        padding: 30px;
        margin-bottom: 40px;
        border-radius: 15px;
    }
    
    .form-row {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
    
    #signatureCanvas {
        width: 400px;
        height: 200px;
    }
    
    .signature-controls {
        flex-direction: row;
        gap: 0;
    }
}

/* Legacy mobile adjustments (kept for compatibility) */
@media (max-width: 767px) {
    .container {
        margin: 0;
        border-radius: 0;
    }
    
    .consent-form h1 {
        font-size: 2rem;
        margin-bottom: 30px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    #signatureCanvas {
        width: 100%;
        height: 150px;
    }
    
    .signature-controls {
        flex-direction: column;
        gap: 10px;
    }
}

@media (max-width: 480px) {
    .consent-form h1 {
        font-size: 1.8rem;
    }
    
    .form-section h2 {
        font-size: 1.2rem;
    }
    
    .form-group input {
        padding: 10px 12px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .language-toggle {
        top: 15px;
        right: 15px;
    }
}

/* Animation for form reveal */
.form-section {
    animation: slideInUp 0.6s ease-out;
    animation-fill-mode: both;
}

.form-section:nth-child(1) { animation-delay: 0.1s; }
.form-section:nth-child(2) { animation-delay: 0.2s; }
.form-section:nth-child(3) { animation-delay: 0.3s; }
.form-section:nth-child(4) { animation-delay: 0.4s; }
.form-section:nth-child(5) { animation-delay: 0.5s; }
.form-section:nth-child(6) { animation-delay: 0.6s; }

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

/* Loading state */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0E6973;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-group input {
        border-width: 3px;
    }
    
    .submit-btn {
        border: 2px solid #2c3e50;
    }
}

/* Focus visible for better keyboard navigation */
.lang-btn:focus-visible,
.form-group input:focus-visible,
#clearSignature:focus-visible,
.submit-btn:focus-visible,
#submitAnother:focus-visible,
#closeError:focus-visible {
    outline: 2px solid #0E6973;
    outline-offset: 2px;
}