/* إدارة الألعاب — التصميم (نسخة محسّنة)
   مبادئ: موبايل أولاً، أزرار كبيرة، عربي RTL */

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

[hidden] {
  display: none !important;
}

:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #0e7a5f;
  --accent-dark: #0b624c;
  --danger: #d64545;
  --warning: #e8a33d;
  --border: #e2e5ea;
  --green-soft: #e9f6ef;
  --green-border: #a9d8be;
  --red-soft: #fdeeee;
  --red-border: #e8abab;
}

html {
  font-size: 16px;
}

body {
  font-family: "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

/* رأس التطبيق */
.app-header {
  background: var(--accent);
  color: #ffffff;
  padding: 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header h1 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* حاوية المحتوى */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

/* أساس الأزرار — كبيرة وتصلح للمس */
button {
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  cursor: pointer;
  min-height: 48px;
  background: var(--accent);
  color: #ffffff;
}

button:active {
  transform: scale(0.98);
}

.btn-primary { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--border); }

/* تلميح الحالة الفارغة */
.empty-hint {
  text-align: center;
  color: var(--muted);
  margin-bottom: 16px;
}

/* شبكة الألعاب */
.rides-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.ride-card {
  background: var(--green-soft);
  border: 1px solid var(--green-border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ride-card.busy {
  background: var(--red-soft);
  border-color: var(--red-border);
}

/* بطاقة إضافة لعبة — مثل الكروت وتأتي أولًا */
.add-card {
  background: var(--card);
  border: 2px dashed var(--accent);
  padding: 0;
}

.add-card-btn {
  width: 100%;
  height: 100%;
  min-height: 96px;
  background: transparent;
  color: var(--accent);
  border: none;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 700;
}

.add-plus {
  font-size: 1.8rem;
  line-height: 1;
}

/* شارة الحالة */
.ride-status {
  align-self: flex-start;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.ride-status.free { background: var(--accent); color: #ffffff; }
.ride-status.busy { background: var(--danger); color: #ffffff; }

.ride-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.ride-child {
  font-weight: 700;
  font-size: 1rem;
}

.ride-details {
  font-size: 0.85rem;
  color: var(--muted);
}

/* منطقة بدء الجلسة في البطاقة المتاحة */
.ride-start {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ride-start:active {
  opacity: 0.7;
}

.ride-hint {
  font-size: 0.8rem;
  color: var(--muted);
}

/* الوقت المتبقي */
.ride-time {
  font-size: 1.3rem;
  font-weight: 700;
  direction: ltr;
  text-align: center;
  background: #ffffff;
  border-radius: 10px;
  padding: 6px;
}

.ride-time.ended {
  color: var(--danger);
}

/* أزرار البطاقات — خلفية ناعمة وأيقونات */
.ride-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.ride-actions button {
  flex: 1;
  min-height: 42px;
  font-size: 0.85rem;
  padding: 8px 10px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.btn-edit { background: #e4edf8; color: #2e63a8; }
.btn-delete { background: #fbe4e4; color: var(--danger); }
.btn-end { background: var(--danger); color: #ffffff; }
.btn-extend { background: #d9efe4; color: var(--accent); }

/* نافذة النموذج (مركزية) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 420px;
}

/* نافذة الجلسة (من الأسفل) */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.sheet {
  background: var(--card);
  border-radius: 18px 18px 0 0;
  padding: 20px 20px 28px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.sheet h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
}

.modal-card h2 {
  font-size: 1.15rem;
  margin-bottom: 16px;
}

.modal-card label,
.sheet label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 12px 0 6px;
}

.modal-card input,
.sheet input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 1rem;
  font-family: inherit;
  background: #ffffff;
}

.modal-card input:focus,
.sheet input:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.required { color: var(--danger); }
.optional { color: var(--muted); font-weight: 400; font-size: 0.8rem; }

.form-error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 10px;
}

/* أزرار المدة */
.duration-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.duration-btn {
  flex: 1;
  min-height: 52px;
  font-size: 1rem;
  font-weight: 700;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 12px;
}

.duration-btn.selected {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-actions button {
  flex: 1;
}

/* صف إبقاء الشاشة مفتوحة */
.wakelock-row {
  margin-bottom: 12px;
}

.wakelock-toggle {
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.9rem;
  font-weight: 600;
}

.wakelock-toggle.on {
  background: var(--green-soft);
  border-color: var(--accent);
  color: var(--accent-dark);
}

.switch {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: var(--border);
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch .knob {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff;
  transition: right 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.wakelock-toggle.on .switch {
  background: var(--accent);
}

.wakelock-toggle.on .switch .knob {
  right: 21px;
}

/* سجل اليوم */
.log-section {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 8px;
}

.btn-clear-log {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.85rem;
  background: #fbe4e4;
  color: var(--danger);
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-entry {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.log-main {
  font-size: 0.95rem;
  font-weight: 600;
}

.log-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* تنبيه سريع */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 36, 48, 0.92);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 0.95rem;
  z-index: 200;
  max-width: 90%;
  text-align: center;
}
