/* ==========================================================================
   Bahçeşehir Koleji Veli Yaka Kartı Yönetim Sistemi
   Modern, Duyarlı (Responsive) ve Yazıcı Uyumlu Stil Dosyası
   ========================================================================== */

:root {
  --primary: #835c9b;
  --primary-hover: #6e4685;
  --primary-dark: #523166;
  --primary-light: #f6f1fa;
  --accent-red: #d32f2f;
  --accent-red-hover: #b71c1c;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: #a87bc4;
  --success: #10b981;
  --warning: #f59e0b;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #ffffff;
  padding: 1.25rem 1rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #ffffff;
}

.brand-logo-badge {
  width: 42px;
  height: 42px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  padding: 4px;
}

.brand-logo-badge svg {
  width: 100%;
  height: 100%;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.brand-text p {
  font-size: 0.75rem;
  opacity: 0.9;
  margin: 0;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */
.app-container {
  max-width: 1150px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.card-box {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  padding: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 640px) {
  .card-box {
    padding: 1.25rem;
    border-radius: var(--radius-md);
  }
}

/* ==========================================================================
   Form Grid & Controls
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-label .required {
  color: var(--accent-red);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: var(--text-main);
  transition: all 0.2s ease;
  outline: none;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(131, 92, 155, 0.15);
}

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

/* ==========================================================================
   Photo Upload Box
   ========================================================================== */
.photo-upload-zone {
  border: 2px dashed var(--primary);
  background-color: var(--primary-light);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  position: relative;
}

.photo-upload-zone:hover {
  background-color: #efe6f5;
  border-color: var(--primary-hover);
}

.upload-icon {
  width: 48px;
  height: 48px;
  color: var(--primary);
}

.photo-preview-thumb {
  width: 90px;
  height: 120px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  line-height: 1.2;
}

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

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(131, 92, 155, 0.3);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-danger {
  background-color: var(--accent-red);
  color: #ffffff;
}

.btn-danger:hover {
  background-color: var(--accent-red-hover);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.825rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1.1rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   YAKA KARTI (BADGE COMPONENT)
   Milimetrik ölçeklenen yaka kartı bileşeni
   Orijinal Çözünürlük: 2379 x 1600 (Oran: ~1.487)
   ========================================================================== */
.badge-wrapper {
  container-type: inline-size;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.badge-card {
  position: relative;
  width: 100%;
  aspect-ratio: 2379 / 1600;
  background-image: url('../img/template.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  border-radius: 4.5cqw;
  overflow: hidden;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Dinamik Değerler (Kart Üzerindeki Metinler) */
.badge-field {
  position: absolute;
  left: 24.5%;
  font-size: 2.2cqw;
  font-weight: 700;
  color: #1e1e24;
  white-space: nowrap;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* Koordinatlar (Orijinal şablona göre) */
.badge-parent-name {
  top: 55.7%;
}

.badge-student-name {
  top: 68.2%;
}

.badge-student-class {
  top: 71.9%;
}

.badge-student-number {
  top: 75.5%;
}

/* Karttaki Fotoğraf Çerçevesi */
.badge-photo-box {
  position: absolute;
  left: 65.1%;
  top: 44.0%;
  width: 19.63%;
  height: 38.81%;
  border-radius: 0.8cqw;
  overflow: hidden;
  background-color: #f1f5f9;
  border: 1px solid #9b7db5;
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-photo-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge-photo-placeholder {
  color: #94a3b8;
  font-size: 1.6cqw;
  text-align: center;
  padding: 4px;
}

/* ==========================================================================
   Modals (Cropper & Edit)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
}

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

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: #f8fafc;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Cropper Container */
.cropper-container-box {
  width: 100%;
  height: 380px;
  background-color: #0f172a;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.cropper-tools {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Admin Dashboard & Tables
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #ffffff;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon.purple {
  background-color: var(--primary-light);
  color: var(--primary);
}

.stat-icon.green {
  background-color: #ecfdf5;
  color: var(--success);
}

.stat-icon.amber {
  background-color: #fffbeb;
  color: var(--warning);
}

.stat-info h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-info .stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

.filter-bar {
  background: #ffffff;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  min-width: 260px;
}

.search-input-wrap input {
  padding-left: 2.25rem;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: #ffffff;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.admin-table th {
  background-color: #f8fafc;
  padding: 0.875rem 1rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.admin-table td {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.admin-table tr:hover {
  background-color: #fcfaff;
}

.badge-status {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-status.yeni {
  background-color: #fef3c7;
  color: #92400e;
}

.badge-status.yazdirildi {
  background-color: #d1fae5;
  color: #065f46;
}

.table-photo-thumb {
  width: 44px;
  height: 58px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

/* Grid View Cards for Admin */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.admin-card-item {
  background: #ffffff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-card-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.admin-card-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  border-top: 1px solid var(--border-color);
  padding-top: 0.75rem;
}

/* ==========================================================================
   YAZICI VE ÇIKTI MOTORU (PRINT STYLES)
   A4 Baskı Standartları: Sayfa başına 6 veya 8 kart + Kesim Çizgileri
   ========================================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .site-header,
  .no-print,
  .btn,
  .filter-bar,
  .stats-grid,
  .modal-overlay {
    display: none !important;
  }

  @page {
    size: A4 portrait;
    margin: 8mm 6mm;
  }

  .print-page {
    width: 100%;
    page-break-after: always;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-gap: 6mm 6mm;
    padding: 0;
    margin: 0;
  }

  .print-page:last-child {
    page-break-after: auto;
  }

  /* Yazıcıdaki Her Bir Kartın Boyutu (Standard Yaka Kartı Kılıfı ~ 90x60mm) */
  .print-card-box {
    position: relative;
    border: 1px dashed #cccccc; /* Kesim Kılavuz Çizgisi */
    padding: 2px;
    background: transparent;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .badge-card {
    box-shadow: none !important;
    border-radius: 8px !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .badge-card img {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}
