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

:root {
  --blue: #2563EB;
  --blue-dark: #1D4ED8;
  --green: #16A34A;
  --green-dark: #15803D;
  --red: #DC2626;
  --yellow: #D97706;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-800: #1F2937;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* --- Login --- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 0.25rem;
}

.login-card p {
  font-size: 0.875rem;
  color: var(--gray-600);
  margin-bottom: 1.75rem;
}

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.form-group input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 1rem;
  transition: border-color .15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary { background: var(--blue); color: #fff; width: 100%; margin-top: 0.5rem; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }

.btn-success { background: var(--green); color: #fff; width: 100%; padding: 0.875rem; font-size: 1.0625rem; }
.btn-success:hover:not(:disabled) { background: var(--green-dark); }

.btn-pick { background: #D97706; color: #fff; width: 100%; padding: 0.5rem; font-size: 0.8125rem; font-weight: 700; }
.btn-pick:hover:not(:disabled) { background: #B45309; }

.btn-send { background: var(--blue); color: #fff; width: 100%; padding: 0.5rem; font-size: 0.8125rem; font-weight: 700; }
.btn-send:hover:not(:disabled) { background: var(--blue-dark); }

.error-msg {
  color: var(--red);
  font-size: 0.875rem;
  margin-top: 0.75rem;
  min-height: 1.25rem;
}

/* --- Navbar --- */
.navbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--blue);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.btn-logout {
  background: none;
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  padding: 0.375rem 0.875rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background .15s;
}

.btn-logout:hover { background: var(--gray-100); }

/* --- Main container --- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* --- Stats bar --- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--gray-600);
  margin-top: 0.375rem;
}

.stat-total .stat-value { color: var(--gray-800); }
.stat-bekliyor .stat-value { color: var(--yellow); }
.stat-uretimde .stat-value { color: var(--blue); }
.stat-iptal .stat-value { color: var(--red); }

/* --- Filter bar --- */
.filter-bar {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}

.filter-bar input[type="text"],
.search-input {
  padding: 0.5rem 0.875rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.875rem;
  width: 100%;
  max-width: 320px;
}

.filter-bar input[type="text"]:focus,
.search-input:focus {
  outline: none;
  border-color: var(--blue);
}

.filter-buttons { display: flex; gap: 0.5rem; }

.filter-btn {
  padding: 0.4375rem 1rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  color: var(--gray-600);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.filter-btn.active,
.filter-btn:hover { background: var(--blue); border-color: var(--blue); color: #fff; }

/* --- Table --- */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

thead th {
  text-align: left;
  padding: 0.875rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

td {
  padding: 0.875rem 1rem;
  vertical-align: middle;
}

.thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--gray-200);
}

.thumb-placeholder {
  width: 48px;
  height: 48px;
  background: var(--gray-200);
  border-radius: 6px;
  display: inline-block;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.badge-bekliyor       { background: #FEF3C7; color: #92400E; }
.badge-uretimde       { background: #FFEDD5; color: #9A3412; }
.badge-gonderildi     { background: #D1FAE5; color: #065F46; }
.badge-iptal          { background: #FEE2E2; color: #991B1B; }
.badge-uretimde_iptal { background: #FEE2E2; color: #991B1B; border: 2px solid #DC2626; }

/* --- Factory grid --- */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.8rem;
  color: var(--gray-600);
}

.sync-status-text { flex: 1; }

.btn-sync-trigger {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.85rem;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s;
}
.btn-sync-trigger:hover { opacity: .85; }
.btn-sync-trigger:disabled { opacity: .5; cursor: not-allowed; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.page-header h1 {
  font-size: 1.375rem;
  font-weight: 700;
}

/* ═══ Sipariş listesi ═══ */
.order-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ═══ Sipariş satırı ═══ */
.order-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.07), 0 1px 6px rgba(0,0,0,.04);
  display: flex;
  align-items: stretch;
  gap: 0;
  transition: box-shadow .15s;
  overflow: hidden;
}
.order-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,.11); }
.order-card.selected { outline: 2px solid var(--blue); outline-offset: -1px; }

/* Sol: checkbox */
.row-check {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  border-right: 1px solid var(--gray-100);
  flex-shrink: 0;
}

/* Müşteri bilgisi */
.row-info {
  width: 190px;
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  border-right: 1px solid var(--gray-100);
}
.row-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.3;
}
.row-meta {
  font-size: 0.7rem;
  color: var(--gray-400);
}
.row-status { margin-top: 4px; }

/* Ürün fotoğrafları — yatay kaydırılabilir şerit */
.row-products {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.65rem 1rem;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-200) transparent;
}
.row-products::-webkit-scrollbar { height: 4px; }
.row-products::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 2px; }

/* Tek ürün kutusu */
.row-product {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 145px;
}

.row-photo {
  position: relative;
  width: 145px;
  height: 170px;
  border-radius: 7px;
  overflow: hidden;
  background: var(--gray-100);
}
.row-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-placeholder {
  width: 100%;
  height: 100%;
  background: var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 1.5rem;
}

/* Adet rozeti — fotoğraf sağ üstü */
.pp-qty-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--blue);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
  padding: 3px 11px;
  border-radius: 12px;
  line-height: 1.4;
  z-index: 2;
}

/* Boyut rozeti — fotoğraf sol altı */
.size-badge {
  position: absolute;
  bottom: 5px;
  left: 5px;
  background: rgba(0,0,0,.72);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1.4;
  z-index: 2;
}

/* Stok kodu — fotoğrafın altında, badge içinde, tam görünür */
.row-stock {
  background: var(--gray-800);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 800;
  text-align: center;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.4;
  width: 145px;
  padding: 4px 8px;
  border-radius: 6px;
}

/* Sağ: adet + aksiyon */
.row-action {
  flex-shrink: 0;
  width: 130px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
  padding: 0.65rem 0.875rem;
  border-left: 1px solid var(--gray-100);
}
.row-total-qty {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gray-800);
  text-align: center;
  line-height: 1.2;
}
.row-total-qty span {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 1px;
}
.row-action .btn { padding: 0.5rem; font-size: 0.8rem; }
.row-action .badge { text-align: center; display: block; padding: .45rem .5rem; font-size: 0.75rem; }
.card-error-msg {
  color: var(--red);
  font-size: 0.72rem;
  text-align: center;
  min-height: 1rem;
}

/* Checkbox */
.card-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--blue);
  display: block;
}

/* Select-all row */
.select-all-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
}

.select-all-row input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--blue);
}

/* --- Batch toolbar --- */
.batch-bar {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-800);
  color: #fff;
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  z-index: 50;
  white-space: nowrap;
}

.batch-bar.hidden { display: none; }

.batch-count { font-size: 0.9375rem; font-weight: 600; }

.batch-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .15s;
}

.batch-btn:disabled { opacity: .5; cursor: not-allowed; }
.batch-btn-pick { background: #D97706; color: #fff; }
.batch-btn-send { background: var(--blue); color: #fff; }
.batch-btn-clear { background: rgba(255,255,255,.15); color: #fff; }

/* Fade out animation */
@keyframes fadeOut {
  to { opacity: 0; transform: scale(.95); }
}

.fade-out {
  animation: fadeOut .4s ease forwards;
  pointer-events: none;
}

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--gray-400);
  font-size: 1.0625rem;
}

/* --- Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-width: 540px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}

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

.modal-header h2 { font-size: 1.125rem; font-weight: 700; }

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

.modal-body { padding: 1.5rem; }

.modal-body img {
  width: 100%;
  border-radius: 8px;
  margin-bottom: 1.25rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.9375rem;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .key { color: var(--gray-600); font-weight: 500; }
.detail-row .val { font-weight: 600; text-align: right; }

/* Auto-refresh indicator */
.refresh-info {
  font-size: 0.8125rem;
  color: var(--gray-400);
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

/* --- Pagination --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 1.25rem 1rem;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  padding: 0 0.5rem;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  color: var(--gray-600);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-btn:hover:not(:disabled) { background: var(--gray-100); }
.page-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

.page-info {
  font-size: 0.875rem;
  color: var(--gray-600);
  padding: 0 0.5rem;
}

/* Responsive */
@media (max-width: 640px) {
  .filter-bar input[type="text"] { width: 100%; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  td:nth-child(4), th:nth-child(4),
  td:nth-child(5), th:nth-child(5) { display: none; }
}
