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

html,
body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #a8b8d8 0%, #b8a8c8 50%, #c8b8d8 100%);
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 20px;
    color: #1a202c;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: inherit;
    z-index: -1;
}

h2 {
    text-align: center;
    color: #ffffff;
    margin-bottom: 30px;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

/* Message Title */
.message-title {
    text-align: center;
    color: #ffffff;
    margin-bottom: 20px;
    font-size: 2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.5s ease-out;
}

/* Message Box */
.message-box {
    max-width: 600px;
    margin: 0 auto 20px;
    padding: 32px 40px;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border-left: 6px solid #e53e3e;
    color: #1a202c;
    font-size: 1.05rem;
    line-height: 1.8;
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.message-box.success {
    border-left-color: #38a169;
}

.message-box:last-child {
    margin-bottom: 0;
}

/* Message Links */
.message-links {
    max-width: 600px;
    margin: 15px auto 25px;
    padding: 12px 20px;
    background: #f8fafc;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.message-links a {
    display: inline-block;
    margin: 0 12px;
    color: #7c8fb8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    padding: 4px 8px;
    border-radius: 4px;
}

.message-links a:hover {
    color: #6b7a9f;
    background: rgba(124, 143, 184, 0.1);
}

/* Form Container */
form {
    max-width: 600px;
    margin: 0 auto;
    background: #ffffff;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border-top: 4px solid #7c8fb8;
}

/* Labels */
label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #1a202c;
    font-size: 0.95rem;
}

/* Subheader for fields */
label + div > span:not(input):not(label):not(button) {
    display: block;
    margin-top: -4px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #718096;
    font-weight: 400;
    line-height: 1.4;
}

/* All Input Types */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid #cbd5e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f8fafc;
    color: #1a202c;
    margin-bottom: 6px;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: #7c8fb8;
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(124, 143, 184, 0.2);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="password"]:hover,
input[type="number"]:hover,
input[type="date"]:hover,
input[type="datetime-local"]:hover,
input[type="tel"]:hover,
input[type="url"]:hover,
input[type="search"]:hover,
textarea:hover,
select:hover {
    border-color: #a0aec0;
}

/* Textarea */
textarea {
    resize: vertical;
    min-height: 120px;
    font-family: inherit;
    line-height: 1.6;
}

/* Select */
select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237c8fb8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
}

/* Password Input Styling */
input[type="password"] {
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
    padding-right: 50px;
}

/* Show/hide password button */
.password-toggle {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
    opacity: 0.6;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.password-toggle:hover {
    opacity: 1;
    background: rgba(124, 143, 184, 0.1);
    border-radius: 4px;
}

.password-toggle svg {
    width: 20px;
    height: 20px;
    stroke: #718096;
    transition: stroke 0.2s ease;
}

.password-toggle:hover svg {
    stroke: #7c8fb8;
}

/* Checkbox and Radio */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #7c8fb8;
}

/* Custom checkbox styling */
input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e0;
    border-radius: 5px;
    background: #ffffff;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

input[type="checkbox"]:hover {
    border-color: #7c8fb8;
}

input[type="checkbox"]:checked {
    background: linear-gradient(135deg, #7c8fb8 0%, #6b7a9f 100%);
    border-color: #7c8fb8;
}

input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Custom radio styling */
input[type="radio"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e0;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

input[type="radio"]:hover {
    border-color: #7c8fb8;
}

input[type="radio"]:checked {
    background: linear-gradient(135deg, #7c8fb8 0%, #6b7a9f 100%);
    border-color: #7c8fb8;
}

input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 5px;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
}

/* Checkbox/Radio with labels */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
    display: flex;
    align-items: center;
    font-weight: 400;
    padding: 12px 16px;
    margin: 8px 0;
    background: #f7fafc;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 2px solid transparent;
}

label:has(input[type="checkbox"]):hover,
label:has(input[type="radio"]):hover {
    background: #edf2f7;
    border-color: #7c8fb8;
    transform: translateX(5px);
}

/* File Input */
input[type="file"] {
    padding: 12px;
    cursor: pointer;
    background: #f8fafc;
    border-radius: 8px;
}

input[type="file"]::file-selector-button {
    background: linear-gradient(135deg, #7c8fb8 0%, #6b7a9f 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    margin-right: 10px;
    font-weight: 600;
    transition: all 0.3s ease;
}

input[type="file"]::file-selector-button:hover {
    background: linear-gradient(135deg, #6b7a9f 0%, #5a6a8f 100%);
    transform: translateY(-1px);
}

/* Error Messages */
div[id*="error"],
div[class*="error"] {
    color: #c53030;
    font-size: 0.8rem;
    margin-top: 6px;
    display: block;
    font-weight: 500;
    min-height: 18px;
    line-height: 1.2;
}

/* Submit Button */
button[type="submit"],
input[type="submit"] {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #7c8fb8 0%, #6b7a9f 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.35s ease;
    margin-top: 25px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 15px rgba(124, 143, 184, 0.4);
}

button[type="submit"]:hover,
input[type="submit"]:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(124, 143, 184, 0.5);
    background: linear-gradient(135deg, #6b7a9f 0%, #5a6a8f 100%);
}

button[type="submit"]:active,
input[type="submit"]:active {
    transform: translateY(-1px);
}

button[type="submit"]:focus,
input[type="submit"]:focus {
    outline: none;
    box-shadow: 0 0 0 4px rgba(124, 143, 184, 0.5), 0 4px 15px rgba(124, 143, 184, 0.4);
}

/* Valid/Invalid states */
input.valid,
textarea.valid,
select.valid {
    border-color: #38a169;
    background: #f0fff4;
    box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.2);
}

input.invalid,
textarea.invalid,
select.invalid {
    border-color: #fc8181;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(252, 129, 129, 0.2);
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(25px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

form {
    animation: fadeIn 0.6s ease-out;
}

/* Checkbox ripple animation */
@keyframes checkbox-ripple-animation {
    to {
        transform: scale(2);
        opacity: 0;
    }
}

/* Responsive */
@media (max-width: 768px) {
    html,
    body {
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        width: 100%;
    }

    body {
        padding: 15px 10px;
    }

    form {
        padding: 25px 15px;
        width: 100%;
        max-width: 100%;
    }

    h2 {
        font-size: 1.4rem;
    }
}

/* Small phones */
@media (max-width: 380px) {
    body {
        padding: 10px 5px;
    }

    form {
        padding: 20px 12px;
    }

    h2 {
        font-size: 1.2rem;
    }

    button[type="submit"],
    input[type="submit"] {
        padding: 14px 20px;
        font-size: 1rem;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    form {
        max-width: 100%;
        margin: 0 auto 30px;
        padding: 0 15px;
    }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        padding: 10px;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    form {
        box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    }
}

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