/* --- ۱. تنظیمات اولیه و فونت (تم روشن) --- */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;900&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Vazirmatn', sans-serif;
    transition: all 0.3s ease-in-out;
}

/* اصلاح بدنه برای مرکزیت عمودی و افقی کامل */
body {
    min-height: 100vh;
    height: 100vh; 
    background: linear-gradient(135deg, #e0e9f5 0%, #ffffff 100%);
    display: flex;
    justify-content: center; 
    align-items: center; 
    direction: rtl;
    overflow-x: hidden; 
    overflow-y: auto; 
    padding: 20px; 
    color: #1a1a2e; 
}

/* --- ۲. کانتینر افکت سه‌بعدی و فلیپ (اصلاح نهایی) --- */
.container {
    perspective: 1000px;
    width: 420px; 
    height: auto; /* ارتفاع وابسته به محتوای بلندترین فرم */
    max-height: 95vh;
    position: relative;
    margin: 0 auto;
}

#flip {
    display: none;
}

/* **تغییر مهم:** حذف height ثابت برای card */
.card {
    width: 100%;
    /* **ارتفاع را روی auto می‌گذاریم تا بزرگترین فرزند ارتفاع آن را تعیین کند** */
    height: auto; 
    position: relative; 
    transition: transform 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transform-style: preserve-3d;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1); 
    border-radius: 25px; 
}

#flip:checked ~ .card {
    transform: rotateY(180deg);
}

/* --- ۳. استایل شیشه‌ای (Face) و ساختار فرم --- */
.face {
    width: 100%;
    /* **تغییر مهم:** ارتفاع را روی auto می‌گذاریم */
    height: auto; 
    min-height: 400px; 
    
    background: rgba(255, 255, 255, 0.9); 
    border-radius: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1); 
    backdrop-filter: blur(12px); 
    border: 1px solid rgba(0, 0, 0, 0.05); 

    backface-visibility: hidden;
    padding: 40px;
    display: flex;
    flex-direction: column;
    color: #1a1a2e; 
    margin: 0 auto;
}

.back {
    /* **تغییر حیاتی:** برای وجه عقب، آن را از حالت absolute خارج می‌کنیم 
    تا ارتفاع آن در DOM محاسبه شود و card ارتفاع آن را بگیرد.
    سپس آن را به absolute برمی‌گردانیم تا transform اعمال شود.
    این ترفند تضمین می‌کند که card بلندترین ارتفاع را نگه دارد. */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    /* **حذف height: 100% و استفاده از همان min-height و padding کلاس .face** */
    /* **توجه: کلاس .face را روی .back نیز اعمال کنید یا استایل‌های زیر را به آن اضافه کنید:** */
    background: rgba(255, 255, 255, 0.9);
    border-radius: 25px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 400px;
    padding: 40px;
    display: flex;
    flex-direction: column;

    /* **حفظ backface-visibility و transform برای افکت Flip** */
    backface-visibility: hidden;
    transform: rotateY(180deg);
}

/* --- ۴. استایل‌های مشترک فرم‌ها و عناصر متنی --- */

h2, h3 {
    text-align: center;
    margin-bottom: 25px;
    color: #0b2b5a; 
    font-weight: 900;
}

form {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo img {
    width: 120px; 
    height: 120px;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(0, 77, 153, 0.1);
    object-fit: cover;
    border: 4px solid #fff;
}

/* ساختار Grid (برای ثبت‌نام و فیلدهای هویتی پروفایل) */
.registration-fields {
    display: grid;
    grid-template-columns: 1fr 1fr; 
    gap: 15px; 
    margin-bottom: 10px;
}
.full-width-input {
    grid-column: 1 / -1; 
}
label {
    color: #1a1a2e; 
    display: block;
    margin-top: 15px; 
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    text-align: right;
}

input, select, textarea {
    padding: 15px 18px;
    border: 1px solid #ced4da;
    
    background: #ffffff; 
    color: #1a1a2e; 
    
    border-radius: 12px; 
    transition: all 0.3s ease;
    width: 100%; 
}

input::placeholder {
    color: rgba(26, 26, 46, 0.5); 
}

input:focus, select:focus, textarea:focus {
    background: #fff; 
    outline: none;
    border-color: #1470b8; 
    box-shadow: 0 0 0 3px rgba(20, 112, 184, 0.2);
}

/* --- ۵. استایل دکمه (بهبود یافته) --- */
button {
    padding: 15px;
    margin-top: 30px;
    background: #0b2b5a; 
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 8px 25px rgba(11, 43, 90, 0.35); 
    transition: all 0.3s ease;
}

button:hover {
    background: #1470b8; 
    transform: translateY(-3px); 
    box-shadow: 0 12px 30px rgba(20, 112, 184, 0.5);
}

/* لینک جابجایی بین فرم‌ها */
.flip-link { 
    margin-top: 25px;
    text-align: center;
    color: #0b2b5a; 
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: color 0.3s ease;
    text-decoration: none; 
}

.flip-link:hover {
    color: #1470b8; 
    text-decoration: underline; 
}

/* --- ۶. استایل‌های خاص فیلدهای disabled و پیام‌ها --- */
input:disabled, textarea:disabled {
    background: #f7f7f7; 
    color: #6c757d; 
    cursor: default;
    box-shadow: none;
    border-color: #e9ecef;
}

/* استایل پیام موفقیت/خطا */
.message-box {
    text-align: right;
    font-weight: 500;
    padding: 12px 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    margin-top: 10px;
    border: 1px solid;
    font-size: 0.95rem;
}

.message-error {
    border-color: #dc3545;
    color: #dc3545;
    background: #f8d7da;
}
.message-success {
    border-color: #28a745;
    color: #155724;
    background: #d4edda;
}
.message-info {
    border-color: #1470b8;
    color: #0b2b5a;
    background: #cce5ff;
}

/* واکنش‌گرا: برای موبایل‌ها */
@media (max-width: 600px) {
    body {
        height: auto;
        min-height: 100vh;
        align-items: flex-start; 
        padding: 15px;
    }
    
    .container { 
        width: 100%;
        margin: 10px 0; 
    }

    .face, .back { /* اعمال استایل‌های موبایل بر هر دو وجه */
        width: 100%;
        max-width: none; 
        padding: 25px;
        margin: 0;
    }
    
    .logo img {
        width: 100px; 
        height: 100px;
    }

    .registration-fields {
        grid-template-columns: 1fr; 
        gap: 10px;
    }
    
    /* کوچک کردن فونت دکمه و ورودی‌ها در موبایل */
    input, select, textarea {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    button {
        padding: 14px;
        font-size: 1rem;
    }
    h2, h3 {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }
}