@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800&display=swap');

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-success: #16a34a;
  --color-danger: #dc2626;
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-border: #e5e7eb;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  direction: rtl;
  font-family: 'Cairo', 'Tajawal', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  width: 100%;
}

.app-title {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
  color: var(--color-primary-dark);
}

.app-subtitle {
  text-align: center;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  font-size: 14px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 14px;
}

input[type="text"],
input[type="password"],
input[type="search"],
select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid var(--color-border);
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 16px;
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
}

button, .btn {
  display: block;
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: 10px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  margin-bottom: 12px;
  transition: transform 0.05s ease, opacity 0.15s ease;
}

button:active, .btn:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

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

.btn-secondary {
  background: #fff;
  color: var(--color-primary);
  border: 2px solid var(--color-primary);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-outline {
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.header-bar .who {
  font-weight: 700;
  font-size: 16px;
}

.header-bar .who small {
  display: block;
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 13px;
}

.session-card {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  text-align: center;
}

.session-card .label {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 6px;
}

.session-card .subject-name {
  font-size: 22px;
  font-weight: 800;
}

.session-card .meta {
  font-size: 13px;
  opacity: 0.9;
  margin-top: 6px;
}

.session-card.empty {
  background: #9ca3af;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 16px 20px;
  border-radius: 12px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  z-index: 1000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  animation: toast-in 0.2s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-danger); }
.toast-info { background: #374151; }

.error-text {
  color: var(--color-danger);
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 18px;
}

#qr-reader {
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.student-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  margin-bottom: 10px;
  background: var(--color-surface);
}

.student-row .info .name {
  font-weight: 700;
}

.student-row .info .code {
  font-size: 13px;
  color: var(--color-text-muted);
}

.student-row button {
  width: auto;
  margin: 0;
  padding: 10px 18px;
  font-size: 14px;
}

.muted-center {
  text-align: center;
  color: var(--color-text-muted);
  padding: 20px 0;
}

.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: 0 auto;
}

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