/* ===== RESET + VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --success:       #10b981;
  --danger:        #ef4444;
  --bg:            #f0f4f8;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --muted:         #64748b;
  --shadow:        0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 24px rgba(0,0,0,0.13);
  --radius:        14px;
  --radius-sm:     8px;
}

body {
  font-family: 'Segoe UI', 'Arial Hebrew', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}

/* ===== AUTH PAGE ===== */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 55%, #0ea5e9 100%);
  padding: 20px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 52px; display: block; margin-bottom: 10px; }
.auth-logo h1 { font-size: 24px; font-weight: 700; }
.auth-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Tabs */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1; padding: 10px; text-align: center;
  font-weight: 600; font-size: 14px; cursor: pointer;
  color: var(--muted); border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.2s; font-family: inherit;
}
.auth-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Role selector */
.role-select { display: flex; gap: 10px; }
.role-option {
  flex: 1; border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 8px; text-align: center; cursor: pointer;
  font-size: 13px; font-weight: 600; transition: all 0.2s;
}
.role-option:hover { border-color: var(--primary); background: var(--primary-light); }
.role-option input[type="radio"] { display: none; }
.role-option.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.role-option .role-icon { font-size: 26px; display: block; margin-bottom: 4px; }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; }

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, background 0.2s;
  background: #f8fafc;
  color: var(--text);
  direction: rtl;
}
input[type="email"],
input[type="password"] { direction: ltr; text-align: right; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: #fff;
}
textarea { min-height: 115px; resize: vertical; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; font-family: inherit; white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: #cbd5e1; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled)  { background: #059669; }
.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled)    { background: var(--border); color: var(--text); }
.btn-ai        { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; }
.btn-ai:hover:not(:disabled)       { filter: brightness(1.1); }
.btn-full      { width: 100%; justify-content: center; padding: 13px; font-size: 15px; }
.btn-sm        { padding: 6px 14px; font-size: 13px; }

/* ===== MESSAGES ===== */
.error-msg {
  background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 12px;
}
.success-msg {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #16a34a;
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 12px;
}
.hidden { display: none !important; }

/* ===== DASHBOARD LAYOUT ===== */
.dashboard-page { min-height: 100vh; display: flex; flex-direction: column; }

.top-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.header-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 18px; color: var(--primary);
  text-decoration: none;
}
.header-brand .brand-icon { font-size: 26px; }
.header-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--muted);
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}

/* ===== TEACHER SPLIT LAYOUT ===== */
.dashboard-body {
  display: flex; flex: 1;
  height: calc(100vh - 64px); overflow: hidden;
}

.sidebar {
  width: 268px; background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0; overflow: hidden;
}
.sidebar-header { padding: 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

.student-list { overflow-y: auto; flex: 1; padding: 8px; }
.sidebar-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.8; }

.student-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s; margin-bottom: 2px;
}
.student-item:hover  { background: #f1f5f9; }
.student-item.active { background: var(--primary-light); color: var(--primary); }

.student-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #dbeafe; color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.student-name  { font-weight: 600; font-size: 14px; }
.student-grade { font-size: 12px; color: var(--muted); }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}

.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; color: var(--muted); gap: 12px;
}
.empty-state .empty-icon { font-size: 72px; opacity: 0.35; }
.empty-state h3 { font-size: 18px; color: var(--text); font-weight: 600; }
.empty-state p  { font-size: 14px; }

/* ===== CARD ===== */
.card {
  background: var(--surface); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 18px;
}
.card-title { font-size: 16px; font-weight: 700; }

/* ===== AI SUMMARY ===== */
.ai-summary-box {
  background: linear-gradient(135deg, #faf5ff, #f3e8ff);
  border: 2px solid #e9d5ff; border-radius: var(--radius-sm);
  padding: 14px 16px; margin-top: 12px;
}
.ai-label {
  font-size: 11px; font-weight: 700; color: #7c3aed;
  margin-bottom: 7px; display: flex; align-items: center; gap: 5px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.ai-summary-text { font-size: 14px; line-height: 1.65; }

/* ===== FILE UPLOAD ===== */
.file-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 20px 16px; text-align: center; cursor: pointer;
  transition: all 0.2s; background: #f8fafc;
}
.file-upload-area:hover,
.file-upload-area.drag-over { border-color: var(--primary); background: var(--primary-light); }
.upload-icon { font-size: 30px; margin-bottom: 6px; }
.file-upload-area p     { font-size: 13px; color: var(--muted); }
.file-upload-area small { font-size: 11px; color: #94a3b8; }

.file-preview {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; background: #f1f5f9;
  border-radius: var(--radius-sm); margin-top: 8px;
  font-size: 13px; border: 1px solid var(--border);
}
.file-icon { font-size: 20px; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-file {
  cursor: pointer; color: var(--danger); font-size: 22px;
  line-height: 1; background: none; border: none; font-family: inherit;
}

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ===== FEEDBACK ITEMS ===== */
.feedback-list { display: flex; flex-direction: column; gap: 16px; }

.empty-feedback {
  text-align: center; padding: 32px; color: var(--muted); font-size: 14px;
}

.feedback-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
}
.feedback-item:hover { box-shadow: var(--shadow-lg); }

.feedback-item-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: #fafafa; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.feedback-date    { font-size: 12px; }
.feedback-teacher { font-size: 13px; font-weight: 600; color: var(--text); }
.feedback-student { font-size: 13px; font-weight: 700; color: var(--primary); }

.feedback-body    { padding: 16px 18px; }
.feedback-content { font-size: 14px; line-height: 1.75; white-space: pre-wrap; }

.feedback-summary {
  margin-top: 12px; padding: 12px;
  background: linear-gradient(135deg, #faf5ff, #f3e8ff);
  border: 1px solid #e9d5ff; border-radius: var(--radius-sm); font-size: 13px;
}
.summary-label {
  font-size: 11px; font-weight: 700; color: #7c3aed;
  margin-bottom: 5px; display: flex; align-items: center; gap: 4px;
}

.feedback-attachment { margin-top: 12px; }
.feedback-attachment a {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--primary); font-size: 13px; text-decoration: none;
  padding: 6px 12px; background: var(--primary-light); border-radius: var(--radius-sm);
}
.feedback-attachment a:hover { background: #dbeafe; }

/* ===== REPLIES ===== */
.replies-section { border-top: 1px solid var(--border); background: #f8fafc; }
.replies-list    { padding: 12px 18px; display: flex; flex-direction: column; gap: 8px; }

.reply-item {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 14px;
}
.reply-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 5px;
}
.reply-author { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.reply-date   { font-size: 11px; color: var(--muted); }
.reply-content { font-size: 13px; line-height: 1.5; }

.role-badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; font-weight: 600; }
.role-badge.teacher { background: #dbeafe; color: var(--primary); }
.role-badge.parent  { background: #dcfce7; color: #16a34a; }

.reply-form {
  padding: 10px 18px 14px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; align-items: flex-end;
}
.reply-form textarea { flex: 1; min-height: 52px; }

/* ===== ADD STUDENT MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 30px 28px; max-width: 440px; width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal h2 { margin-bottom: 20px; font-size: 19px; }
.modal-actions { display: flex; gap: 10px; flex-direction: row-reverse; margin-top: 20px; }

/* ===== LOADING ===== */
.loading {
  display: flex; align-items: center; justify-content: center;
  padding: 36px; color: var(--muted); font-size: 14px; gap: 10px;
}
.spinner {
  width: 20px; height: 20px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  .dashboard-body     { flex-direction: column; height: auto; overflow: visible; }
  .sidebar            { width: 100%; height: auto; border-left: none; border-bottom: 1px solid var(--border); }
  .student-list       { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px; overflow-x: auto; max-height: none; }
  .student-item       { flex-direction: column; text-align: center; padding: 10px; min-width: 68px; margin-bottom: 0; }
  .main-content       { height: auto; overflow: visible; }
  .reply-form         { flex-direction: column; }
  .auth-card          { padding: 28px 20px; }
  .form-actions       { flex-direction: column; }
  .form-actions .btn  { justify-content: center; }
  .top-header         { padding: 0 14px; }
  .header-user span   { display: none; }
  .modal-actions      { flex-direction: column; }
}

/* ===== ROLE BADGES (extended) ===== */
.role-badge.admin   { background: #ede9fe; color: #7c3aed; }
.role-badge.student { background: #fef9c3; color: #a16207; }

/* ===== ADMIN LAYOUT ===== */
.admin-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px;
  width: 100%;
}

/* Stats row */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
@media (max-width: 700px) {
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--accent, var(--primary));
}
.stat-icon { font-size: 32px; flex-shrink: 0; }
.stat-num  { font-size: 30px; font-weight: 800; color: var(--accent, var(--primary)); line-height: 1; }
.stat-label { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* Tabs */
.admin-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 4px;
}
.admin-tab {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-family: inherit;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.admin-tab:hover { color: var(--primary); background: var(--primary-light); }
.admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-light);
}

/* Panels */
.admin-panel { display: none; }
.admin-panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-header h2 { font-size: 17px; font-weight: 700; }

/* Table */
.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table th {
  background: #f8fafc;
  padding: 11px 14px;
  text-align: right;
  font-weight: 700;
  font-size: 12px;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f8fafc; }

.admin-empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* Danger button */
.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

/* Count badge */
.badge-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

/* AI and file badges in feedback table */
.ai-badge, .file-badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 4px;
  margin-left: 4px;
}
.ai-badge   { background: #faf5ff; color: #7c3aed; border: 1px solid #e9d5ff; }
.file-badge { background: var(--primary-light); color: var(--primary); border: 1px solid #bfdbfe; }

/* Feedback excerpt in admin table */
.feedback-excerpt {
  max-height: 54px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 13px;
  color: var(--text);
  line-height: 1.6;
}
