/* =====================================================
   Photier / PhotoMatch — Modernized UI Styles (v2.3 Branding-aware)
   - Branding değişkenleriyle otomatik uyum
   - 4 sütun galeri grid (responsive)
   - Admin Event formları + UI iyileştirmeleri
   ===================================================== */

:root{
  /* BRANDING ile eşleşen haritalamalar (yoksa eski default’lar) */
  --bg: var(--brand-bg, #f6f8fb);
  --surface: #ffffff;
  --text: var(--brand-text, #1f2d3d);
  --muted: #6b7a90;

  --primary: var(--brand-primary, #0d6efd);
  /* Türetilmiş tonlar markaya göre hesaplanır */
  --primary-600: color-mix(in oklab, var(--primary) 85%, black);
  --primary-700: color-mix(in oklab, var(--primary) 75%, black);

  --success: #25a562;
  --warning: #f59e0b;
  --danger: #dc3545;
  --info: #0dcaf0;
  --ring: color-mix(in oklab, var(--primary) 45%, transparent);

  --radius: var(--brand-radius, 12px);
  --shadow-1: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-2: 0 8px 24px rgba(0,0,0,.10);
  --border: #e5e7eb;

  /* Galeri (branding’den gelebilir) */
  --gallery-cols: var(--brand-gallery-cols, 4);
  --gallery-gap: var(--brand-gallery-gap, 1rem);
}

@media (prefers-color-scheme: dark){
  :root{
    --bg: #0f1520;
    --surface: #121a26;
    --text: #e6edf3;
    --muted: #9fb0c0;
    /* Dark’ta da marka rengi korunur */
    --primary: var(--brand-primary, #4ea8ff);
    --primary-600: color-mix(in oklab, var(--primary) 85%, black);
    --primary-700: color-mix(in oklab, var(--primary) 75%, black);
    --ring: color-mix(in oklab, var(--primary) 45%, transparent);
    --shadow-1: 0 1px 3px rgba(0,0,0,.55), 0 1px 2px rgba(0,0,0,.45);
    --shadow-2: 0 8px 24px rgba(0,0,0,.55);
    --border: #253142;
  }
}

@media (prefers-reduced-motion: reduce){
  * { animation: none !important; transition: none !important; }
}

*{ box-sizing: border-box; }
html, body { height: 100%; }
html{ scroll-behavior: smooth; }
body {
  font-family: Inter, Roboto, "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.container { max-width: 1080px; }

h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: .1px; margin: 0 0 .6rem; }
small, .text-muted { color: var(--muted) !important; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-600); text-decoration: underline; }

.navbar { box-shadow: var(--shadow-1); backdrop-filter: saturate(180%) blur(6px); }
.navbar-light.bg-light { background: color-mix(in oklab, var(--surface) 85%, white) !important; }
.navbar .nav-link { border-radius: 8px; }
.navbar .nav-link:hover { background: rgba(0,0,0,.04); }

.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card:hover{ box-shadow: var(--shadow-2); transition: box-shadow .25s ease; }
.card-header{ border-bottom: 1px solid var(--border); font-weight: 600; }
.card-footer{ border-top: 1px solid var(--border); background: color-mix(in oklab, var(--surface) 92%, white); }

.btn{
  border-radius: calc(var(--radius) - 4px) !important;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  transition: transform .06s ease, box-shadow .2s ease, filter .2s ease, background .2s ease;
}
.btn:active{ transform: translateY(1px); }
.btn-primary{ background: var(--primary); border-color: var(--primary); }
.btn-primary:hover{ background: var(--primary-600); border-color: var(--primary-600); }
.btn-primary:focus{ box-shadow: 0 0 0 3px var(--ring); }
.btn-outline-secondary{ border-color: color-mix(in oklab, var(--text) 20%, white); color: var(--text); }
.btn-outline-secondary:hover{ background: rgba(0,0,0,.04); }
.btn-icon{ width: 28px; height: 28px; padding: 0; display: grid; place-items: center; }

/* Marka butonu (user & admin tarafında kullanılıyor) */
.btn-brand{
  background: var(--brand-btn, var(--primary));
  border-color: var(--brand-btn, var(--primary));
  color: #fff;
  border-radius: var(--radius);
}
.btn-brand:hover{
  background: var(--brand-btn-hover, var(--primary-600));
  border-color: var(--brand-btn-hover, var(--primary-600));
  color: #fff;
}

.row.g-3.mb-5 { display: flex !important; flex-wrap: wrap; gap: 1rem; }
.row.g-3.mb-5 .col { flex: 1 1 180px; display: flex; }
.row.g-3.mb-5 .col .card { flex: 1; display: flex; align-items: center; justify-content: center; text-align: center; padding: 18px; }
.row.g-3.mb-5 .card i { margin-bottom: 6px; font-size: 1.8rem; opacity: .9; }

ul#event-list{ list-style: none; padding-left: 0; margin-top: 16px; }
ul#event-list li{
  background: var(--surface);
  margin-bottom: 10px; padding: 12px 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  display: flex; align-items: center; justify-content: space-between;
}
ul#event-list li .event-info{ display: flex; align-items: center; gap: 12px; }
ul#event-list li img.cover-thumb{ width: 48px; height: 48px; object-fit: cover; border-radius: 8px; }

#gallery-wrapper{
  max-height: 60vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-left:  calc(var(--bs-gutter-x, 1.5rem)/2);
  padding-right: calc(var(--bs-gutter-x, 1.5rem)/2);
}

#gallery-grid{
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}
#gallery-grid > *{ min-width: 0; width: 100%; }
#gallery-grid .card{ height: 100%; }

#gallery-wrapper .card{ position: relative; overflow: hidden; box-shadow: var(--shadow-1); }
#gallery-wrapper .card-img-top{ width: 100%; height: auto; aspect-ratio: 4/3; object-fit: cover; }

#gallery-wrapper .delete-btn,
#gallery-grid .btn-danger{
  position: absolute; top: .5rem; right: .5rem; z-index: 10;
  border: none; border-radius: 8px; padding: 6px 8px;
  background: color-mix(in oklab, var(--danger) 88%, black 0%);
  color: #fff; box-shadow: var(--shadow-1);
}
#gallery-wrapper .delete-btn:hover{ filter: brightness(.95); }

#gallery-drop-zone{
  min-height: 110px; cursor: pointer;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  border: 2px dashed color-mix(in oklab, var(--muted) 40%, transparent);
  transition: border-color .2s ease, background .2s ease;
}
#gallery-drop-zone.bg-light{ background: color-mix(in oklab, var(--surface) 92%, white); border-color: var(--primary); }

#preview-zone{ display: flex; flex-wrap: wrap; gap: 8px; }
#preview-zone > div{
  position: relative; width: 90px; height: 90px; margin: 4px;
  border-radius: 10px; overflow: hidden; box-shadow: var(--shadow-1);
}
#preview-zone img{ width: 100%; height: 100%; object-fit: cover; display: block; }
#preview-zone button{
  position: absolute; top: 2px; right: 2px;
  border: none; background: var(--danger); color:#fff; border-radius: 6px;
  width: 22px; height: 22px; line-height: 1;
}

.match-wrapper{ gap: 1rem; padding-bottom: .5rem; }
#match-grid{ display: grid; grid-auto-flow: column; grid-auto-columns: 200px; gap: 1rem; }
#match-grid .card{ width: 200px; box-shadow: var(--shadow-1); }
#match-grid .card-img-top{ height: 150px; object-fit: cover !important; }
#match-grid .card-body{ padding: 8px !important; text-align: center; }
@media (max-width: 768px){ #match-grid{ grid-auto-flow: row; grid-template-columns: repeat( auto-fill, minmax(140px,1fr) ); } }

#event-settings-form{
  background: var(--surface);
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.setting-row{
  display: grid;
  grid-template-columns: 40px 220px 1fr;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.setting-row label{ font-weight: 600; }
.setting-row input[type="text"],
.setting-row input[type="datetime-local"],
.setting-row input[type="file"],
.setting-row select,
.setting-row input[type="number"]{ max-width: 320px; width: 100%; }
#event-settings-form button[type="submit"]{ margin-top: 10px; }
@media (max-width: 768px){ .setting-row{ grid-template-columns: 28px 1fr; } .setting-row > *:nth-child(3){ grid-column: 1 / -1; } }
.setting-row > *:nth-child(3){ display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.setting-row input[type="checkbox"]{
  appearance: none; -webkit-appearance: none;
  width: 42px; height: 24px; border-radius: 999px;
  background: #cfd6e0; position: relative; cursor: pointer;
  outline: none; border: 1px solid var(--border);
  transition: background .25s ease, box-shadow .25s ease;
}
.setting-row input[type="checkbox"]:focus{ box-shadow: 0 0 0 3px var(--ring); }
.setting-row input[type="checkbox"]::after{
  content:""; position:absolute; top:2px; left:2px;
  width: 20px; height: 20px; border-radius: 999px; background:#fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  transition: transform .25s ease;
}
.setting-row input[type="checkbox"]:checked{ background: var(--primary); border-color: var(--primary-600); }
.setting-row input[type="checkbox"]:checked::after{ transform: translateX(18px); }
#watermark-preview, #frame-preview{
  width: 64px !important; height: 64px !important; object-fit: contain !important;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  box-shadow: var(--shadow-1);
}
#watermark-extra-settings, #frame-extra-settings{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
#event-settings-form .btn-primary{ padding: 10px 16px; font-weight: 600; }
#event-settings-form .btn-primary:active{ transform: translateY(1px); }

input[type="text"], input[type="file"], input[type="number"], select{
  padding: 10px; border: 1px solid rgba(0,0,0,.12); border-radius: 10px;
  background: var(--surface); color: var(--text);
}
input:focus, select:focus{ outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.fade-in{ animation: fade .28s ease-out both; }
@keyframes fade{ from{ opacity: 0; transform: translateY(4px); } to{ opacity: 1; transform: none; } }

*::-webkit-scrollbar{ height: 10px; width: 10px; }
*::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.18); border-radius: 10px; }
*::-webkit-scrollbar-track{ background: transparent; }

.ring{ box-shadow: 0 0 0 3px var(--ring); }
.surface{ background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.soft-shadow{ box-shadow: var(--shadow-1); }

#cover-preview{ max-height: 220px; width: auto; border-radius: 12px; box-shadow: var(--shadow-1); }
.qr-actions img{ border-radius: 10px; box-shadow: var(--shadow-1); background: #fff; }
.table .btn{ margin-right: 4px; }
.toast{ background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-2); }

.lightbox{ position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: center; justify-content: center; z-index: 1050; }
.lightbox.show{ display: flex; }
.lightbox-img{ max-width: 92vw; max-height: 88vh; border-radius: 12px; box-shadow: var(--shadow-2); }
.lightbox-close{ position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 999px; display: grid; place-items: center; background: rgba(0,0,0,.6); color: #fff; border: none; cursor: pointer; }
.lightbox-close:hover{ background: rgba(0,0,0,.72); }

/* Opsiyonel: .gallery helper (branding grid değişkenleriyle) */
.gallery{
  display: grid;
  grid-template-columns: repeat(var(--gallery-cols), 1fr);
  gap: var(--gallery-gap);
}

/* Kamera modalini taşmayacak şekilde sınırla */
#cameraModal .modal-dialog { max-width: min(520px, 95vw); }
#cameraModal .modal-body { max-height: 75vh; overflow: hidden; }

/* Video & Canvas görüntüyü çerçevenin içinde tut */
#cameraVideo, #cameraCanvas {
  display: block;
  width: 100%;
  height: auto;            /* en-boy oranını koru */
  object-fit: contain;     /* çerçeveden taşma yok */
}

/* İsteğe bağlı: görüntüyü ortala */
.cam-frame {
  max-height: 70vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
