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

:root {
  --bg: #0f172a;
  --surface: #131e35;
  --surface-2: #182544;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #6366f1;
  --accent-hover: #7c7ff2;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(
      circle at 15% -10%,
      rgba(99, 102, 241, 0.12),
      transparent 40%
    ),
    radial-gradient(circle at 100% 0%, rgba(99, 102, 241, 0.08), transparent 35%);
  color: var(--text);
  font-family: "Cairo", sans-serif;
  direction: rtl;
  min-height: 100vh;
}

button,
input,
select,
textarea {
  font-family: inherit;
  color: inherit;
}

/* ---------- Login ---------- */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.auth-image{
  height: 180px;
  display: flex;
  justify-content: center;
  background-color: #182544;
  border-radius: 10px;
  
}

.auth-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
}

.auth-card p {
  color: var(--text-dim);
  font-size: 14px;
  margin: 0 0 24px;
}

.field {
  margin-bottom: 16px;
}

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

.field input,
.field select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 8px 22px var(--accent-glow);
}

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

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.2);
}

.btn-sm {
  text-decoration: none;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 16px;
}

/* ---------- App shell ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(19, 30, 53, 0.6);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
}

.topbar .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.topbar .captain-name {
  color: var(--text-dim);
  font-size: 14px;
}

.topbar nav {
  display: flex;
  gap: 6px;
}

.topbar nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.topbar nav a.active {
  color: #fff;
  background: var(--accent);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px;
}

/* ---------- App shell (sidebar layout) ---------- */
.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 18px;
  background: rgba(19, 30, 53, 0.6);
  backdrop-filter: blur(6px);
  border-inline-start: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  padding: 0 6px;
  margin-bottom: 26px;
}

.sidebar .brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
  flex-shrink: 0;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar nav a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.sidebar nav a.active {
  color: #fff;
  background: var(--accent);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-foot .captain-name {
  color: var(--text-dim);
  font-size: 13px;
  padding: 0 6px;
}

.app-shell > main {
  flex: 1;
  min-width: 0;
}

@media (max-width: 780px) {
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 14px 16px;
    overflow-x: auto;
  }
  .sidebar .brand {
    margin-bottom: 0;
    padding-inline-end: 14px;
    flex-shrink: 0;
  }
  .sidebar nav {
    flex-direction: row;
    flex: none;
  }
  .sidebar nav a {
    white-space: nowrap;
  }
  .sidebar-foot {
    flex-direction: row;
    align-items: center;
    border-top: none;
    margin-top: 0;
    padding-top: 0;
    padding-inline-start: 14px;
    margin-inline-start: auto;
    flex-shrink: 0;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 24px;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 17px;
}

.panel .sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 16px;
}

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

.lookup-row .field {
  margin: 0;
  flex: 1;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

/* ---------- Course cards ---------- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.course-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  gap: 14px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.course-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
  transform: translateY(-2px);
}

.course-ring {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  position: relative;
}

.course-ring svg {
  transform: rotate(-90deg);
}

.course-ring .track {
  stroke: rgba(255, 255, 255, 0.08);
  fill: none;
  stroke-width: 5;
}

.course-ring .progress {
  stroke: var(--accent);
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s ease;
}

.course-ring .pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-dim);
}

.course-info {
  flex: 1;
  min-width: 0;
}

.course-info h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.course-info .meta {
  color: var(--text-dim);
  font-size: 12.5px;
  margin: 0 0 12px;
}

.course-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
}

.empty-state .icon {
  font-size: 32px;
  margin-bottom: 10px;
}

/* ---------- Modal ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 20, 0.65);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.modal.modal-lg {
  max-width: 780px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-head h3 {
  margin: 0;
  font-size: 16px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
}

.modal-foot {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Day/slot/exercise builder ---------- */
.day-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 14px;
  background: var(--surface-2);
}

.day-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.day-block-head .tag {
  background: var(--accent-glow);
  color: #c7d2fe;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

.slot-block {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.slot-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.exercise-row {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 1fr 34px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.exercise-row input,
.exercise-row select {
  padding: 9px 10px;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}

.exercise-row select:focus,
.exercise-row input:focus {
  border-color: var(--accent);
}

.exercise-pick-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  text-align: right;
  color: inherit;
}

.exercise-pick-btn:hover,
.exercise-pick-btn:focus {
  border-color: var(--accent);
}

.expick-thumb {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  flex-shrink: 0;
  background: #0c1526 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.expick-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.exercise-card.picker-card {
  cursor: pointer;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
}

.add-link {
  background: none;
  border: none;
  color: var(--accent-hover);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  font-weight: 600;
}

.add-link:hover {
  text-decoration: underline;
}

/* ---------- Course detail view ---------- */
.detail-day {
  margin-bottom: 18px;
}

.detail-day h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--accent-hover);
}

.detail-slot {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.detail-slot .slot-title {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.detail-exercise {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.detail-exercise:last-child {
  border-bottom: none;
}

.detail-exercise-thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  flex-shrink: 0;
  background: #0c1526 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.detail-exercise-main {
  flex: 1;
  min-width: 0;
}

.detail-exercise-reps {
  flex-shrink: 0;
  text-align: left;
}

.detail-exercise .ex-name {
  font-weight: 600;
}

.detail-exercise .ex-meta {
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------- Players list ---------- */
.player-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: border-color 0.15s ease;
}

.player-row:hover {
  border-color: rgba(99, 102, 241, 0.35);
}

.player-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent), #4338ca);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.player-info {
  flex: 1;
  min-width: 0;
}

.player-info .p-name {
  font-weight: 600;
  font-size: 14.5px;
}

.player-info .p-meta {
  color: var(--text-dim);
  font-size: 12.5px;
  margin-top: 2px;
}

.badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.badge-active {
  background: rgba(34, 197, 94, 0.14);
  color: var(--success);
}

.badge-inactive {
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-dim);
}

/* ---------- Exercises ---------- */
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.chip {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  color: var(--text);
}

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.exercise-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.exercise-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  transform: translateY(-2px);
}

.exercise-thumb {
  width: 100%;
  height: 180px;
  background: #0c1526 center/cover no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 26px;
}

.exercise-body {
  padding: 12px 14px;
}

.exercise-body .ex-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.exercise-body .ex-cat {
  color: var(--accent-hover);
  font-size: 12px;
  margin-bottom: 10px;
}

.exercise-body .exercise-actions {
  display: flex;
  gap: 8px;
}

.file-field {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--surface-2);
  font-size: 13.5px;
  color: var(--text-dim);
}

.file-field input[type="file"] {
  width: 100%;
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Toast ---------- */
#toast-host {
  position: fixed;
  bottom: 24px;
  left: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.2s ease;
  max-width: 320px;
}

.toast.success {
  border-color: rgba(34, 197, 94, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

@media (max-width: 560px) {
  .row-2 {
    grid-template-columns: 1fr;
  }
  .exercise-row {
    grid-template-columns: 1fr;
  }
}
