 :root {
     /* ألوان الوضع الفاتح */
     --light-bg: #f8f9fa;
     --light-text: #2c3e50;
     --light-secondary-text: #7f8c8d;
     --light-card-bg: white;
     --light-input-bg: white;
     --light-border: #e0e0e0;
     --light-input-border: #3498db;
     --primary: #3498db;
     --primary-light: #60a5fa;
     --success: #2ecc71;
     --success-light: #6ee7b7;
     --danger: #e74c3c;
     --warning: #f39c12;
     --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);

     /* ألوان الوضع الداكن - محسّنة */
     --dark-bg: #1a1f2c;
     --dark-card-bg: #252c3d;
     --dark-input-bg: #1e2432;
     --dark-border: #3a4256;
     --dark-input-border: #4b6cb7;
     --dark-text: #f1f5f9;
     --dark-secondary-text: #cbd5e1;
     --dark-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
 }

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

 body {
     font-family: 'Tajawal', Arial, sans-serif;
     line-height: 1.6;
     background-color: var(--light-bg);
     color: var(--light-text);
     padding: 16px;
     min-height: 100vh;
     transition: background-color 0.3s, color 0.3s;
 }

 body.dark-mode {
     background-color: var(--dark-bg);
     color: var(--dark-text);
 }

 .container {
     max-width: 30%;
     margin: 0 auto;
     position: relative;
     z-index: 10;
     padding-top: 20px;
 }

 h1 {
     text-align: center;
     margin-bottom: 12px;
     font-size: 1.8rem;
     color: var(--primary);
     transition: color 0.3s;
 }

 .subtitle {
     text-align: center;
     color: var(--light-secondary-text);
     font-size: 0.9rem;
     transition: color 0.3s;
 }

 body.dark-mode .subtitle {
     color: var(--dark-secondary-text);
 }

 form {
     margin: 15px 0;
 }

 label {
     display: block;
     margin-bottom: 8px;
     font-weight: 500;
     color: var(--light-text);
     transition: color 0.3s;
 }

 body.dark-mode label {
     color: var(--dark-text);
 }

 select,
 input {
     width: 100%;
     padding: 10px 15px;
     font-family: inherit;
     border: 2px solid var(--light-input-border);
     border-radius: 12px;
     background: var(--light-input-bg);
     font-size: 1rem;
     margin-bottom: 12px;
     color: var(--light-text);
     transition: all 0.3s;
 }

 /* إخفاء السهمين من حقول الأرقام */
 input[type="number"]::-webkit-inner-spin-button,
 input[type="number"]::-webkit-outer-spin-button {
     -webkit-appearance: none;
     margin: 0;
 }

 input[type="number"] {
     -moz-appearance: textfield;
     appearance: textfield;
 }

 body.dark-mode select,
 body.dark-mode input {
     background: var(--dark-input-bg);
     border-color: var(--dark-input-border);
     color: var(--dark-text);
 }

 select:focus,
 input:focus {
     outline: none;
     box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
 }

 body.dark-mode select:focus,
 body.dark-mode input:focus {
     box-shadow: 0 0 0 3px rgba(75, 108, 183, 0.4);
 }

 #subjectsForm {
     display: flex;
     flex-direction: column;
     gap: 10px;
     margin-top: 15px;
 }

 .subject {
     display: flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     padding: 10px 0;
 }

 .subject-number {
     width: 28px;
     height: 28px;
     border-radius: 50%;
     background: var(--primary);
     color: white;
     display: flex;
     align-items: center;
     justify-content: center;
     font-weight: bold;
     font-size: 14px;
     flex-shrink: 0;
 }

 .subject-name {
     flex: 2;
     min-width: 100px;
 }

 .subject-cr {
     flex: 1;
     min-width: 65px;
 }

 .subject-grade {
     flex: 1;
     min-width: 85px;
 }

 .subject-name,
 .subject-cr,
 .subject-grade {
     border: 2px solid var(--light-input-border);
     border-radius: 20px;
     padding: 8px 12px;
     text-align: center;
     background: transparent;
     font-weight: 500;
     transition: all 0.3s;
 }

 body.dark-mode .subject-name,
 body.dark-mode .subject-cr,
 body.dark-mode .subject-grade {
     border-color: var(--dark-input-border);
 }

 .remove-btn {
     width: 28px;
     height: 28px;
     border-radius: 50%;
     background: var(--danger);
     color: white;
     border: none;
     font-weight: bold;
     cursor: pointer;
     display: flex;
     align-items: center;
     justify-content: center;
     font-size: 16px;
     flex-shrink: 0;
     transition: all 0.2s;
 }

 .remove-btn:hover {
     background: #c0392b;
     transform: scale(1.05);
 }

 .btn {
     padding: 12px 20px;
     font-family: 'Tajawal';
     border: none;
     border-radius: 12px;
     cursor: pointer;
     font-weight: bold;
     margin: 10px 0;
     width: 100%;
     transition: all 0.2s ease;
     box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
 }

 .add-btn {
     background: var(--success);
     color: white;
     display: flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
 }

 .add-btn:hover {
     background: #27ae60;
 }

 .gpa-btn {
     background: var(--primary);
     color: white;
     font-size: 1.1rem;
     padding: 14px;
 }

 .gpa-btn:hover {
     background: #2980b9;
 }

 .clear-data-btn {
     background: var(--danger);
     color: white;
 }

 .clear-data-btn:hover {
     background: #c0392b;
 }

 .result-box {
     background: var(--light-card-bg);
     border: 1px solid var(--light-border);
     border-radius: 12px;
     padding: 16px;
     margin-top: 20px;
     box-shadow: var(--shadow);
     display: none;
     transition: all 0.3s;
 }

 body.dark-mode .result-box {
     background: var(--dark-card-bg);
     border-color: var(--dark-border);
     box-shadow: var(--dark-shadow);
 }

 .button-group {
     display: flex;
     flex-direction: column;
     gap: 10px;
     margin-top: 20px;
 }

 #cumulativeFields {
     background: var(--light-card-bg);
     border: 1px solid var(--light-border);
     border-radius: 12px;
     padding: 15px;
     margin: 15px 0;
     display: none;
     transition: all 0.3s;
     box-shadow: var(--shadow);
 }

 body.dark-mode #cumulativeFields {
     background: var(--dark-card-bg);
     border-color: var(--dark-border);
     box-shadow: var(--dark-shadow);
 }

 @media (max-width: 480px) {
     .container {
         max-width: 100%;
     }

     .subject {
         flex-direction: row;
         gap: 6px;
     }

     .subject-name,
     .subject-cr,
     .subject-grade {
         font-size: 0.9rem;
         padding: 7px 10px;
     }

     .remove-btn {
         width: 26px;
         height: 26px;
         font-size: 14px;
     }
 }

 @media (min-width: 768px) {
     .subject {
         gap: 12px;
     }

     .subject-name {
         min-width: 150px;
     }

     .subject-cr,
     .subject-grade {
         min-width: 80px;
     }
 }

 /* Theme toggle button */
 .theme-toggle-btn {
     background: var(--warning);
     color: white;
 }

 .theme-toggle-btn:hover {
     background: #e67e22;
 }

 body.dark-mode .theme-toggle-btn {
     background: #4b6cb7;
 }

 body.dark-mode .theme-toggle-btn:hover {
     background: #5a7ec7;
 }

 /* Loading indicator */
 .loading {
     display: inline-block;
     width: 20px;
     height: 20px;
     border: 3px solid rgba(255, 255, 255, 0.3);
     border-radius: 50%;
     border-top-color: white;
     animation: spin 1s linear infinite;
     margin-left: 8px;
 }

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

 /* Empty state message */
 .empty-state {
     text-align: center;
     color: var(--light-secondary-text);
     padding: 20px;
     background: var(--light-card-bg);
     border-radius: 12px;
     margin: 10px 0;
     font-style: italic;
     transition: all 0.3s;
     border: 1px solid var(--light-border);
 }

 body.dark-mode .empty-state {
     background: var(--dark-card-bg);
     color: var(--dark-secondary-text);
     border-color: var(--dark-border);
 }

 /* Honor message styles */
 .honor-message {
     margin: 15px 0;
     padding: 12px;
     background: #e8f5e9;
     border-radius: 8px;
     border-left: 4px solid #2ecc71;
     color: #27ae60;
     font-weight: 500;
 }

 body.dark-mode .honor-message {
     background: rgba(46, 204, 113, 0.1);
     border-color: #2ecc71;
     color: #6ee7b7;
 }

 .honor-amount {
     margin: 10px 0;
     padding: 8px;
     background: #e8f5e9;
     border-radius: 8px;
     color: #27ae60;
     font-weight: 500;
 }

 body.dark-mode .honor-amount {
     background: rgba(46, 204, 113, 0.1);
     color: #6ee7b7;
 }

 /* Modal styles */
 .gpa-modal {
     display: none;
     position: fixed;
     z-index: 2000;
     left: 0;
     top: 0;
     width: 100%;
     height: 100%;
     background-color: rgba(0, 0, 0, 0.7);
     backdrop-filter: blur(5px);
     align-items: center;
     justify-content: center;
 }

 .gpa-modal.active {
     display: flex;
 }

 .gpa-modal-content {
     background: var(--light-card-bg);
     border-radius: 16px;
     padding: 24px;
     max-width: 90%;
     max-height: 90vh;
     overflow: auto;
     box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
     transition: all 0.3s;
 }

 body.dark-mode .gpa-modal-content {
     background: var(--dark-card-bg);
 }

 .gpa-modal-image {
     width: 100%;
     height: auto;
     border-radius: 8px;
     margin-bottom: 16px;
 }

 .gpa-modal-close-btn {
     width: 100%;
     padding: 12px;
     background: var(--primary);
     color: white;
     border: none;
     border-radius: 8px;
     font-weight: bold;
     cursor: pointer;
     font-size: 1rem;
     font-family: 'Tajawal';
     transition: all 0.2s;
 }

 .gpa-modal-close-btn:hover {
     background: #2980b9;
 }

 .info-link {
     display: inline-block;
     margin-top: 12px;
     padding: 10px 16px;
     background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     color: white;
     text-decoration: none;
     cursor: pointer;
     font-size: 0.95rem;
     font-weight: 500;
     border-radius: 8px;
     transition: all 0.3s;
     box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
 }

 .info-link:hover {
     transform: translateY(-2px);
     box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
     background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
 }

 body.dark-mode .info-link {
     background: linear-gradient(135deg, #4b6cb7 0%, #182848 100%);
     box-shadow: 0 2px 8px rgba(75, 108, 183, 0.4);
 }

 body.dark-mode .info-link:hover {
     transform: translateY(-2px);
     box-shadow: 0 4px 12px rgba(75, 108, 183, 0.5);
     background: linear-gradient(135deg, #182848 0%, #4b6cb7 100%);
 }
