/* Reset & Base */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --border-card: #e2e8f0;
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.05), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-light: #eff6ff;
    --primary-gradient: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-focus: #2563eb;
    --navbar-bg: #1e293b;
    --sidebar-bg: #ffffff;
    --sidebar-active-bg: #eff6ff;
    --sidebar-active-text: #1d4ed8;
}

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

body { 
    font-family: 'Tajawal', sans-serif; 
    direction: rtl; 
    background-color: var(--bg-body); 
    color: var(--text-main); 
    min-height: 100vh; 
}

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.main-content { padding: 2rem 0; min-height: calc(100vh - 140px); }

/* Navbar */
.navbar { 
    background: var(--navbar-bg); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.08); 
    padding: 1rem 0; 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
}
.navbar-container { display: flex; justify-content: space-between; align-items: center; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.navbar-brand a { font-size: 1.4rem; font-weight: 800; color: #ffffff; text-decoration: none; display: flex; align-items: center; gap: 0.5rem; }
.navbar-menu { display: flex; gap: 1rem; align-items: center; color: #e2e8f0; }
.navbar-menu a { color: #e2e8f0; text-decoration: none; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: 6px; transition: background 0.3s; }
.navbar-menu a:hover { background: rgba(255,255,255,0.15); color: #ffffff; }
.navbar-link { color: #cbd5e1; text-decoration: none; padding: 0.5rem 1rem; border-radius: 8px; transition: all 0.3s; }
.navbar-link:hover { color: #ffffff; background: rgba(255,255,255,0.1); }

/* Cards */
.card { 
    background: var(--bg-card); 
    border: 1px solid var(--border-card); 
    border-radius: 16px; 
    padding: 2rem; 
    margin-bottom: 1.5rem; 
    box-shadow: var(--shadow-card);
    transition: transform 0.3s, box-shadow 0.3s; 
}
.card:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04); 
}

/* Form Elements */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 600; color: #334155; font-size: 0.95rem; }
.form-control { 
    width: 100%; 
    padding: 0.75rem 1rem; 
    background: var(--input-bg); 
    border: 1px solid var(--input-border); 
    border-radius: 10px; 
    color: var(--text-main); 
    font-family: 'Tajawal'; 
    font-size: 1rem; 
    transition: all 0.3s; 
    direction: rtl; 
}
.form-control:focus { 
    outline: none; 
    border-color: var(--input-focus); 
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); 
}
.form-control::placeholder { color: #94a3b8; }
select.form-control { 
    appearance: none; 
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23475569'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E"); 
    background-repeat: no-repeat; 
    background-position: left 1rem center; 
    background-size: 1.2em; 
    padding-left: 2.5rem; 
}
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }

/* Buttons */
.btn { 
    display: inline-flex; 
    align-items: center; 
    justify-content: center; 
    gap: 0.5rem; 
    padding: 0.75rem 1.5rem; 
    border: none; 
    border-radius: 10px; 
    font-family: 'Tajawal'; 
    font-size: 1rem; 
    font-weight: 700; 
    cursor: pointer; 
    transition: all 0.3s; 
    text-decoration: none; 
}
.btn-primary { background: var(--primary-gradient); color: white; box-shadow: 0 4px 12px rgba(29, 78, 216, 0.25); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(29, 78, 216, 0.35); }
.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; color: #0f172a; }
.btn-success { background: linear-gradient(135deg, #059669, #10b981); color: white; box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25); }
.btn-success:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(5, 150, 105, 0.35); }
.btn-danger { background: linear-gradient(135deg, #dc2626, #ef4444); color: white; box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25); }
.btn-danger:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35); }
.btn-info { background: #0284c7; color: white; }
.btn-sm { padding: 0.4rem 1rem; font-size: 0.85rem; border-radius: 8px; }
.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* Stepper */
.stepper { display: flex; justify-content: center; align-items: center; margin-bottom: 2.5rem; gap: 0; direction: rtl; }
.step { display: flex; flex-direction: column; align-items: center; position: relative; flex: 1; cursor: pointer; }
.step-number { 
    width: 45px; 
    height: 45px; 
    border-radius: 50%; 
    background: #ffffff; 
    color: #64748b; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    font-weight: 700; 
    font-size: 1.1rem; 
    border: 2px solid #cbd5e1; 
    transition: all 0.4s; 
    z-index: 2; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.step-label { margin-top: 0.5rem; font-size: 0.85rem; color: #64748b; text-align: center; transition: all 0.3s; direction: rtl; font-weight: 500; }
.step.active .step-number { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 0 15px rgba(29, 78, 216, 0.35); transform: scale(1.1); }
.step.active .step-label { color: var(--primary); font-weight: 700; }
.step.completed .step-number { background: #059669; color: white; border-color: #059669; }
.step.completed .step-label { color: #059669; font-weight: 600; }
.step:not(:last-child)::after { content: ''; position: absolute; top: 22px; right: 50%; width: 100%; height: 3px; background: #e2e8f0; z-index: 1; }
.step.completed:not(:last-child)::after { background: #059669; }

/* Alerts */
.alert { padding: 1rem 1.25rem; border-radius: 12px; margin-bottom: 1.5rem; display: flex; justify-content: space-between; align-items: center; animation: slideDown 0.3s ease; font-weight: 500; }
.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert-danger { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-warning { background: #fef3c7; border: 1px solid #fde047; color: #92400e; }
.alert-info { background: #dbeafe; border: 1px solid #93c5fd; color: #1e40af; }
.alert-close { background: none; border: none; color: inherit; font-size: 1.2rem; cursor: pointer; opacity: 0.7; }

/* Tables */
.table-responsive { overflow-x: auto; border-radius: 12px; border: 1px solid #e2e8f0; }
table { width: 100%; border-collapse: collapse; background: white; }
table thead th { background: #f1f5f9; padding: 1rem; text-align: right; font-weight: 700; color: #334155; border-bottom: 2px solid #e2e8f0; white-space: nowrap; }
table tbody td { padding: 0.875rem 1rem; border-bottom: 1px solid #f1f5f9; color: #1e293b; font-size: 0.95rem; }
table tbody tr { transition: background 0.2s; }
table tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 0.3rem 0.85rem; border-radius: 50px; font-size: 0.825rem; font-weight: 700; }
.badge-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.badge-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.badge-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* Login Page */
.login-wrapper { display: flex; justify-content: center; align-items: center; min-height: 85vh; padding: 2rem 0; }
.login-card { width: 100%; max-width: 460px; border-top: 4px solid var(--primary); }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { font-size: 2rem; font-weight: 800; color: #1e293b; margin-bottom: 0.5rem; }
.login-header p { color: #64748b; font-size: 1rem; }

/* Radio cards for concours selection */
.radio-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.radio-card { position: relative; }
.radio-card input[type="radio"] { position: absolute; opacity: 0; }
.radio-card label { display: block; padding: 1.25rem; background: #ffffff; border: 2px solid #e2e8f0; border-radius: 12px; cursor: pointer; transition: all 0.3s; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.radio-card input:checked + label { border-color: var(--primary); background: #eff6ff; box-shadow: 0 0 15px rgba(29, 78, 216, 0.15); }
.radio-card label:hover { border-color: #cbd5e1; transform: translateY(-2px); }
.radio-card label h3 { font-size: 1.05rem; margin-bottom: 0.35rem; color: #0f172a; font-weight: 700; }

/* Upload Zone */
.upload-zone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 2rem; text-align: center; cursor: pointer; transition: all 0.3s; background: #f8fafc; }
.upload-zone:hover { border-color: var(--primary); background: #eff6ff; }
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 0.75rem 1rem; background: #f1f5f9; border-radius: 8px; border: 1px solid #e2e8f0; }

/* Admin Sidebar Layout */
.admin-layout { display: grid; grid-template-columns: 260px 1fr; gap: 2rem; }
.sidebar { background: var(--bg-card); border-radius: 16px; padding: 1.5rem; border: 1px solid var(--border-card); height: fit-content; position: sticky; top: 90px; box-shadow: var(--shadow-card); }
.sidebar-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; color: #475569; text-decoration: none; border-radius: 10px; margin-bottom: 0.35rem; transition: all 0.3s; font-size: 0.95rem; font-weight: 600; }
.sidebar-link:hover { color: var(--primary); background: #f1f5f9; }
.sidebar-link.active { color: var(--primary); background: #eff6ff; border-right: 4px solid var(--primary); }

/* Dashboard Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card { text-align: center; padding: 1.5rem; background: #ffffff; border-radius: 14px; border: 1px solid #e2e8f0; box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.stat-card .stat-number { font-size: 2.5rem; font-weight: 800; color: var(--primary); }
.stat-card .stat-label { color: #64748b; font-size: 0.9rem; margin-top: 0.25rem; font-weight: 600; }

/* Step Navigation */
.step-navigation { display: flex; justify-content: space-between; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid #e2e8f0; }

/* Footer */
.footer { text-align: center; padding: 1.5rem 0; color: #64748b; font-size: 0.9rem; border-top: 1px solid #e2e8f0; margin-top: 2.5rem; }

/* Step Content */
.step-content { display: none; animation: fadeIn 0.4s ease; }
.step-content.active { display: block; }

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

/* Responsive */
@media (max-width: 968px) {
    .admin-layout { grid-template-columns: 1fr; }
    .sidebar { position: static; }
}
@media (max-width: 768px) {
    .navbar-container { flex-direction: column; gap: 0.75rem; }
    .stepper { flex-wrap: wrap; }
    .form-row { grid-template-columns: 1fr; }
}

/* Cursus Table Styling */
#step-3 table {
    min-width: 950px;
    table-layout: fixed;
}
#step-3 table th, #step-3 table td {
    padding: 0.75rem 0.5rem;
}
#step-3 table th:nth-child(1), #step-3 table td:nth-child(1) { width: 110px; } /* السنة الجامعية */
#step-3 table th:nth-child(2), #step-3 table td:nth-child(2) { width: 260px; } /* المؤسسة */
#step-3 table th:nth-child(3), #step-3 table td:nth-child(3) { width: 140px; } /* مستوى الدراسة */
#step-3 table th:nth-child(4), #step-3 table td:nth-child(4) { width: 220px; } /* الشعبة / الاختصاص */
#step-3 table th:nth-child(5), #step-3 table td:nth-child(5) { width: 90px; }  /* المعدل */
#step-3 table th:nth-child(6), #step-3 table td:nth-child(6) { width: 170px; } /* النتيجة */
#step-3 table th:nth-child(7), #step-3 table td:nth-child(7) { width: 95px; text-align: center; } /* انقطاع */

#step-3 table td .form-control {
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
}
#step-3 table td select.form-control {
    padding-left: 2rem;
    background-position: left 0.75rem center;
}
#step-3 .interruption-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}
