:root {
    --primary-color: #004986;
    --secondary-color: #2f80ed;
    --accent-color: #38B6FF;
    --text-color: #333333;
    --light-bg: #f8f9fa;
    --border-radius: 8px;
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px; /* Lisätty vielä enemmän ylä- ja alapaddingia */
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    perspective: 1000px;
}

.card-container {
    position: relative;
    width: 100%;
    max-width: 1000px;
    min-height: 630px; /* Palautettu alkuperäinen korkeus */
    margin: 0 auto;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

/* Erillinen lomakkeelle käytettävä korkeampi container */
.card-container.form-active {
    min-height: 950px; /* Hieman pienennetty korkeutta, koska lomake on nyt tiiviimpi */
}

.rotate-container {
    transform: rotateY(180deg);
}

.auth-card, .form-card {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 16px;
    overflow: auto; /* Muutettu hidden -> auto, jotta voidaan scrollata jos sisältö ei mahdu */
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
    background: white;
}

.form-card {
    transform: rotateY(180deg);
}

.card-inner {
    padding: 40px;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
    min-height: 630px; /* Palautettu automaattiseksi */
}

/* Erillinen korkeampi card-inner lomakkeelle */
.form-card .card-inner {
    min-height: 950px;
}

h2 {
    color: var(--primary-color);
    font-weight: 700;
    margin-bottom: 30px;
    font-size: 28px;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    border-radius: 2px;
}

.form-label {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.form-control {
    padding: 12px 16px;
    border: 1px solid #e1e5eb;
    border-radius: var(--border-radius);
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: none;
    background-color: var(--light-bg);
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(56, 182, 255, 0.2);
}

.form-group {
    margin-bottom: 20px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border: none;
    padding: 14px 20px;
    font-size: 18px;
    font-weight: 600;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(47, 128, 237, 0.3);
    margin-top: 15px;
    width: 100%;
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(47, 128, 237, 0.4);
    transform: translateY(-2px);
    background: linear-gradient(135deg, #00407a, #2270d3);
}

.form-check {
    margin-bottom: 15px;
    padding-left: 30px;
}

.form-check-input {
    width: 20px;
    height: 20px;
    margin-left: -30px;
    border: 2px solid var(--secondary-color);
    cursor: pointer;
}

.form-check-input:checked {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.form-check-label {
    font-size: 15px;
    padding-top: 2px;
}

.form-check-label a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.form-check-label a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Modals */
.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-bottom: none;
    padding: 20px 25px;
}

.modal-title {
    font-weight: 600;
    font-size: 22px;
}

.modal-body {
    padding: 25px;
    font-size: 16px;
    line-height: 1.6;
}

.btn-close {
    background-color: white;
    opacity: 0.8;
    box-shadow: none;
}

.btn-close:focus {
    box-shadow: none;
}

/* Responsive adjustments */
@media (max-width: 767.98px) {
    .card-inner {
        padding: 25px;
    }
    
    h2 {
        font-size: 24px;
    }
    
    .form-control {
        padding: 10px 14px;
    }
    
    .btn-primary {
        padding: 12px;
    }
    
    .card-container {
        min-height: 680px;
    }
    
    .card-container.form-active {
        min-height: 1000px; /* Mobiilissa hieman korkeampi */
    }
    
    body {
        padding: 20px; /* Pienempi padding mobiililla */
        align-items: flex-start; /* Ei keskitetä pystysuunnassa mobiililla */
        padding-top: 30px;
        padding-bottom: 30px;
    }
}

/* Alert styling */
#successScreen {
    display: none;
    text-align: center;
    padding: 20px 0;
}

.success-container {
    max-width: 500px;
    margin: 0 auto;
}

.success-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00a86b, #4CAF50);
    margin: 0 auto 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 60px;
    box-shadow: 0 10px 20px rgba(0, 168, 107, 0.3);
}

.success-title {
    color: #00a86b;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
}

.success-message {
    color: var(--text-color);
    font-size: 17px;
    line-height: 1.6;
    margin-bottom: 30px;
}

.reference-number {
    display: inline-block;
    background-color: #f5f7fa;
    border-radius: var(--border-radius);
    padding: 12px 25px;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 30px;
    border: 1px dashed #ccd4e0;
}
.alert-info {
    background-color: rgba(56, 182, 255, 0.1);
    border-left: 4px solid var(--accent-color);
    color: var(--text-color);
    border-radius: var(--border-radius);
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
}

.alert-info p {
    margin-bottom: 12px;
}

.alert-info .alert-heading {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 18px;
}

/* SEO branding element */
.seo-branding {
    text-align: center;
    margin-top: 10px;
    margin-bottom: 30px;
}

.seo-branding img {
    max-height: 40px;
    opacity: 0.9;
}

/* Form Input Icon */
.input-with-icon {
    position: relative;
}

.input-with-icon .form-control {
    padding-left: 45px;
}

.input-with-icon i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-color);
    opacity: 0.7;
}

/* SMS verification code input */
.verification-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 30px 0;
}

.verification-input {
    width: 50px;
    height: 60px;
    font-size: 24px;
    text-align: center;
    border: 2px solid #e1e5eb;
    border-radius: var(--border-radius);
    background-color: var(--light-bg);
    transition: all 0.3s ease;
}

.verification-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(56, 182, 255, 0.2);
    outline: none;
}

.progress-container {
    width: 100%;
    margin: 30px 0;
}

.progress {
    height: 8px;
    background-color: #e1e5eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary-color), var(--accent-color));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.info-text {
    text-align: center;
    color: #6c757d;
    margin-top: 20px;
    font-size: 14px;
}

.resend-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.resend-link:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

.step-indicator {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
}

.step {
    width: 120px;
    text-align: center;
    position: relative;
}

.step-number {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #e1e5eb;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-weight: bold;
    position: relative;
    z-index: 2;
}

.step.active .step-number {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
}

.step.completed .step-number {
    background: linear-gradient(135deg, #00a86b, #4CAF50);
    color: white;
}

.step-label {
    font-size: 14px;
    color: #6c757d;
}

.step.active .step-label {
    color: var(--primary-color);
    font-weight: 600;
}

.step.completed .step-label {
    color: #4CAF50;
    font-weight: 600;
}

.step-line {
    position: absolute;
    top: 15px;
    height: 2px;
    background-color: #e1e5eb;
    width: 100%;
    left: 50%;
}

.step:last-child .step-line {
    display: none;
}

.step.completed .step-line {
    background-color: #4CAF50;
}

/* Fade in animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

/* Spinner animation */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Success icon animation */
.success-checkmark {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    position: relative;
    display: block;
}

.success-checkmark .check-icon {
    width: 80px;
    height: 80px;
    position: relative;
    border-radius: 50%;
    box-sizing: content-box;
    border: 4px solid #4CAF50;
}

.success-checkmark .check-icon::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #F8F9FA;
    opacity: 0;
    animation: fillCheckmark 0.4s ease-in-out 0.3s forwards;
}

.success-checkmark .check-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 28px;
    transform: rotate(45deg) translate(-50%, -50%);
    transform-origin: 0% 0%;
    width: 3px;
    height: 0;
    background-color: #4CAF50;
    animation: checkmarkHeight 0.2s ease-in-out 0.7s forwards;
}

.success-checkmark .check-icon .icon-line {
    position: absolute;
    top: 54%;
    left: 46%;
    transform: rotate(-45deg) translate(-50%, -50%);
    transform-origin: 0% 0%;
    width: 0;
    height: 3px;
    background-color: #4CAF50;
    animation: checkmarkWidth 0.15s ease-in-out 0.9s forwards;
}

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

@keyframes checkmarkHeight {
    from { height: 0; }
    to { height: 28px; }
}

@keyframes checkmarkWidth {
    from { width: 0; }
    to { width: 20px; }
}