/**
 * Enhanced Form Styling with CENTERED Messages
 * Fixed positioning for all alerts and notifications
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 500px;
}

.form-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

h1 {
    color: #333;
    font-size: 28px;
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
    font-size: 14px;
}

/* Form Groups */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

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

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
    background-color: #fff;
}

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

/* Validation States */
.form-group.success input {
    border-color: #48bb78;
    background-color: #f0fff4;
}

.form-group.success input:focus {
    box-shadow: 0 0 0 3px rgba(72, 187, 120, 0.1);
}

.form-group.warning input {
    border-color: #ed8936;
    background-color: #fffdf7;
}

.form-group.warning input:focus {
    box-shadow: 0 0 0 3px rgba(237, 137, 54, 0.1);
}

.form-group.error input {
    border-color: #f56565;
    background-color: #fff5f5;
    animation: shake 0.5s;
}

.form-group.error input:focus {
    box-shadow: 0 0 0 3px rgba(245, 101, 101, 0.1);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Help Text */
.help-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #999;
    transition: color 0.3s ease;
}

.form-group.success .help-text {
    color: #48bb78;
}

.form-group.warning .help-text {
    color: #ed8936;
}

.form-group.error .help-text {
    color: #f56565;
}

/* Submit Button */
.btn {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #cbd5e0;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

/* CENTERED Messages - Hidden by default */
.success-message,
.error-message {
    display: none !important; /* СКРЫТО ПО УМОЛЧАНИЮ */
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7) !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 9999 !important;
    animation: fadeIn 0.3s ease;
    padding: 20px;
    box-sizing: border-box;
}

/* Класс для показа сообщений */
.success-message.show,
.error-message.show {
    display: flex !important;
}

/* Countdown progress bar */
.countdown-progress {
    margin-top: 20px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #f56565 0%, #ed8936 100%);
    border-radius: 4px;
    animation: countdown linear forwards;
    transform-origin: left;
}

@keyframes countdown {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

/* Countdown number styling */
.error-content strong {
    color: #f56565;
    font-size: 1.5em;
    font-weight: bold;
    display: inline-block;
    min-width: 30px;
    text-align: center;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* Alternative centering method for better browser support */
.success-message {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.error-message {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.success-content,
.error-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease;
    position: relative;
    margin: auto;
}

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

.success-content h3 {
    color: #48bb78;
    margin-bottom: 15px;
    font-size: 24px;
}

.error-content h3 {
    color: #f56565;
    margin-bottom: 15px;
    font-size: 24px;
}

.success-content p,
.error-content p {
    color: #666;
    margin-bottom: 20px;
    line-height: 1.6;
}

.success-buttons,
.error-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.success-buttons .btn,
.error-buttons .btn {
    flex: 1;
    min-width: 120px;
}

/* Honeypot (hidden) */
input[name="website"] {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
}

/* Loading State */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
    vertical-align: middle;
}

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

/* Security Badge */
.security-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
    color: #999;
    font-size: 12px;
}

.security-badge svg {
    width: 16px;
    height: 16px;
    margin-right: 5px;
    fill: #48bb78;
}

/* Responsive Design with proper centering */
@media (max-width: 480px) {
    .form-container {
        padding: 30px 20px;
    }
    
    h1 {
        font-size: 24px;
    }
    
    .subtitle {
        font-size: 13px;
    }
    
    .form-group input {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .btn {
        font-size: 14px;
        padding: 12px 16px;
    }
    
    .success-content,
    .error-content {
        padding: 20px;
        width: 95%;
        max-width: 350px;
    }
    
    /* Ensure messages stay centered on mobile */
    .success-message,
    .error-message {
        padding: 10px;
    }
}

/* Ensure proper centering in all browsers */
.success-message::before,
.error-message::before {
    content: '';
    display: inline-block;
    height: 100%;
    vertical-align: middle;
}

/* Accessibility */
.form-group input:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    body {
        background: white;
    }
    
    .form-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    
    .btn {
        display: none;
    }
    
    .success-message,
    .error-message {
        display: none !important;
    }
}