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

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

:root {
  --bg-main: #111111;
  --bg-card: #1c1c1c;
  --bg-card2: #242424;
  --green: #1e6b1e;
  --green-light: #27922a;
  --gold: #c8a227;
  --gold-light: #e0b830;
  --text: #f0f0f0;
  --text-muted: #999;
  --border: #333;
  --radius: 10px;
  /* Portal colors */
  --jockey: #6b7a2a;
  --trainer: #c8851a;
  --owner: #1a5e1a;
  --media: #1a5aad;
  --committee: #7b1a1a;
  --support: #6a6a6a;
  --finance: #1a6b4a;
}

html { direction: rtl; scroll-behavior: smooth; }

body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg-main);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.site-header {
  background: #0a0a0a;
  border-bottom: 2px solid var(--gold);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 75px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-brand img {
  width: 55px;
  height: 55px;
  border-radius: 50%;
  object-fit: cover;
}

.header-brand .brand-text h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1.2;
}

.header-brand .brand-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-logout {
  background: transparent;
  border: 1.5px solid #555;
  color: #bbb;
  padding: 7px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.btn-logout:hover { border-color: #e55; color: #f55; }

.user-badge {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
}

/* ── MAIN NAV ────────────────────────────────────────────────────────────── */
.main-nav {
  background: #0d0d0d;
  border-bottom: 1px solid #1e1e1e;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  flex-wrap: wrap;
  position: sticky;
  top: 75px;
  z-index: 99;
}
.main-nav a {
  color: #aaa;
  text-decoration: none;
  padding: 11px 22px;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: 'Cairo', sans-serif;
  border-bottom: 2px solid transparent;
  transition: all 0.18s;
  white-space: nowrap;
}
.main-nav a:hover { color: #fff; background: rgba(200,162,39,0.07); border-bottom-color: var(--gold); }

/* ── LIVE STREAM BUTTON ──────────────────────────────────────────────────── */
.live-nav-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 7px;
  background: rgba(183,28,28,0.18) !important;
  border: 1px solid #c62828 !important;
  border-bottom: 1px solid #c62828 !important;
  color: #ff5252 !important;
  padding: 7px 18px !important;
  border-radius: 20px !important;
  margin: 6px 12px !important;
  font-size: 0.88rem !important;
  font-weight: 700 !important;
  letter-spacing: 0.3px;
  transition: background 0.18s !important;
}
.live-nav-btn:hover { background: rgba(183,28,28,0.35) !important; border-bottom-color: #c62828 !important; }
.live-dot {
  width: 9px;
  height: 9px;
  background: #ff5252;
  border-radius: 50%;
  flex-shrink: 0;
  animation: livePulse 1.4s ease-in-out infinite;
}
@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(1.4); }
}
.main-nav a.nav-active { color: var(--gold); background: rgba(200,162,39,0.1); border-bottom-color: var(--gold); }

/* ── HERO / LANDING ─────────────────────────────────────────────────────── */
.hero {
  min-height: 92vh;
  background: linear-gradient(135deg, #0a0a0a 0%, #111 40%, #0d1a0d 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 50%, rgba(30, 107, 30, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.hero-logo {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  margin-bottom: 2rem;
  box-shadow: 0 0 40px rgba(200, 162, 39, 0.3);
  object-fit: cover;
}

.hero h1 {
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 20px rgba(200,162,39,0.3);
}

.hero .subtitle {
  font-size: 1.2rem;
  color: #ccc;
  margin-bottom: 2rem;
  font-weight: 300;
}

.hero-divider {
  width: 80px;
  height: 2px;
  background: var(--gold);
  margin: 1.5rem auto;
  opacity: 0.6;
}

.hero p {
  max-width: 680px;
  font-size: 1.05rem;
  color: #bbb;
  line-height: 1.9;
  margin-bottom: 3rem;
}

.btn-primary {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 14px 48px;
  font-size: 1.15rem;
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s;
  display: inline-block;
}
.btn-primary:hover {
  background: var(--green-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(30,107,30,0.4);
}

/* ── ABOUT STRIP ────────────────────────────────────────────────────────── */
.about-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.about-item {
  background: var(--bg-card);
  padding: 2rem;
  text-align: center;
}

.about-item .icon { font-size: 2rem; margin-bottom: 0.75rem; }
.about-item h3 { color: var(--gold); font-size: 1.1rem; margin-bottom: 0.4rem; }
.about-item p { color: var(--text-muted); font-size: 0.9rem; }

/* ── LOGIN PAGE ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a0a0a 0%, #0d1a0d 100%);
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 16px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-card .login-logo {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: block;
  margin: 0 auto 1.5rem;
  border: 2px solid var(--gold);
}

.login-card h2 {
  text-align: center;
  color: var(--gold);
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

.login-card .login-sub {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.form-group { margin-bottom: 1.4rem; }

.form-group label {
  display: block;
  font-size: 0.9rem;
  color: #ccc;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  background: #111;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  transition: border-color 0.2s;
  outline: none;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--gold);
}

.form-group select option { background: #1c1c1c; }

.btn-login {
  width: 100%;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 13px;
  font-size: 1.1rem;
  font-family: 'Cairo', sans-serif;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.25s;
  margin-top: 0.5rem;
}
.btn-login:hover { background: var(--green-light); }

.login-note {
  text-align: center;
  margin-top: 1.5rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.6;
}

.alert {
  padding: 11px 16px;
  border-radius: 7px;
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
  display: none;
}
.alert-error { background: rgba(180,30,30,0.2); border: 1px solid #c33; color: #f88; }
.alert-success { background: rgba(30,107,30,0.2); border: 1px solid #2a6; color: #7f7; }

/* ── DASHBOARD ──────────────────────────────────────────────────────────── */
.dashboard-body { padding: 2.5rem 2rem; max-width: 1200px; margin: 0 auto; }

.welcome-section {
  background: linear-gradient(135deg, var(--bg-card) 0%, #1a2a1a 100%);
  border: 1px solid var(--border);
  border-right: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.welcome-section .welcome-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  flex-shrink: 0;
}

.welcome-text h2 {
  font-size: 1.6rem;
  color: var(--gold);
  margin-bottom: 0.3rem;
}

.welcome-text p {
  color: #bbb;
  font-size: 0.95rem;
  line-height: 1.8;
  max-width: 700px;
}

.membership-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 0.5rem;
}

.portals-section h3 {
  font-size: 1.2rem;
  color: var(--text-muted);
  margin-bottom: 1.2rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* ── PORTAL BUTTONS GRID ────────────────────────────────────────────────── */
.portals-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin-bottom: 2rem;
}

.portal-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 20px;
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.25s;
  text-align: center;
  min-height: 72px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  text-decoration: none;
}

.portal-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.4);
  filter: brightness(1.15);
}

.portal-btn:active { transform: translateY(-1px); }

.portal-jockey    { background: var(--jockey); }
.portal-trainer   { background: var(--trainer); }
.portal-owner     { background: var(--owner); }
.portal-media     { background: var(--media); }
.portal-committee { background: var(--committee); }
.portal-support   { background: var(--support); }

/* ── PORTAL PAGE ────────────────────────────────────────────────────────── */
.portal-page { padding: 2rem; max-width: 1200px; margin: 0 auto; }

.portal-header {
  padding: 2rem 2.5rem;
  border-radius: var(--radius);
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

.portal-header h1 { font-size: 2rem; font-weight: 900; }
.portal-header p { opacity: 0.85; margin-top: 0.3rem; }

.btn-back {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 9px 22px;
  border-radius: 7px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
}
.btn-back:hover { background: rgba(255,255,255,0.25); }

.portal-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.2rem;
  margin-bottom: 2rem;
}

.portal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.8rem;
  transition: border-color 0.2s;
}
.portal-card:hover { border-color: #555; }
.portal-card h3 { font-size: 1.05rem; margin-bottom: 0.5rem; }
.portal-card p { color: var(--text-muted); font-size: 0.88rem; line-height: 1.7; }

.placeholder-box {
  background: var(--bg-card2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
  margin-top: 1rem;
}
.placeholder-box .icon { font-size: 3rem; margin-bottom: 1rem; }
.placeholder-box p { font-size: 0.95rem; }

/* ── ADMIN PANEL ────────────────────────────────────────────────────────── */
.admin-body { padding: 2rem; max-width: 1300px; margin: 0 auto; }

.admin-title {
  font-size: 1.8rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  text-align: center;
}
.stat-card .stat-num { font-size: 2.2rem; font-weight: 900; color: var(--gold); }
.stat-card .stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.3rem; }

.admin-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-toolbar h2 { font-size: 1.1rem; }

.btn-add {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 7px;
  font-family: 'Cairo', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-add:hover { background: var(--green-light); }

.search-input {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 14px;
  color: var(--text);
  font-family: 'Cairo', sans-serif;
  font-size: 0.9rem;
  width: 260px;
  outline: none;
}
.search-input:focus { border-color: var(--gold); }

.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: #0a0a0a; }
thead th { padding: 13px 16px; color: var(--gold); font-weight: 700; text-align: right; white-space: nowrap; }
tbody tr { border-bottom: 1px solid #222; transition: background 0.15s; }
tbody tr:hover { background: #232323; }
tbody td { padding: 12px 16px; vertical-align: middle; }

.type-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
}
.badge-jockey    { background: var(--jockey); }
.badge-trainer   { background: var(--trainer); }
.badge-owner     { background: var(--owner); }
.badge-media     { background: var(--media); }
.badge-committee { background: var(--committee); }
.badge-support   { background: var(--support); }
.badge-finance   { background: var(--finance); }

.active-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-left: 6px;
}
.dot-active { background: #4caf50; }
.dot-inactive { background: #f44; }

.btn-edit, .btn-delete {
  border: none;
  padding: 6px 14px;
  border-radius: 5px;
  cursor: pointer;
  font-family: 'Cairo', sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  transition: opacity 0.2s;
  margin-right: 5px;
}
.btn-edit { background: #2a5e8a; color: #fff; }
.btn-delete { background: #7b1a1a; color: #fff; }
.btn-edit:hover, .btn-delete:hover { opacity: 0.8; }

/* ── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--gold);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 { color: var(--gold); font-size: 1.2rem; margin-bottom: 1.5rem; }

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

.btn-save {
  flex: 1;
  background: var(--green);
  color: #fff;
  border: none;
  padding: 11px;
  border-radius: 7px;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-save:hover { background: var(--green-light); }

.btn-cancel {
  flex: 1;
  background: transparent;
  color: #aaa;
  border: 1px solid #444;
  padding: 11px;
  border-radius: 7px;
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-cancel:hover { border-color: #888; color: #ddd; }

/* ── FOOTER ─────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portals-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .about-strip { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2rem; }
  .welcome-section { flex-direction: column; text-align: center; }
  .site-header { padding: 0 1rem; }
  .header-brand .brand-text h1 { font-size: 0.95rem; }

  .main-nav {
    overflow-x: auto; justify-content: flex-start;
    flex-wrap: nowrap; -webkit-overflow-scrolling: touch;
  }
  .main-nav::-webkit-scrollbar { height: 2px; }
  .main-nav a { padding: 10px 14px; font-size: 0.82rem; }

  .dashboard-body { padding: 1.5rem 1rem; }
  .admin-body { padding: 1rem; }
  .search-input { width: 100%; }
  .admin-toolbar { flex-direction: column; align-items: stretch; }

  .portal-header { flex-direction: column; gap: 1rem; padding: 1.5rem; }
  .portal-header h1 { font-size: 1.4rem; }
  .portal-page { padding: 1rem; }

  .modal { padding: 1.5rem 1rem; }
  .modal-actions { flex-direction: column; }

  .welcome-section { padding: 1.5rem; }
  .welcome-text h2 { font-size: 1.3rem; }
}

@media (max-width: 480px) {
  .portals-grid { grid-template-columns: 1fr 1fr; }
  .portal-btn { font-size: 0.92rem; padding: 16px 8px; min-height: 60px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }

  .hero h1 { font-size: 1.6rem; }
  .hero .subtitle { font-size: 1rem; }
  .hero-logo { width: 110px; height: 110px; }
  .hero p { font-size: 0.9rem; margin-bottom: 2rem; }
  .btn-primary { padding: 12px 32px; font-size: 1rem; }

  .header-brand .brand-text span { display: none; }
  .header-brand .brand-text h1 { font-size: 0.88rem; }

  .login-card { padding: 2rem 1.2rem; }

  .table-wrap { font-size: 0.82rem; }
  thead th { padding: 10px 8px; font-size: 0.78rem; }
  tbody td { padding: 9px 8px; }
}
