/* ==============================
   Elmister - Main Stylesheet
   ============================== */

@import url('https://fonts.googleapis.com/css2?family=Rubik:ital,wght@0,300..900;1,300..900&display=swap');
@import url('app-shell.css');
@import url('app-pages.css');
@import url('page-list-shared.css');

:root {
  --primary:       #f96f7e;
  --primary-dark:  #e04f61;
  --primary-light: #ffecef;
  --accent:        #FF6F00;
  --green:         #2E7D32;
  --green-light:   #E8F5E9;
  --blue:          #1565C0;
  --blue-light:    #E3F2FD;
  --yellow:        #F9A825;
  --yellow-light:  #FFFDE7;
  --app-content-bg: #f5f7fb;
  --gray-50:       #FAFAFA;
  --gray-100:      #F5F5F5;
  --gray-200:      #EEEEEE;
  --gray-300:      #E0E0E0;
  --gray-400:      #BDBDBD;
  --gray-500:      #9E9E9E;
  --gray-600:      #757575;
  --gray-700:      #616161;
  --gray-800:      #424242;
  --gray-900:      #212121;
  --white:         #FFFFFF;
  --sidebar-width: 272px;
  --header-height: 64px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;
  --shadow:        0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:     0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg:     0 8px 32px rgba(0,0,0,0.16);
  --transition:    0.2s ease;

  /* Form fields — unified palette */
  --field-bg:            #fafbfc;
  --field-border:        #e2e6ef;
  --field-border-width:  1.5px;
  --field-border-hover:  #cbd5e1;
  --field-focus-border:  #94a3b8;
  --field-focus-ring:    rgba(148, 163, 184, 0.28);
  --field-text:          #1a1d24;
  --field-label:         #1a1d24;
  --field-placeholder:   #94a3b8;
  --field-icon:          #94a3b8;
  --field-radius:        11px;
  --field-min-height:    46px;
  --field-padding-block: 13px;
  --field-padding-inline: 14px;
  --field-padding-icon:  44px;
}

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

html {
  direction: rtl;
}

html[dir="ltr"] {
  direction: ltr;
}

html[dir="rtl"] {
  direction: rtl;
}

body {
  font-family: 'Rubik', system-ui, -apple-system, sans-serif;
  background: var(--app-content-bg);
  color: var(--gray-900);
  direction: inherit;
  font-size: 14px;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; direction: inherit; }

/* ==============================
   LAYOUT
   ============================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  position: fixed;
  top: 0;
  inset-inline-start: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  width: 40px; height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.sidebar-logo .brand-name {
  color: white;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.sidebar-logo .brand-sub {
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
}

.sidebar-teacher {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-teacher img {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
}

.sidebar-teacher .teacher-name {
  color: white;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-teacher .teacher-role {
  color: var(--gray-500);
  font-size: 11px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-title {
  padding: 8px 24px 4px;
  color: var(--gray-500);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  color: var(--gray-400);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  border-inline-end: 3px solid transparent;
  cursor: pointer;
}

.nav-item:hover {
  color: white;
  background: rgba(255,255,255,0.05);
}

.nav-item.active {
  color: white;
  background: rgba(229,57,53,0.15);
  border-inline-end-color: var(--primary);
}

.nav-item .nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active .nav-icon,
.nav-item:hover .nav-icon {
  opacity: 1;
}

.nav-item .badge {
  margin-inline-start: auto;
  background: var(--primary);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 700;
}

/* Main Content */
.main-content {
  margin-inline-start: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--app-content-bg);
}

/* Header */
.top-header {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.header-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--gray-900);
}

.header-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-icon {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* Page Content */
.page-content {
  padding: 24px;
  flex: 1;
  background: var(--app-content-bg);
}

/* ==============================
   CARDS & STATS
   ============================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
}

.stat-icon.red    { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--green-light); color: var(--green); }
.stat-icon.blue   { background: var(--blue-light); color: var(--blue); }
.stat-icon.yellow { background: var(--yellow-light); color: var(--yellow); }

.stat-info .stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

.stat-info .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
  font-weight: 500;
}

/* Card */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}

.card-body {
  padding: 20px;
}

/* ==============================
   BUTTONS
   ============================== */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  transition: all var(--transition);
  cursor: pointer;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-success {
  background: var(--green);
  color: white;
}
.btn-success:hover { background: #1B5E20; }

.btn-warning {
  background: var(--yellow);
  color: white;
}

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

.btn-outline {
  background: transparent;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover {
  background: var(--gray-100);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
  border-radius: var(--radius);
}

/* ==============================
   TABLE
   ============================== */

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: start;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  color: var(--gray-800);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--gray-50); }

/* ==============================
   FORMS
   ============================== */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--field-label);
  margin-bottom: 6px;
}

.form-control,
input.form-control,
select.form-control,
textarea.form-control {
  width: 100%;
  min-height: var(--field-min-height);
  padding-block: var(--field-padding-block);
  padding-inline: var(--field-padding-inline);
  border: var(--field-border-width) solid var(--field-border);
  border-radius: var(--field-radius);
  font-size: 14px;
  color: var(--field-text);
  background: var(--field-bg);
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  direction: inherit;
  box-sizing: border-box;
}

.form-control:hover:not(:disabled):not(:focus),
input.form-control:hover:not(:disabled):not(:focus),
select.form-control:hover:not(:disabled):not(:focus),
textarea.form-control:hover:not(:disabled):not(:focus) {
  border-color: var(--field-border-hover);
}

.form-control:focus,
input.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
  outline: none;
  border-color: var(--field-focus-border);
  box-shadow: 0 0 0 3px var(--field-focus-ring);
  background: var(--field-bg);
}

.form-control::placeholder,
input.form-control::placeholder,
textarea.form-control::placeholder {
  color: var(--field-placeholder);
  opacity: 1;
}

.form-control:disabled,
select.form-control:disabled,
textarea.form-control:disabled {
  background: var(--gray-50);
  color: var(--gray-500);
  cursor: not-allowed;
  opacity: 0.85;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  padding-inline-start: 14px;
  padding-inline-end: 36px;
}

html[dir="rtl"] select.form-control {
  background-position: left 14px center;
}

html[dir="ltr"] select.form-control {
  background-position: right 14px center;
}

textarea.form-control {
  min-height: 96px;
  resize: vertical;
  padding-block: 12px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

/* ==============================
   BADGES & STATUS
   ============================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-success  { background: var(--green-light);   color: var(--green); }
.badge-danger   { background: var(--primary-light); color: var(--primary); }
.badge-warning  { background: var(--yellow-light);  color: var(--yellow); }
.badge-info     { background: var(--blue-light);    color: var(--blue); }
.badge-gray     { background: var(--gray-100);      color: var(--gray-600); }

/* ==============================
   MODAL
   ============================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { transform: scale(0.95) translateY(10px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--gray-900);
}

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--gray-100);
  color: var(--gray-600);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-close:hover { background: var(--gray-200); }

.modal-body { padding: 24px; }

.confirm-modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.confirm-modal__icon {
  font-size: 22px;
  line-height: 1;
}

.confirm-modal__message {
  margin: 0;
  font-size: 14px;
  line-height: 1.7;
  color: var(--gray-700);
}

.confirm-modal__footer {
  gap: 10px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

/* ==============================
   SEARCH & FILTERS
   ============================== */

.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
}

.search-box input {
  padding-inline-end: 40px;
  width: 100%;
  min-height: var(--field-min-height);
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  background: var(--field-bg);
  color: var(--field-text);
  font-size: 14px;
  padding-inline-start: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-box input::placeholder {
  color: var(--field-placeholder);
}

.search-box input:focus {
  outline: none;
  border-color: var(--field-focus-border);
  box-shadow: 0 0 0 3px var(--field-focus-ring);
}

.search-box .search-icon {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--field-icon);
  pointer-events: none;
}

/* ==============================
   AVATAR
   ============================== */

.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--gray-200);
  flex-shrink: 0;
}

.avatar-placeholder {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

/* ==============================
   TOAST
   ============================== */

#toast-container {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  min-width: 200px;
}

.toast.success { background: var(--green); }
.toast.error   { background: var(--primary); }
.toast.info    { background: var(--blue); }

@keyframes toastIn {
  from { transform: translateX(-20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ==============================
   LOADING
   ============================== */

.loading-spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--gray-400);
  flex-direction: column;
  gap: 16px;
}

/* ==============================
   EMPTY STATE
   ============================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state .empty-title { font-size: 16px; font-weight: 700; color: var(--gray-600); }
.empty-state .empty-sub { font-size: 13px; margin-top: 6px; }

/* ==============================
   ATTENDANCE TOGGLE
   ============================== */

.attendance-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gray-300);
  background: white;
  font-size: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.attendance-btn.present {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.attendance-btn.absent {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* ==============================
   MOBILE MENU TOGGLE
   ============================== */

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--gray-700);
  font-size: 22px;
  cursor: pointer;
}

/* ==============================
   RESPONSIVE
   ============================== */

@media (max-width: 768px) {
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  html[dir="ltr"] .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-inline-start: 0;
  }

  .menu-toggle { display: block; }

  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page-content { padding: 16px; }

  .modal { margin: 12px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}
