/* ================================================
   College Media Gallery – gallery.css (Frontend)
   ================================================ */

.cmg-gallery-wrap {
  --cmg-primary:  #1E4D8C;
  --cmg-dark:     #0F172A;
  --cmg-accent:   #C9A227;
  --cmg-bg:       #F8FAFC;
  --cmg-card:     #FFFFFF;
  --cmg-border:   #E2E8F0;
  --cmg-text:     #1E293B;
  --cmg-muted:    #64748B;
  --cmg-shadow:   0 4px 24px rgba(15,23,42,0.09);
  --cmg-radius:   14px;
  font-family: -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
  direction: rtl;
  background: var(--cmg-bg);
  color: var(--cmg-text);
  overflow-x: hidden;
}
.cmg-gallery-wrap *, .cmg-gallery-wrap *::before, .cmg-gallery-wrap *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}

/* ════ SEARCH BAR ════ */
.cmg-search-bar {
  padding: 20px;
  background: var(--cmg-card);
  border-bottom: 1px solid var(--cmg-border);
}
.cmg-search-box {
  display: flex; align-items: center; gap: 10px;
  max-width: 620px; margin: 0 auto;
  background: var(--cmg-bg); border: 2px solid var(--cmg-border);
  border-radius: 50px; padding: 10px 18px;
  transition: border 0.2s, box-shadow 0.2s;
}
.cmg-search-box:focus-within {
  border-color: var(--cmg-primary);
  box-shadow: 0 0 0 3px rgba(30,77,140,0.1);
}
.cmg-search-ico { width: 18px; height: 18px; color: var(--cmg-muted); flex-shrink: 0; }
.cmg-search-box input {
  flex: 1; border: none; background: transparent;
  font-family: inherit; font-size: 14px; outline: none;
  direction: rtl; color: var(--cmg-text);
}
.cmg-search-btn {
  background: var(--cmg-primary); color: #fff; border: none;
  border-radius: 50px; padding: 8px 20px; font-family: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.2s;
  white-space: nowrap;
}
.cmg-search-btn:hover { background: #163d70; }
.cmg-search-tags {
  display: flex; gap: 8px; justify-content: center;
  flex-wrap: wrap; margin-top: 12px;
}
.cmg-search-tags span {
  background: var(--cmg-bg); border: 1px solid var(--cmg-border);
  color: var(--cmg-muted); font-size: 12px; padding: 4px 14px;
  border-radius: 50px; cursor: pointer; transition: all 0.2s;
}
.cmg-search-tags span:hover {
  background: var(--cmg-primary); color: #fff; border-color: var(--cmg-primary);
}

/* ════ FILTER TABS ════ */
.cmg-filter-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 16px 20px;
  background: var(--cmg-card); border-bottom: 1px solid var(--cmg-border);
  scrollbar-width: none;
}
.cmg-filter-tabs::-webkit-scrollbar { display: none; }
.cmg-tab {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 9px 18px; border-radius: 50px; border: 1.5px solid var(--cmg-border);
  background: var(--cmg-card); color: var(--cmg-muted); font-family: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s;
  flex-shrink: 0;
}
.cmg-tab:hover { border-color: var(--cmg-primary); color: var(--cmg-primary); }
.cmg-tab.active {
  background: var(--cmg-primary); color: #fff; border-color: var(--cmg-primary);
  box-shadow: 0 4px 14px rgba(30,77,140,0.3);
}
.cmg-tab-count {
  background: rgba(255,255,255,0.25); color: inherit;
  font-size: 11px; padding: 1px 7px; border-radius: 20px;
}
.cmg-tab:not(.active) .cmg-tab-count {
  background: var(--cmg-bg); color: var(--cmg-muted);
}

/* ════ GRID ════ */
.cmg-grid {
  display: grid; gap: 20px; padding: 24px 20px;
  max-width: 1200px; margin: 0 auto;
}
.cmg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.cmg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.cmg-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ════ ITEM CARD ════ */
.cmg-item {
  background: var(--cmg-card); border-radius: var(--cmg-radius);
  overflow: hidden; border: 1px solid var(--cmg-border);
  box-shadow: var(--cmg-shadow); transition: transform 0.3s, box-shadow 0.3s;
  position: relative;
  animation: cmgFadeIn 0.4s ease both;
}
@keyframes cmgFadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cmg-item:hover { transform: translateY(-5px); box-shadow: 0 12px 36px rgba(15,23,42,0.14); }
.cmg-item.cmg-featured { border-color: var(--cmg-accent); border-width: 2px; }
.cmg-featured-badge {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  background: var(--cmg-accent); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px;
}

/* Thumbnail */
.cmg-item-thumb {
  position: relative; overflow: hidden;
  aspect-ratio: 4/3; background: #E2E8F0;
}
.cmg-item-thumb img {
  width: 100%; height: 100%; object-fit: cover;
  display: block; transition: transform 0.4s ease;
}
.cmg-item:hover .cmg-item-thumb img { transform: scale(1.05); }
.cmg-no-img {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; background: #F0F6FF;
}
.cmg-no-img svg { width: 48px; height: 48px; color: #93C5FD; }

/* Overlay */
.cmg-item-overlay {
  position: absolute; inset: 0;
  background: rgba(15,23,42,0);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.3s;
}
.cmg-item:hover .cmg-item-overlay { background: rgba(15,23,42,0.45); }
.cmg-play-btn, .cmg-view-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255,255,255,0.9); color: var(--cmg-primary);
  border: none; border-radius: 50px; padding: 10px 20px;
  font-family: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  opacity: 0; transform: scale(0.9);
  transition: opacity 0.3s, transform 0.3s;
}
.cmg-play-btn { padding: 14px; border-radius: 50%; }
.cmg-play-btn svg, .cmg-view-btn svg { width: 18px; height: 18px; }
.cmg-item:hover .cmg-play-btn,
.cmg-item:hover .cmg-view-btn { opacity: 1; transform: scale(1); }
.cmg-img-count {
  background: var(--cmg-primary); color: #fff;
  font-size: 11px; padding: 2px 7px; border-radius: 20px;
}
.cmg-open-lb { position: relative; }

/* Category badge */
.cmg-item-cat {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(30,77,140,0.85); color: #fff;
  font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; backdrop-filter: blur(4px);
}

/* Body */
.cmg-item-body { padding: 14px 16px 10px; }
.cmg-item-title {
  font-size: 15px; font-weight: 800; color: var(--cmg-dark);
  margin-bottom: 4px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.cmg-item-desc {
  font-size: 13px; color: var(--cmg-muted); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; margin-bottom: 8px;
}
.cmg-item-date {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--cmg-muted);
}
.cmg-item-date svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ════ EMPTY ════ */
.cmg-empty-gallery {
  text-align: center; padding: 60px 20px;
  max-width: 400px; margin: 0 auto;
}
.cmg-empty-gallery svg { width: 56px; height: 56px; color: #CBD5E1; margin: 0 auto 16px; display: block; }
.cmg-empty-gallery p   { font-size: 16px; color: var(--cmg-muted); }

/* ════ LOAD MORE ════ */
.cmg-loadmore-wrap { text-align: center; padding: 8px 20px 40px; }
.cmg-loadmore-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--cmg-card); border: 2px solid var(--cmg-border);
  color: var(--cmg-primary); border-radius: 50px;
  padding: 12px 36px; font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all 0.25s;
}
.cmg-loadmore-btn:hover  { background: var(--cmg-primary); color: #fff; border-color: var(--cmg-primary); }
.cmg-loadmore-btn:disabled { opacity: 0.6; pointer-events: none; }
.cmg-spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(30,77,140,0.2);
  border-top-color: var(--cmg-primary);
  animation: cmgSpin 0.7s linear infinite; display: inline-block;
}
.cmg-loadmore-btn:hover .cmg-spinner { border-color: rgba(255,255,255,0.3); border-top-color: #fff; }
@keyframes cmgSpin { to { transform: rotate(360deg); } }

/* ════ PAGINATION ════ */
.cmg-pagination-wrap { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; padding: 8px 0; }
.cmg-page-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid var(--cmg-border);
  background: var(--cmg-card); color: var(--cmg-muted); font-family: inherit;
  font-size: 13px; font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.cmg-page-btn.active,
.cmg-page-btn:hover { background: var(--cmg-primary); color: #fff; border-color: var(--cmg-primary); }

/* ════ LIGHTBOX ════ */
.cmg-lightbox {
  position: fixed; inset: 0; z-index: 999999;
  display: flex; align-items: center; justify-content: center;
}
.cmg-lb-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(6px);
}
.cmg-lb-content {
  position: relative; width: calc(100% - 32px); max-width: 1000px;
  max-height: 95vh; display: flex; flex-direction: column;
  align-items: center; animation: cmgLbIn 0.3s ease;
}
@keyframes cmgLbIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
/* Buttons */
.cmg-lb-close {
  position: fixed; top: 16px; right: 16px;
  width: 44px; height: 44px; background: rgba(255,255,255,0.12);
  border: none; border-radius: 50%; cursor: pointer;
  color: #fff; font-size: 24px; font-weight: 300; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; z-index: 10;
}
.cmg-lb-close:hover { background: rgba(220,38,38,0.6); }
.cmg-lb-prev, .cmg-lb-next {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; background: rgba(255,255,255,0.12);
  border: none; border-radius: 50%; cursor: pointer; color: #fff;
  font-size: 28px; display: flex; align-items: center; justify-content: center;
  transition: background 0.2s; z-index: 10; user-select: none;
}
.cmg-lb-prev { right: 16px; }
.cmg-lb-next { left:  16px; }
.cmg-lb-prev:hover, .cmg-lb-next:hover { background: rgba(255,255,255,0.25); }

/* Media */
.cmg-lb-media {
  max-width: 100%; max-height: 75vh;
  display: flex; align-items: center; justify-content: center;
}
.cmg-lb-media img {
  max-width: 100%; max-height: 72vh; border-radius: 10px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
  object-fit: contain; display: block;
}
.cmg-lb-media iframe {
  width: min(800px, 92vw); height: min(450px, 52vw);
  border-radius: 10px; border: none; box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}
.cmg-lb-caption {
  margin-top: 12px; color: rgba(255,255,255,0.8);
  font-size: 14px; text-align: center; direction: rtl;
}
.cmg-lb-counter {
  color: rgba(255,255,255,0.5); font-size: 12px;
  margin-top: 4px; text-align: center;
}
/* Thumbnails strip */
.cmg-lb-thumbs {
  display: flex; gap: 8px; margin-top: 14px;
  overflow-x: auto; max-width: 100%; padding-bottom: 6px;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.cmg-lb-thumb-item {
  width: 56px; height: 56px; border-radius: 7px; overflow: hidden;
  cursor: pointer; flex-shrink: 0; opacity: 0.5;
  border: 2px solid transparent; transition: all 0.2s;
}
.cmg-lb-thumb-item:hover   { opacity: 0.8; }
.cmg-lb-thumb-item.active  { opacity: 1; border-color: #fff; }
.cmg-lb-thumb-item img     { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ════ RESPONSIVE ════ */
@media (max-width: 900px) {
  .cmg-cols-4 { grid-template-columns: repeat(3,1fr); }
}
@media (max-width: 680px) {
  .cmg-cols-3, .cmg-cols-4 { grid-template-columns: repeat(2,1fr); }
  .cmg-lb-prev, .cmg-lb-next { width: 38px; height: 38px; font-size: 22px; }
}
@media (max-width: 400px) {
  .cmg-cols-2, .cmg-cols-3, .cmg-cols-4 { grid-template-columns: 1fr; }
}

/* Fix: keep lightbox hidden until user opens an image */
.cmg-lightbox[hidden] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Details button and activity details panel */
.cmg-details-btn {
  margin-top: 12px;
  width: 100%;
  border: 1px solid rgba(30,77,140,0.18);
  background: linear-gradient(135deg, #EEF5FF, #FFFFFF);
  color: var(--cmg-primary);
  border-radius: 10px;
  padding: 9px 12px;
  font-family: inherit;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: all .25s ease;
}
.cmg-details-btn:hover {
  background: var(--cmg-primary);
  color: #fff;
  border-color: var(--cmg-primary);
  transform: translateY(-1px);
}
.cmg-details-panel {
  width: min(920px, 94vw);
  max-height: 82vh;
  overflow: auto;
  background: #fff;
  color: var(--cmg-text);
  border-radius: 18px;
  box-shadow: 0 25px 80px rgba(0,0,0,.35);
  direction: rtl;
}
.cmg-details-img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}
.cmg-details-video {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #0f172a;
}
.cmg-details-video iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}
.cmg-details-content {
  padding: 28px 30px 32px;
}
.cmg-details-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(201,162,39,.14);
  color: #8a6a0a;
  border: 1px solid rgba(201,162,39,.35);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 12px;
}
.cmg-details-content h2 {
  margin: 0 0 10px;
  color: var(--cmg-primary);
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.45;
  font-weight: 900;
}
.cmg-details-date {
  color: var(--cmg-muted);
  font-size: 14px;
  margin-bottom: 18px;
}
.cmg-details-content p {
  color: #334155;
  font-size: 16px;
  line-height: 2;
  margin: 0;
  text-align: justify;
}
.cmg-details-muted { color: var(--cmg-muted) !important; }
@media (max-width: 700px) {
  .cmg-details-panel { width: 94vw; max-height: 84vh; border-radius: 14px; }
  .cmg-details-content { padding: 20px 18px 24px; }
  .cmg-details-content p { font-size: 15px; text-align: right; }
}

/* Video fallback message inside details */
.cmg-video-fallback {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: #eff6ff;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 12px;
  color: #1e3a8a;
  font-size: 14px;
  line-height: 1.8;
  text-align: center;
}
.cmg-video-fallback a {
  color: #b8860b !important;
  font-weight: 800;
  text-decoration: underline;
}
.cmg-details-panel {
  overflow: auto;
}

/* Details gallery inside activity details */
.cmg-details-gallery{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(90px,1fr));
  gap:10px;
  margin:14px 0 4px;
}
.cmg-details-gallery a{
  display:block;
  border-radius:12px;
  overflow:hidden;
  border:1px solid var(--cmg-border);
  background:#fff;
}
.cmg-details-gallery img{
  width:100%;
  height:84px;
  object-fit:cover;
  display:block;
  transition:transform .25s ease;
}
.cmg-details-gallery a:hover img{ transform:scale(1.06); }

/* Details photo browser: browse all images inside activity details */
.cmg-details-photo-browser{
  width:100%;
  margin:0 0 18px;
}
.cmg-details-main-photo-wrap{
  position:relative;
  width:100%;
  border-radius:18px;
  overflow:hidden;
  background:#f1f5f9;
  border:1px solid var(--cmg-border);
}
.cmg-details-main-photo{
  width:100%;
  max-height:520px;
  object-fit:contain;
  display:block;
  background:#f8fafc;
}
.cmg-details-photo-nav{
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  width:42px;
  height:42px;
  border:0;
  border-radius:50%;
  background:rgba(30,77,140,.92);
  color:#fff;
  font-size:30px;
  line-height:1;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:4;
  transition:.25s ease;
  box-shadow:0 10px 24px rgba(15,23,42,.18);
}
.cmg-details-photo-nav:hover{
  background:#d4af37;
  transform:translateY(-50%) scale(1.06);
}
.cmg-details-photo-prev{ right:14px; }
.cmg-details-photo-next{ left:14px; }
.cmg-details-photo-count{
  position:absolute;
  right:16px;
  bottom:14px;
  padding:6px 12px;
  border-radius:999px;
  background:rgba(15,23,42,.72);
  color:#fff;
  font-size:13px;
  font-weight:800;
}
.cmg-details-gallery{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(74px,1fr));
  gap:10px;
  margin:12px 0 4px;
}
.cmg-details-thumb{
  padding:0;
  border:2px solid transparent;
  border-radius:12px;
  overflow:hidden;
  background:#fff;
  cursor:pointer;
  height:78px;
  box-shadow:0 5px 14px rgba(15,23,42,.08);
  transition:.25s ease;
}
.cmg-details-thumb img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.cmg-details-thumb:hover,
.cmg-details-thumb.active{
  border-color:#d4af37;
  transform:translateY(-2px);
}
@media(max-width:768px){
  .cmg-details-main-photo{max-height:340px;}
  .cmg-details-photo-nav{width:36px;height:36px;font-size:24px;}
  .cmg-details-gallery{grid-template-columns:repeat(auto-fill,minmax(58px,1fr));}
  .cmg-details-thumb{height:62px;}
}
/* Forced live-server filter visibility safeguard */
.cmg-item[hidden]{display:none!important;}
