/**
 * Student Portal Stylesheet (Premium Interactive Edition)
 * پورتال کلاینت مجهز به افکت‌های ۳بعدی کارت‌ها، اسکنر وب‌کم دایره‌ای و انیمیشن صندوق آرا
 */

:root {
    --primary: #1a73e8;
    --primary-light: #eff6ff;
    --primary-hover: #1557b0;
    --success: #10b981;
    --success-light: #d1fae5;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --text-dark: #1f2937;
    --text-muted: #4b5563;
    --border-color: #e5e7eb;
    --bg-app: #f3f4f6;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
}

/* ۱. استایل‌های عمومی و پایه */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Estedad', 'Vazirmatn', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-app);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* اسکرول بار شکیل اختصاصی */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ۲. کانتینر اصلی کارت برنامه (App Card) */
.app-card {
    background: white;
    width: 100%;
    max-width: 850px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid rgba(0,0,0,0.03);
}

.header {
    background: linear-gradient(135deg, var(--primary) 0%, #1557b0 100%);
    color: white;
    padding: 35px 20px;
    text-align: center;
    position: relative;
    border-bottom: 4px solid var(--success);
}

.header i {
    text-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.header h2 {
    font-size: 1.7rem;
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0,0,0,0.15);
    margin-top: 5px;
}

.container {
    padding: 35px;
}

/* ۳. استایل‌های بخش فرم‌ها و ورودی‌ها */
.form-group {
    margin-bottom: 22px;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.95rem;
}

input[type="text"], input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid #d1d5db;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    transition: var(--transition);
    background: #fcfdfd;
    text-align: center;
}

input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.12);
    background: white;
}

/* ۴. دکمه‌های کنترلی سیستم (Buttons) */
.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    width: 100%;
    font-size: 1.05rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 10px rgba(26, 115, 232, 0.15);
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 15px rgba(26, 115, 232, 0.25);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 14px 28px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: none;
}
.btn-secondary:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* ۵. استایل‌های بخش دوربین وب‌کم دایره‌ای بیومتریک */
#webcam-container {
    margin: 25px 0;
    text-align: center;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    background: #fafafa;
}

#webcam-container h4 {
    font-size: 0.95rem;
    color: var(--text-dark);
    margin-bottom: 15px;
    font-weight: 800;
}

.webcam-scan-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--success);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
    background: #e5e7eb;
    animation: pulseBorder 2s infinite ease-in-out;
    z-index: 1;
}

#webcam-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.scan-laser-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, transparent, rgba(16, 185, 129, 0.8), transparent);
    box-shadow: 0 0 8px var(--success);
    z-index: 10;
    animation: scanMove 3s infinite linear;
}

@keyframes pulseBorder {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes scanMove {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

/* ۶. گرید نمایش کارت‌های کاندیداها به همراه پرسپکتیو ۳بعدی */
.candidates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 25px;
    perspective: 1000px; /* ایجاد عمق برای جلوه سه بعدی کارت‌ها */
}

.candidate-card {
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius-md);
    padding: 25px 15px;
    text-align: center;
    cursor: pointer;
    position: relative;
    user-select: none;
    transform-style: preserve-3d;
    transition: transform 0.15s ease-out, box-shadow 0.25s ease, opacity 0.3s ease, filter 0.3s ease;
}

/* افکت مات و کم‌رنگ شدن سایر کاندیداها به هنگام انتخاب */
.candidates-grid.has-selections .candidate-card:not(.selected) {
    opacity: 0.5;
    filter: blur(1.5px) grayscale(20%);
    transform: scale(0.96) !important; /* لغو چرخش ۳بعدی برای کاندیداهای دیگر */
}

.candidate-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(26, 115, 232, 0.12);
}

.candidate-card.selected::before {
    content: "\f058";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    top: 12px;
    left: 12px;
    color: var(--primary);
    font-size: 1.3rem;
    transform: translateZ(20px); /* قرار گرفتن آیکون تیک در فضا به صورت سه بعدی */
}

.candidate-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 12px;
    border: 4px solid white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transform: translateZ(30px); /* قرار گرفتن برجسته تصویر نامزد در عمق سه بعدی */
}

.candidate-card h4 {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-dark);
    transform: translateZ(15px);
}

.candidate-card p {
    transform: translateZ(10px);
}

/* ۷. کادرهای هشدار و نوتیفیکیشن‌ها (Alerts) */
.alert {
    padding: 15px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.6;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.alert-danger {
    background: var(--danger-light);
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.hidden {
    display: none !important;
}

/* =============================================================================
   ۸. کدهای افکت سه‌بعدی سقوط برگه رای به صندوق (Ballot Box Animation)
   ============================================================================= */
#ballot-box-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.88); /* مشکی مات و مدرن */
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-direction: column;
}

.ballot-container {
    position: relative;
    width: 300px;
    height: 380px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 40px;
}

/* برگه رای تاشونده مجازی */
.ballot-paper {
    position: absolute;
    width: 80px;
    height: 105px;
    background: white;
    border-radius: 4px;
    top: 5%;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    transform-style: preserve-3d;
}

.ballot-paper-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* فعال شدن کلاس انیمیشن سقوط برگه */
.ballot-paper.animating {
    animation: foldAndDrop 2.6s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* شیار صندوق شیشه‌ای */
.ballot-box-slot {
    width: 110px;
    height: 10px;
    background: #1e293b;
    border-radius: 5px;
    border: 1.5px solid rgba(255,255,255,0.1);
    margin-bottom: -5px;
    z-index: 3;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.8);
}

/* صندوق شیشه‌ای آرا */
.ballot-box {
    position: relative;
    width: 160px;
    height: 130px;
    background: rgba(255,255,255,0.07);
    border: 2px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    z-index: 2;
    box-shadow: 0 15px 35px rgba(0,0,0,0.35);
    overflow: hidden;
}

.ballot-box-glass {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 100%);
}

#ballot-status-text {
    margin-top: 30px;
    font-size: 1.15rem;
    font-weight: 800;
    color: #f8fafc;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-align: center;
}

/* انیمیشن سه‌بعدی تا شدن برگه و سقوط داخل صندوق */
@keyframes foldAndDrop {
    0% {
        top: 5%;
        opacity: 0;
        transform: rotateX(0deg) scale(1);
    }
    15% {
        top: 10%;
        opacity: 1;
        transform: rotateX(0deg) scale(1);
    }
    45% {
        top: 25%;
        transform: rotateX(45deg) rotateY(45deg) scale(0.7);
        opacity: 1;
    }
    75% {
        top: 52%;
        transform: rotateX(85deg) rotateY(90deg) scale(0.42);
        opacity: 0.8;
        z-index: 1; /* رفتن به پشت تاق شیار جهت شبیه‌ساز واقعی ورود به صندوق */
    }
    90%, 100% {
        top: 75%;
        transform: rotateX(90deg) scale(0);
        opacity: 0;
        z-index: 1;
    }
}

/* ۹. رسپانسیو کامل موبایل */
@media (max-width: 576px) {
    body {
        padding: 10px;
    }
    
    .app-card {
        border-radius: var(--radius-md);
    }
    
    .header {
        padding: 25px 15px;
    }
    
    .header h2 {
        font-size: 1.35rem;
    }
    
    .container {
        padding: 25px 15px;
    }
    
    .candidates-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    .candidate-img {
        width: 80px;
        height: 80px;
    }
    
    .candidate-card h4 {
        font-size: 0.95rem;
    }
}