/* ===== القواعد الأساسية ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #2c3e50;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== الرأسية ===== */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ===== البطاقات ===== */
.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

/* ===== صف الاختيار ===== */
.selection-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #34495e;
}

.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== جدول المواد ===== */
.subjects-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.9rem;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.subjects-table th,
.subjects-table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
}

.subjects-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.subjects-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.subjects-table tbody tr:hover {
    background-color: #e3f2fd;
    transform: scale(1.01);
    transition: all 0.2s ease;
}

.subject-name {
    font-weight: 600;
    text-align: right;
    background: #f0f2f5 !important;
    min-width: 120px;
    color: #2c3e50;
}

/* ===== حقول الإدخال ===== */
.grade-input {
    width: 60px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.grade-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    transform: scale(1.05);
}

.grade-input:valid {
    border-color: #28a745;
    background-color: #f8fff9;
}

.coefficient-input {
    width: 60px;
    padding: 8px;
    border: 2px solid #ffc107;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    background: #fff3cd;
    transition: all 0.3s ease;
}

.coefficient-input:focus {
    outline: none;
    border-color: #ff8f00;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.2);
}

/* ===== الأزرار ===== */
.actions-row {
    display: flex;
    gap: 10px;
    margin: 20px 0;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* ===== أزرار الحذف ===== */
.delete-btn {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.delete-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

/* ===== نموذج إضافة مادة ===== */
.add-subject-form {
    display: none;
    padding: 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 10px;
    margin: 20px 0;
    border: 2px solid #dee2e6;
}

.add-subject-form.show {
    display: block;
    animation: slideDown 0.4s ease;
}

.add-subject-form h3 {
    margin-bottom: 20px;
    color: #495057;
    text-align: center;
}

.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-row input {
    padding: 12px;
    border: 2px solid #ced4da;
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-row input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* ===== قسم النتائج ===== */
.result-section {
    margin-top: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 15px;
    text-align: center;
    display: none;
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.3);
}

.result-section.show {
    display: block;
    animation: fadeInUp 0.6s ease;
}

.result-section.warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff8f00 100%);
    box-shadow: 0 10px 30px rgba(255, 193, 7, 0.3);
}

.result-section.danger {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    box-shadow: 0 10px 30px rgba(220, 53, 69, 0.3);
}

.result-average {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.result-status {
    font-size: 1.8rem;
    margin-bottom: 15px;
    font-weight: 600;
}

.result-message {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

.result-details {
    margin-top: 25px;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    text-align: right;
}

.result-details h3 {
    margin-bottom: 15px;
    font-size: 1.3rem;
}

/* ===== قسم الإحصائيات ===== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 25px 0;
}

.stat-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 8px;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.stat-label {
    font-size: 0.95rem;
    color: #6c757d;
    font-weight: 600;
}

/* ===== معلومات إضافية ===== */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.info-item {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border-right: 4px solid #667eea;
}

.info-item h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

.info-item p {
    color: #6c757d;
    line-height: 1.6;
}

/* ===== الرسوم المتحركة ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
    }
}

/* ===== التصميم المتجاوب ===== */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .selection-row {
        grid-template-columns: 1fr;
    }
    
    .subjects-table {
        font-size: 0.8rem;
    }
    
    .grade-input, .coefficient-input {
        width: 50px;
        padding: 6px;
    }
    
    .actions-row {
        justify-content: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .result-average {
        font-size: 2.5rem;
    }
    
    .result-status {
        font-size: 1.4rem;
    }
    
    .card {
        padding: 15px;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .subjects-table {
        font-size: 0.7rem;
    }
    
    .grade-input, .coefficient-input {
        width: 40px;
        padding: 4px;
    }
    
    .subjects-table th,
    .subjects-table td {
        padding: 6px;
    }
}

/* ===== تأثيرات إضافية ===== */
.highlight {
    animation: pulse 2s infinite;
}

.fade-in {
    animation: fadeInUp 0.5s ease;
}

.grade-input.excellent {
    border-color: #28a745;
    background-color: #d4edda;
    box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
}

.grade-input.good {
    border-color: #ffc107;
    background-color: #fff3cd;
}

.grade-input.poor {
    border-color: #dc3545;
    background-color: #f8d7da;
}