:root {
  --primary: #0d7d6e;
  --primary-dark: #095c50;
  --primary-light: #e6f4f1;
  --call: #16a34a;
  --call-dark: #0f7a37;
  --whatsapp: #25d366;
  --whatsapp-dark: #1da851;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f2f5f4;
  --card: #ffffff;
  --text: #1c2521;
  --muted: #6b7a75;
  --border: #e3e8e6;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 4px 16px rgba(20, 40, 35, 0.08);
  --shadow-lg: 0 10px 30px rgba(20, 40, 35, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input {
  font-family: inherit;
}

[hidden] {
  display: none !important;
}

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Login ---------- */

.login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 55%, #073d34 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 24px;
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  margin: 0 auto 16px;
}

.login-card h1 {
  font-size: 20px;
  margin: 0 0 6px;
  font-weight: 700;
}

.login-card p.subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.field-label {
  display: block;
  text-align: right;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}

.big-input {
  width: 100%;
  padding: 16px;
  font-size: 20px;
  letter-spacing: 1px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
  background: #fafcfb;
  transition: border-color 0.15s;
}

.big-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
}

.primary-btn {
  width: 100%;
  margin-top: 18px;
  padding: 16px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: var(--radius-md);
  transition: background 0.15s, transform 0.1s;
}

.primary-btn:active {
  transform: scale(0.98);
}

.primary-btn:disabled {
  opacity: 0.6;
}

.primary-btn.loading::after {
  content: '...';
}

.alert {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  text-align: right;
  line-height: 1.6;
}

.alert.error {
  background: var(--danger-light);
  color: #991b1b;
}

.alert.warn {
  background: #fff7ed;
  color: #9a5b13;
}

.admin-link {
  display: inline-block;
  margin-top: 22px;
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
}

/* ---------- Duty header ---------- */

.duty-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.duty-header .who {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.duty-header .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.duty-header .name-block {
  min-width: 0;
}

.duty-header .teacher-name {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 42vw;
}

.badge-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  background: rgba(255, 255, 255, 0.2);
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 2px;
}

.badge-active .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
}

.logout-btn {
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- Search ---------- */

.search-wrap {
  padding: 16px;
  background: var(--primary);
  padding-top: 0;
}

.search-box {
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 16px 48px 16px 16px;
  font-size: 18px;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.search-box input:focus {
  outline: 3px solid rgba(255, 255, 255, 0.5);
}

.search-box .icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 20px;
  pointer-events: none;
}

.results-area {
  flex: 1;
  padding: 12px 16px 32px;
}

.hint {
  text-align: center;
  color: var(--muted);
  padding: 48px 20px;
  font-size: 15px;
  line-height: 1.8;
}

.hint .big-icon {
  font-size: 44px;
  display: block;
  margin-bottom: 12px;
}

.result-count {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 4px 12px;
}

/* ---------- Student card ---------- */

.student-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.student-card .name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.tag.id-tag {
  background: #eef1f0;
  color: var(--muted);
  direction: ltr;
  display: inline-block;
}

.phone-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: var(--muted);
  margin-bottom: 14px;
  direction: ltr;
  justify-content: flex-end;
}

.actions-row {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 8px;
  border-radius: var(--radius-md);
  border: none;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.1s, filter 0.15s;
}

.action-btn:active {
  transform: scale(0.96);
  filter: brightness(0.95);
}

.action-btn.call {
  background: var(--call);
}

.action-btn.whatsapp {
  background: var(--whatsapp);
}

.action-btn .emoji {
  font-size: 18px;
}

/* ---------- Utility ---------- */

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 24px auto;
}

.spinner.dark {
  border: 3px solid var(--border);
  border-top-color: var(--primary);
}

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

@media (min-width: 640px) {
  .results-area {
    max-width: 560px;
    margin: 0 auto;
    width: 100%;
  }
  .search-wrap > .search-box {
    max-width: 560px;
    margin: 0 auto;
  }
}
