/* ============================================================
   ÜRETIM TAKIP - RESPONSIVE / MOBILE STYLES
   ============================================================ */

/* ---- Touch Targets (Mobile) ---- */
@media (max-width: 1023px) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 36px; }

  .form-input { min-height: 48px; font-size: 16px; } /* 16px prevents iOS zoom */
  .form-select { min-height: 48px; font-size: 16px; }
  .form-textarea { font-size: 16px; }

  .stage-item { min-height: 52px; }
  .stage-checkbox { width: 30px; height: 30px; }

  .list-item { min-height: 56px; }
  .more-menu-item { min-height: 64px; }
  .nav-item { min-height: 44px; }

  /* Sidebar mobilde tamamen gizli */
  #sidebar { display: none !important; }
}

/* ---- Small Screens ---- */
@media (max-width: 380px) {
  .login-card { padding: 24px 20px; }
  .login-title { font-size: 24px; }
  .login-logo-icon { font-size: 48px; }

  .user-badge-info { display: none; }
  .user-badge-btn { padding: 5px 7px; }

  .brand-title { font-size: 15px; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 24px; }

  .form-row { grid-template-columns: 1fr; }

  .page-title { font-size: 18px; }
  .prod-name { font-size: 15px; }
}

/* ---- Tablet (768px+) — modal ortalama ---- */
@media (min-width: 768px) {
  #modal-overlay {
    align-items: center;
    padding: 20px;
  }
  #modal-container {
    border-radius: var(--r-xl);
    max-width: 560px;
  }
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   DESKTOP LAYOUT (1024px+) — Sidebar + Geniş İçerik
   ============================================================ */
@media (min-width: 1024px) {

  /* Temel değişkenler */
  :root { --sidebar-w: 250px; }

  /* ---- Sidebar Göster, Alt Nav Gizle ---- */
  #sidebar {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-800);
    border-right: 1px solid var(--card-border);
    padding: 20px 12px;
    z-index: 200;
    overflow-y: auto;
    gap: 4px;
  }

  #bottom-nav { display: none !important; }

  /* ---- App Container ---- */
  #app {
    max-width: 100%;
    margin: 0;
  }

  /* ---- Header: sağa kaydır ---- */
  #app-header {
    left: var(--sidebar-w) !important;
    transform: none !important;
    width: calc(100% - var(--sidebar-w)) !important;
    max-width: none !important;
  }

  /* ---- Content: sola boşluk bırak ---- */
  #main-content {
    padding-left: var(--sidebar-w);
    padding-bottom: 40px;
  }

  /* ---- Sayfa genişliği ---- */
  .view-page {
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px 40px;
  }

  /* ---- Modal masaüstü ---- */
  #modal-overlay {
    align-items: center;
    padding: 24px;
  }
  #modal-container {
    max-width: 680px;
    border-radius: var(--r-xl);
  }

  /* ---- İstatistik Kartları 4 sütun ---- */
  .stats-grid { grid-template-columns: repeat(4, 1fr); }

  /* ---- Sidebar İçerik Stilleri ---- */
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 8px 16px;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 4px;
  }

  .sidebar-brand-name {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-100);
    letter-spacing: -0.02em;
  }

  .sidebar-firma {
    font-size: 11px;
    font-weight: 600;
    color: var(--green);
    padding: 6px 8px 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-divider {
    height: 1px;
    background: var(--card-border);
    margin: 6px 0;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
  }

  /* Nav item masaüstü override */
  #sidebar .nav-item {
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    padding: 10px 12px !important;
    border-radius: var(--r-md) !important;
    color: var(--text-400);
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    text-align: left;
    min-height: unset;
    transform: none !important;
  }

  #sidebar .nav-item:hover {
    background: var(--bg-700);
    color: var(--text-300);
  }

  #sidebar .nav-item.active {
    background: var(--green-dim);
    color: var(--green);
  }

  #sidebar .nav-item.active .nav-icon {
    transform: none; /* Mobil scale animasyonunu iptal et */
  }

  #sidebar .nav-icon {
    font-size: 18px !important;
    line-height: 1;
    flex-shrink: 0;
  }

  #sidebar .nav-label {
    font-size: 14px !important;
    font-weight: 600 !important;
    letter-spacing: normal !important;
    white-space: nowrap;
    flex: 1;
  }

  #sidebar .nav-badge {
    position: static !important;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
  }

  .sidebar-spacer { flex: 1; min-height: 16px; }

  .sidebar-user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    background: var(--bg-700);
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: all var(--t-fast);
    width: 100%;
    text-align: left;
  }

  .sidebar-user-btn:hover {
    background: var(--bg-600);
    border-color: var(--card-border-hover);
  }

  .sidebar-user-info { flex: 1; min-width: 0; }

  .sidebar-user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-100);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .sidebar-user-role {
    font-size: 10px;
    font-weight: 600;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }

  /* ---- Üst Header Basitleştir ---- */
  /* Masaüstünde header sadece sayfa adını gösterir, kullanıcı sidebar'da */
  #user-badge-btn { display: none; }
  .header-inner { justify-content: flex-start; }
  .brand-title {
    font-size: 18px;
    font-weight: 700;
  }

  /* ---- İçerik Grid'leri ---- */
  /* Sipariş/ürün listesi 2 sütun */
  .desktop-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* Profil menüsü konumu */
  .profile-menu {
    left: calc(var(--sidebar-w) + 8px);
    top: unset;
    bottom: 80px;
    right: unset;
  }
}

/* ---- Safe Area for iPhone notch ---- */
@supports (padding: env(safe-area-inset-top)) {
  @media (max-width: 1023px) {
    #app-header {
      padding-top: env(safe-area-inset-top);
      height: calc(var(--header-h) + env(safe-area-inset-top));
    }
    #main-content {
      padding-top: calc(var(--header-h) + env(safe-area-inset-top));
      padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
    }
    #bottom-nav {
      height: calc(var(--nav-h) + env(safe-area-inset-bottom));
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* ---- Landscape Mobile ---- */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 1023px) {
  .login-card { padding: 16px 24px; }
  .login-logo { margin-bottom: 16px; }
  .login-logo-icon { font-size: 36px; }
  .login-title { font-size: 20px; }

  #bottom-nav { height: 56px; }
  .nav-label { display: none; }
  .nav-item { padding: 8px; }
}

/* ---- Scrollbar Styling ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-600);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-600); }

/* ---- Focus Styles (Accessibility) ---- */
*:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* ---- Print Styles ---- */
@media print {
  #app-header, #bottom-nav, #sidebar { display: none; }
  #main-content { padding: 0; }
}
