/* ===============================================
   Unified Style Sheet – البرنامج القومي لتنمية اللغة العربية
   Responsive, RTL, Modern Design
   Color Theme: Green/Teal with Warm Orange Accents
   =============================================== */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #17706E;
  --primary-dark: #0f5a58;
  --primary-light: #1a8a88;
  --primary-lightest: #e8f5f5;
  --accent: #FB7813;
  --accent-dark: #e0660a;
  --accent-light: #fda55a;
  --secondary: #F77EE;
  --secondary-light: #ffb8a0;
  --bg-warm: #F9E8D4;
  --bg-light: #f7f5f0;
  --text-dark: #2d3a3a;
  --text-muted: #5a6e6e;
  --white: #ffffff;
  --border: #dbe5e5;
  --shadow: 0 10px 25px rgba(23, 112, 110, 0.08);
  --shadow-hover: 0 15px 35px rgba(23, 112, 110, 0.2);
  --radius: 16px;
  --radius-sm: 12px;
}

/* ---------- Global Reset & Base ---------- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Tajawal', 'Segoe UI', Arial, sans-serif;
  background-color: var(--bg-light);
  color: var(--text-dark);
  line-height: 1.6;
  direction: rtl;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Typography ---------- */
h1, h2, h3 {
  font-weight: 700;
  line-height: 1.3;
}

/* ---------- Header (unified across all pages except index) ---------- */
.program-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  padding: 0.8rem 0;
  border-bottom: 4px solid var(--accent);
  box-shadow: 0 4px 12px rgba(23, 112, 110, 0.2);
}

.header-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Logo adjustments - more balanced & responsive */
.logo-right, 
.logo-left {
  height: 70px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.logo-right:hover, .logo-left:hover {
  transform: scale(1.02);
}

.title-container {
  flex: 1;
  text-align: center;
}

.program-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  color: var(--white);
  text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* ---------- Login Page Specific ---------- */
.login-page {
  background: linear-gradient(135deg, var(--bg-light), var(--bg-warm));
  min-height: 100vh;
}

.login-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.login-card {
  max-width: 450px;
  width: 100%;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.login-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.login-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 1.5rem;
  text-align: center;
  border-bottom: 4px solid var(--accent);
}

.login-header h2 {
  color: var(--white);
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.login-body {
  padding: 2rem;
}

/* ---------- Buttons ---------- */
.btn, 
.submit-button, 
button[type="submit"],
.save-btn {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  padding: 12px 32px;
  border: none;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
  text-decoration: none;
  text-align: center;
  box-shadow: 0 2px 5px rgba(23, 112, 110, 0.2);
}

.btn:hover, 
.submit-button:hover, 
button[type="submit"]:hover,
.save-btn:hover {
  background: var(--accent);
  color: var(--white);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-block {
  width: 100%;
}

/* Secondary / outline variant */
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: 12px;
}

.btn-outline:hover {
  background: var(--primary);
  color: var(--white);
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.form-group .required {
  color: var(--accent);
  margin-right: 3px;
}

.form-control, select.form-control, input.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  transition: all 0.2s;
  background: var(--white);
  font-family: inherit;
}

.form-control:focus, select.form-control:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(23, 112, 110, 0.15);
}

.form-control.error {
  border-color: #dc3545;
}

.form-control.error:focus {
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

.form-control.success {
  border-color: var(--primary);
}

.form-control.success:focus {
  box-shadow: 0 0 0 3px rgba(23, 112, 110, 0.2);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%232d3a3a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  background-size: 16px;
}

/* Remember Me checkbox */
.remember-me {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 1rem 0 1.5rem;
}

.remember-me input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.remember-me label {
  font-weight: 500;
  color: var(--text-dark);
  cursor: pointer;
  font-size: 0.95rem;
}

/* Login messages */
.login-message {
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  display: none;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}

.login-message.show {
  display: flex;
}

.login-message.error {
  background: #f8d7da;
  border: 2px solid #dc3545;
  color: #721c24;
}

.login-message.success {
  background: #d4edda;
  border: 2px solid #28a745;
  color: #155724;
}

.login-message.info {
  background: #cce5ff;
  border: 2px solid #007bff;
  color: #004085;
}

.login-message i {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* Login footer links */
.login-footer {
  text-align: center;
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.login-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s;
}

.login-footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- Error & helper texts ---------- */
.error-message {
  color: #dc3545;
  font-size: 0.8rem;
  margin-top: 5px;
  display: none;
}

.form-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ---------- Cards & Containers ---------- */
.card, .welcome-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover, .welcome-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.card-header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  padding: 1.2rem;
  text-align: center;
  border-bottom: 3px solid var(--accent);
}

.card-header h2 {
  color: var(--white);
  margin: 0;
  font-size: 1.5rem;
}

.card-body {
  padding: 2rem;
}

/* ---------- Top Bar (dashboard) ---------- */
.topbar {
  background: var(--white);
  width: 95%;
  margin: 20px auto;
  padding: 12px 25px;
  border-radius: 50px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: 0 5px 12px rgba(23, 112, 110, 0.08);
  border: 1px solid rgba(23, 112, 110, 0.05);
}

.topbar .welcome {
  font-weight: 700;
  color: var(--primary);
}

.topbar .welcome i {
  color: var(--accent);
  margin-left: 8px;
}

.topbar-links a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  margin-right: 20px;
  transition: color 0.2s;
}

.topbar-links a:hover {
  color: var(--accent);
}

.topbar-links a.logout-link {
  color: #dc3545;
}

.topbar-links a.logout-link:hover {
  color: #a71d2a;
}

/* ---------- Filter Row (school/grade selectors) ---------- */
.form-row1 {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background: var(--white);
  padding: 20px;
  border-radius: var(--radius);
  width: 95%;
  margin: 20px auto;
  box-shadow: 0 5px 12px rgba(23, 112, 110, 0.08);
  border: 1px solid rgba(23, 112, 110, 0.05);
}

.form-group1 {
  flex: 1;
  min-width: 180px;
}

.form-group1 label {
  font-weight: 600;
  margin-bottom: 8px;
  display: block;
  color: var(--text-dark);
}

/* Counters */
.counters {
  display: flex;
  justify-content: center;
  gap: 25px;
  flex-wrap: wrap;
  margin: 20px auto;
  font-weight: 600;
  background: var(--white);
  padding: 12px 20px;
  border-radius: 50px;
  width: fit-content;
  box-shadow: 0 5px 12px rgba(23, 112, 110, 0.08);
  border: 1px solid rgba(23, 112, 110, 0.05);
}

.counters span {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Student Evaluation Table Styles ---------- */
.student-info-cell {
  min-width: 220px;
  padding: 8px 10px !important;
  text-align: right !important;
  vertical-align: top !important;
}

.student-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dark);
  margin-bottom: 4px;
}

.student-details {
  margin-top: 4px;
}

.student-details .details-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 4px;
}

.student-details .details-row label {
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: var(--text-dark);
}

.student-details .details-row label:hover {
  color: var(--primary);
}

.student-details input[type="radio"],
.student-details input[type="checkbox"] {
  transform: scale(0.85);
  margin: 0 2px;
  cursor: pointer;
  accent-color: var(--primary);
}

.student-details select {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  transition: border-color 0.2s;
}

.student-details select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(23, 112, 110, 0.15);
}

.student-details select:disabled {
  background: #f5f5f5;
  opacity: 0.7;
}

/* Grade inputs */
.grade-input {
  width: 55px;
  padding: 6px 4px;
  font-size: 0.8rem;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: white;
  transition: all 0.3s ease;
  font-weight: 600;
  color: var(--text-dark);
}

.grade-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 112, 110, 0.15);
  outline: none;
}

.grade-input.grade-filled {
  border-color: var(--primary);
  background: var(--primary-lightest);
}

.grade-input.grade-error {
  border-color: #dc3545;
  background: #fff5f5;
}

.grade-input:disabled {
  background: #f0f0f0;
  opacity: 0.6;
  cursor: not-allowed;
}

.grade-input::placeholder {
  color: #aaa;
  font-size: 0.7rem;
}

/* Question header */
.question-header {
  font-size: 0.75rem;
  white-space: nowrap;
  padding: 6px 4px !important;
}

.question-header .max-score {
  display: block;
  font-weight: 400;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.85);
}

/* Grade cell */
.grade-cell {
  padding: 4px !important;
  min-width: 60px;
  text-align: center !important;
}

/* Action cell */
.action-cell {
  padding: 4px !important;
  min-width: 85px;
  text-align: center !important;
}

/* Save button */
.save-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.save-btn:hover {
  background: var(--accent);
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.save-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.save-btn i {
  font-size: 0.7rem;
}

/* Empty state */
.empty-state {
  background: var(--bg-warm);
  border: 2px solid var(--secondary);
  border-radius: var(--radius-sm);
  padding: 40px;
  text-align: center;
  color: var(--text-dark);
}

.empty-state i {
  font-size: 3rem;
  display: block;
  margin-bottom: 15px;
  color: var(--accent);
}

.empty-state h5 {
  font-weight: 700;
  margin-bottom: 10px;
}

/* Table responsive */
.table-responsive {
  overflow-x: auto;
  margin: 10px 0;
}

.table-responsive table {
  min-width: 800px;
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* ---------- Table Styles (general) ---------- */
#studentsTableContainer {
  width: 95%;
  margin: 20px auto;
  overflow-x: auto;
}

table th, table td {
  border: 1px solid var(--border);
  padding: 12px 8px;
  text-align: center;
  vertical-align: middle;
}

table th {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  font-weight: 700;
}

table th:first-child {
  text-align: right;
}

table tr:nth-child(even) {
  background-color: #faf8f5;
}

table tr:hover {
  background-color: var(--primary-lightest);
}

/* ---------- Remove Arrows from Number Inputs (global) ---------- */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ---------- Radio and checkbox scaling ---------- */
input[type="radio"], input[type="checkbox"] {
  margin: 0 3px;
  transform: scale(0.85);
}

/* ---------- Index Page (without header, fullscreen background) ---------- */
body.index-page {
  background: linear-gradient(rgba(23, 112, 110, 0.7), rgba(23, 112, 110, 0.7)), url('read.jpg') center/cover fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  padding: 20px;
}

body.index-page .program-header {
  display: none;
}

.main-container {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-card {
  max-width: 750px;
  width: 90%;
  text-align: center;
  padding: 40px 30px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(4px);
  border-radius: 25px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.25);
  border-top: 6px solid var(--accent);
}

.welcome-card .program-title {
  color: var(--primary);
  margin-bottom: 30px;
  font-size: 2rem;
}

.buttons {
  display: flex;
  justify-content: center;
  gap: 25px;
  flex-wrap: wrap;
}

/* ---------- Responsive (Mobile first adjustments) ---------- */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  .logo-right, .logo-left {
    height: 50px;
  }
  .program-title {
    font-size: 1.1rem;
  }
  .card-body, .login-body {
    padding: 1.2rem;
  }
  .form-row1 {
    flex-direction: column;
    gap: 12px;
  }
  .topbar {
    flex-direction: column;
    text-align: center;
    border-radius: 20px;
    padding: 12px 15px;
  }
  .topbar-links a {
    margin: 0 10px;
  }
  .counters {
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border-radius: 20px;
  }
  .student-info-cell {
    min-width: 180px;
  }
  .grade-input {
    width: 42px;
    font-size: 0.7rem;
    padding: 4px 2px;
  }
  .question-header {
    font-size: 0.6rem;
  }
  .student-details .details-row {
    gap: 8px;
  }
  .student-details .details-row label {
    font-size: 0.65rem;
  }
  th, td {
    padding: 8px 4px;
    font-size: 0.7rem;
  }
  .save-btn {
    padding: 4px 10px;
    font-size: 0.65rem;
  }
  .welcome-card {
    padding: 25px;
  }
  .welcome-card .program-title {
    font-size: 1.4rem;
  }
  .btn {
    padding: 10px 20px;
    min-width: 160px;
  }
  .login-card {
    max-width: 100%;
    margin: 0 10px;
  }
  .grade-cell {
    min-width: 45px;
    padding: 2px !important;
  }
  .action-cell {
    min-width: 65px;
    padding: 2px !important;
  }
}

/* For very small devices */
@media (max-width: 480px) {
  .form-group1 {
    min-width: 100%;
  }
  table, .table-responsive {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  .login-body {
    padding: 1.2rem;
  }
  .btn {
    padding: 10px 16px;
    font-size: 0.9rem;
  }
  .remember-me {
    flex-wrap: wrap;
  }
  .grade-input {
    width: 36px;
    font-size: 0.65rem;
    padding: 3px 1px;
  }
  .student-info-cell {
    min-width: 150px;
    padding: 4px 6px !important;
  }
  .student-name {
    font-size: 0.75rem;
  }
  .student-details .details-row label {
    font-size: 0.6rem;
  }
  .counters {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}

/* ---------- Additional accent elements ---------- */
/* Accent border for cards */
.card-accent {
  border-top: 4px solid var(--accent);
}

/* Progress bars or status indicators */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.success {
  background: var(--primary-lightest);
  color: var(--primary);
}

.status-badge.warning {
  background: #fff3e0;
  color: var(--accent);
}

.status-badge.danger {
  background: #fde8e8;
  color: #dc3545;
}