/* Next Stage Petitions - Frontend Styles */
/* Material Design inspired modern styling */

.next-stage-petition-wrapper {
    font-family: 'Roboto', sans-serif;
    max-width: 600px;
    margin: 0 auto;
    padding: 32px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

.petition-header {
    text-align: center;
    margin-bottom: 32px;
}

.petition-title {
    font-size: 28px;
    font-weight: 500;
    color: #1976d2;
    margin: 0 0 16px 0;
    line-height: 1.3;
}

.petition-description {
    font-size: 16px;
    color: #666;
    margin: 0;
    line-height: 1.5;
}

/* Form Styles */
.petition-form {
    position: relative;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group.half {
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #1f2937;
    margin-bottom: 8px;
    transition: color 0.3s ease;
}

.form-control {
    width: 100%;
    padding: 16px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
    background: #fafafa;
}

/* Error state for controls */
.form-control.error,
.form-control[aria-invalid="true"] {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
    background: #fff;
}

.form-control::placeholder {
    color: #999;
}

/* Checkbox Styles */
.checkbox-group {
    margin: 24px 0;
}

.checkbox-container {
    margin-bottom: 8px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.5;
    color: #555;
    position: relative;
    padding-left: 32px;
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.checkmark {
    position: absolute;
    left: 0;
    top: 2px;
    height: 20px;
    width: 20px;
    background-color: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.checkbox-label:hover .checkmark {
    border-color: #1976d2;
}

.checkbox-label input:checked ~ .checkmark {
    background-color: #1976d2;
    border-color: #1976d2;
}

.checkmark:after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.checkbox-label input:checked ~ .checkmark:after {
    display: block;
}

.checkbox-text {
    flex: 1;
    padding-left: 8px;
}

/* Error state for checkbox */
.checkbox-container.error .checkbox-label .checkmark {
    border-color: #ef4444;
    background: #fef2f2;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
    animation: checkboxErrorPulse 0.3s ease-in-out;
}

.checkbox-container.error .checkbox-label .checkbox-text {
    color: #dc2626;
    font-weight: 500;
}

.checkbox-container.error .checkbox-label {
    animation: checkboxLabelShake 0.5s ease-in-out;
}

/* Error message positioning for checkbox */
.checkbox-group .error-message {
    margin-top: 8px;
    display: block;
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .checkbox-container.error .checkbox-label .checkmark,
    .checkbox-container.error .checkbox-label {
        animation: none;
    }
}

@keyframes checkboxErrorPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.1);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
    }
}

@keyframes checkboxLabelShake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 16px 32px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-sign-petition {
    width: 100%;
    min-height: 56px;
}

.btn-text,
.btn-loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error and Success Messages */
.error-message,
.success-message {
    font-size: 14px;
    margin-top: 4px;
    min-height: 18px;
    line-height: 1.4;
}

.error-message {
    color: #dc2626;
    display: none;
}

.success-message {
    color: #16a34a;
}

/* Help text */
.form-help {
    font-size: 13px;
    color: #666;
    font-style: italic;
    margin-top: 8px;
}

.form-messages .success-message,
.form-messages .error-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-top: 16px;
}

.form-messages .success-message {
    background: #ecfdf5;
    border: 1px solid #10b981;
}

.form-messages .error-message {
    background: #fef2f2;
    border: 1px solid #ef4444;
}

/* Loading State */
.petition-form.submitting {
    pointer-events: none;
    opacity: 0.7;
}

.petition-form.submitting .form-control {
    background: #f5f5f5;
}

/* Responsive Design */
@media (max-width: 768px) {
    .next-stage-petition-wrapper {
        margin: 16px;
        padding: 24px;
    }

    .petition-title {
        font-size: 24px;
    }

    .form-row {
        flex-direction: column;
        gap: 0;
    }

    .form-group.half {
        margin-bottom: 16px;
    }

    .btn {
        padding: 14px 24px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .next-stage-petition-wrapper {
        margin: 8px;
        padding: 20px;
    }

    .petition-title {
        font-size: 22px;
    }

    .form-control {
        padding: 14px 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .checkbox-text {
        font-size: 13px;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for accessibility */
.form-control:focus,
.btn:focus,
.checkbox-label:focus {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 3px;
    }

    .checkmark {
        border-width: 3px;
    }
}

/* Print styles */
@media print {
    .next-stage-petition-wrapper {
        box-shadow: none;
        border: 1px solid #000;
    }

    .btn {
        display: none;
    }
}
