/**
 * WarehouseOS — Mobile & Responsive Stylesheet
 * Responsive breakpoints and mobile-specific component overrides
 * Version: 2.5.1
 */

  /* ─── MOBILE RESPONSIVE ───────────────────────────────── */
  @media (max-width: 768px) {
    /* sidebar jadi bottom nav */
    aside {
      width: 100%; height: 60px; min-height: 0;
      top: auto; bottom: 0; left: 0; right: 0;
      flex-direction: row; border-right: none;
      border-top: 1px solid var(--border);
      z-index: 300; overflow: hidden;
    }
    .logo { display: none; }
    nav {
      padding: 0; flex: 1; display: flex;
      flex-direction: row; align-items: stretch;
      overflow-x: auto; overflow-y: hidden;
    }
    nav::-webkit-scrollbar { display: none; }
    .nav-section { display: none; }
    .nav-item {
      flex-direction: column; flex: 1; min-width: 60px;
      padding: 6px 4px; gap: 3px; border-left: none;
      border-top: 2px solid transparent; font-size: 9px;
      text-align: center; justify-content: center;
    }
    .nav-item svg { width: 20px; height: 20px; }
    .nav-item.active { border-top-color: var(--accent); border-left: none; background: rgba(0,229,160,0.05); }
    .nav-item[onclick*="supplier"] { display: none; }
    .nav-item[onclick*="opname"] { display: none; }

    /* Tombol opname di header - hanya tampil di mobile */
    #header-opname-btn { display: flex !important; }

    /* FAB opname */
    #fab-opname { display: flex !important; }
    .nav-badge { position: absolute; top: 4px; right: 4px; margin: 0; }
    .sidebar-footer { display: none; }

    /* main layout */
    main { margin-left: 0; padding-bottom: 60px; }
    header {
      padding: 12px 16px; gap: 8px;
      flex-wrap: wrap;
    }
    .header-title { font-size: 12px; }
    .header-date { display: none; }
    .btn { padding: 7px 12px; font-size: 12px; }

    /* pages */
    .page { padding: 16px; }

    /* dashboard */
    .kpi-grid { grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 16px; }
    .kpi-value { font-size: 22px; }
    .kpi-icon { font-size: 26px; }
    .two-col { grid-template-columns: 1fr; gap: 12px; }

    /* table scroll */
    .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .data-table th, .data-table td { padding: 10px 10px; font-size: 12px; white-space: nowrap; }

    /* page head */
    .page-head { flex-wrap: wrap; gap: 8px; }
    .page-head h1 { font-size: 15px; }
    .search-box { width: 100%; }

    /* modal */
    .modal { width: calc(100vw - 24px); padding: 20px 16px; }
    .form-row { grid-template-columns: 1fr; }

    /* detail panel */
    .detail-panel { width: 100%; right: -100%; }
    .detail-meta-grid { grid-template-columns: 1fr 1fr; }

    /* scan mode */
    .scan-header { padding: 12px 14px; gap: 8px; }
    .scan-header .btn { padding: 7px 12px; font-size: 12px; }
    .scan-body { flex-direction: column; overflow-y: auto; }
    .scan-input-zone {
      width: 100% !important; border-right: none;
      border-bottom: 1px solid var(--border);
      overflow-y: visible;
    }
    .scan-feed { min-height: 160px; max-height: 200px; flex-shrink: 0; }
    .scan-mode-btn { padding: 7px 14px; font-size: 12px; }

    /* camera button in scan */
    .cam-scan-trigger { display: flex !important; }

    /* notif bar */
    .notif-bar { font-size: 12px; }

    /* ── DATA BARANG mobile ── */
    .tbl-barang-desktop { display: none; }
    .mobile-card-list { display: flex; flex-direction: column; gap: 10px; }

    /* ── TRANSAKSI mobile ── */
    .tbl-trx-desktop { display: none; }
    .mobile-trx-list { display: flex; flex-direction: column; gap: 8px; }

    /* ── LOKASI mobile ── */
    .rak-grid { grid-template-columns: repeat(4,1fr) !important; gap: 10px !important; }
    .rak { font-size: 12px !important; }
    .rak-legend { flex-wrap: wrap; gap: 10px; }

    /* ── LAPORAN mobile ── */
    .report-grid { grid-template-columns: repeat(2,1fr) !important; gap: 10px !important; }
    .report-card { padding: 14px !important; }
    .laporan-nilai-grid { grid-template-columns: 1fr !important; gap: 1px; }
    .laporan-nilai-val { font-size: 16px !important; }

    /* ── PAGE HEAD mobile ── */
    .page-head { flex-direction: column; align-items: stretch; }
    .page-head h1 { font-size: 16px; }
    .page-head .search-box { width: 100%; }
    .page-head select { width: 100% !important; }
  }

  /* camera scan trigger — hidden on desktop, shown mobile */
  .cam-scan-trigger {
    display: none;
    align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 8px;
    background: var(--surface2); border: 1px solid var(--border);
    cursor: pointer; font-size: 20px; flex-shrink: 0;
    transition: all 0.15s;
  }
  .cam-scan-trigger:hover { border-color: var(--accent); }

  /* mobile: show camera btn even on desktop if user clicks */
  .cam-scan-trigger.force-show { display: flex !important; }

  /* ─── MOBILE CARD STYLES ─────────────────────────────── */
  .mobile-card-list { display: none; flex-direction: column; gap: 10px; }
  .m-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px;
    cursor: pointer; transition: border-color 0.15s;
    position: relative;
  }
  .m-card:active { border-color: var(--accent2); }
  .m-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
  .m-card-name { font-size: 14px; font-weight: 700; flex: 1; line-height: 1.3; }
  .m-card-id { font-size: 10px; font-family: var(--mono); color: var(--text3); margin-bottom: 4px; }
  .m-card-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
  .m-card-meta { font-size: 11px; color: var(--text2); }
  .m-card-meta b { color: var(--text); }
  .m-stok-bar { height: 3px; border-radius: 2px; background: var(--border); margin-top: 8px; }
  .m-stok-fill { height: 3px; border-radius: 2px; transition: width 0.3s; }

  /* mobile trx card */
  .mobile-trx-list { display: none; flex-direction: column; gap: 8px; }
  .m-trx-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 12px 14px;
    border-left: 3px solid var(--border);
  }
  .m-trx-card.masuk { border-left-color: var(--accent2); }
  .m-trx-card.keluar { border-left-color: var(--danger); }
  .m-trx-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
  .m-trx-nama { font-size: 13px; font-weight: 700; flex: 1; }
  .m-trx-meta { font-size: 11px; color: var(--text3); font-family: var(--mono); }
  .m-trx-sn { font-size: 10px; color: var(--text3); font-family: var(--mono); margin-top: 4px; word-break: break-all; }

  @media (max-width: 768px) {
    .data-table-wrap { display: none; }
    .mobile-card-list { display: flex; }
    .mobile-trx-list { display: flex; }
  }

  /* ─── STOK KRITIS ACCORDION ─────────────────────────── */
  .merek-row {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.12s; user-select: none;
  }
  .merek-row:hover { background: var(--surface2); }
  .merek-row:last-child { border-bottom: none; }
  .merek-chevron { font-size: 10px; color: var(--text3); transition: transform 0.2s; margin-left: auto; flex-shrink:0; }
  .merek-chevron.open { transform: rotate(90deg); }
  .merek-name { font-size: 13px; font-weight: 700; flex:1; }
  .merek-badges { display: flex; gap: 5px; flex-shrink:0; }
  .merek-count-habis { font-size: 10px; font-family: var(--mono); font-weight: 700;
    background: rgba(255,61,90,0.15); color: var(--danger);
    padding: 2px 7px; border-radius: 4px; }
  .merek-count-kritis { font-size: 10px; font-family: var(--mono); font-weight: 700;
    background: rgba(255,123,61,0.15); color: var(--warn);
    padding: 2px 7px; border-radius: 4px; }

  .merek-items { display: none; background: var(--surface2); }
  .merek-items.open { display: block; }
  .merek-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 16px 9px 28px;
    border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.1s;
  }
  .merek-item:hover { background: rgba(255,255,255,0.03); }
  .merek-item:last-child { border-bottom: none; }
  .merek-item-name { font-size: 12px; flex:1; color: var(--text2); }
  .merek-item-id { font-size: 10px; font-family: var(--mono); color: var(--text3); }

  /* ── LAPORAN ── */
  .lap-tab {
    flex:1; min-width:80px; padding:8px 12px;
    background:none; border:none; border-radius:6px;
    font-size:12px; font-family:var(--mono); font-weight:500;
    color:var(--text3); cursor:pointer;
    transition:all 0.15s; white-space:nowrap;
  }
  .lap-tab:hover { color:var(--text); background:rgba(255,255,255,0.04); }
  .lap-tab.active { background:var(--surface); color:var(--accent); border:1px solid var(--border); }

  .lap-table { width:100%; border-collapse:collapse; }
  .lap-table th {
    font-family:var(--mono); font-size:10px; color:var(--text3);
    letter-spacing:0.08em; padding:10px 12px;
    border-bottom:1px solid var(--border);
    text-align:left; background:var(--surface2);
  }
  .lap-table td {
    padding:10px 12px; font-size:12px;
    border-bottom:1px solid rgba(255,255,255,0.04);
    vertical-align:middle;
  }
  .lap-table tr:hover td { background:rgba(255,255,255,0.02); }
  .lap-table tr:last-child td { border-bottom:none; }

  .lap-bar-row { display:flex; align-items:center; gap:10px; padding:8px 0; border-bottom:1px solid rgba(255,255,255,0.04); }
  .lap-bar-label { font-size:12px; width:140px; flex-shrink:0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
  .lap-bar-bg { flex:1; height:8px; background:var(--border); border-radius:4px; overflow:hidden; }
  .lap-bar-fill { height:8px; border-radius:4px; transition:width 0.6s ease; }
  .lap-bar-val { font-family:var(--mono); font-size:11px; color:var(--text2); width:80px; text-align:right; flex-shrink:0; }

  .lap-month-row {
    display:grid; grid-template-columns:100px 1fr 1fr 1fr 120px;
    gap:12px; align-items:center;
    padding:12px 16px; border-bottom:1px solid var(--border);
    font-size:12px;
  }
  .lap-month-row:last-child { border-bottom:none; }
  .lap-month-name { font-family:var(--mono); font-weight:500; }

  @media(max-width:768px){
    #lap-kpi-row { grid-template-columns:repeat(2,1fr); }
    .lap-month-row { grid-template-columns:80px 1fr 1fr; font-size:11px; }
    .lap-month-row .hide-mobile { display:none; }
    .lap-bar-label { width:90px; font-size:11px; }
  }

  /* ── LAPORAN MINI CHART ── */
  .mini-chart-bars { display:flex; align-items:flex-end; gap:3px; height:60px; }
  .mini-bar { border-radius:2px 2px 0 0; min-width:8px; flex:1; transition:height 0.5s; }

  .lap-period-btn {
    padding: 5px 12px; border-radius: 6px;
    background: var(--surface2); border: 1px solid var(--border);
    font-size: 11px; font-family: var(--mono); color: var(--text2);
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
  }
  .lap-period-btn:hover { border-color: var(--accent2); color: var(--accent2); }
  .lap-period-btn.active { background: rgba(0,145,255,0.1); border-color: var(--accent2); color: var(--accent2); }

  /* ── STOCK OPNAME ── */
  .opname-row-ok      { background: rgba(0,229,160,0.03); }
  .opname-row-selisih { background: rgba(255,123,61,0.05); }
  .opname-row-lebih   { background: rgba(0,145,255,0.04); }
  .opname-qty-input {
    width: 80px; padding: 5px 8px;
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text);
    font-family: var(--mono); font-size: 13px; font-weight: 700;
    text-align: center; outline: none;
    transition: border-color 0.15s;
  }
  .opname-qty-input:focus { border-color: var(--accent); }
  .opname-qty-input.changed { border-color: var(--accent2); background: rgba(0,145,255,0.08); }
  .opname-qty-input.selisih-neg { border-color: var(--warn); background: rgba(255,123,61,0.08); }
  .opname-qty-input.selisih-pos { border-color: var(--accent2); background: rgba(0,145,255,0.08); }
  .opname-note-input {
    width: 100%; padding: 4px 8px;
    background: transparent; border: none;
    border-bottom: 1px solid var(--border);
    color: var(--text2); font-size: 11px; outline: none;
  }
  .opname-note-input:focus { border-bottom-color: var(--accent); }

  @media(max-width:768px){
    #page-opname .data-table-wrap { display:none; }
    #opname-mobile-list { display:flex !important; flex-direction:column; gap:10px; padding:12px; }
    .opname-mobile-card {
      background: var(--surface); border: 1px solid var(--border);
      border-radius:10px; padding:14px;
    }
  }

  /* ─── PRINT STYLES ─────────────────────────────────── */
  @media print {
    body > *:not(#print-area) { display: none !important; }
    #print-area { display: block !important; position: static; }
    #print-area * { color: #000 !important; background: #fff !important; border-color: #ccc !important; }
  }
  #print-area { display: none; }

  /* ─── BATALKAN TRANSAKSI ────────────────────────────── */
  .trx-cancel-btn {
    background: none; border: 1px solid rgba(255,61,90,0.3);
    border-radius: 4px; padding: 3px 8px;
    font-size: 10px; color: var(--danger);
    cursor: pointer; font-family: var(--mono);
    transition: all 0.15s;
  }
  .trx-cancel-btn:hover { background: rgba(255,61,90,0.1); }
  .trx-cancelled { opacity: 0.4; text-decoration: line-through; }

  /* html5-qrcode dark theme override */
  #cam-reader { background: #000 !important; }
  #cam-reader video { border-radius: 0 !important; width:100% !important; }
  #cam-reader__scan_region { background: transparent !important; }
  #cam-reader__dashboard { background: #111 !important; padding: 8px !important; }
  #cam-reader__dashboard_section_csr button {
    background: var(--accent) !important; color: #000 !important;
    border: none !important; border-radius: 6px !important;
    padding: 8px 16px !important; font-weight: 700 !important;
    cursor: pointer !important; margin: 4px !important;
  }
  #cam-reader__dashboard_section_swaplink,
  #cam-reader__header_message { display:none !important; }
  #cam-reader__status_span { color: rgba(255,255,255,0.5) !important; font-size:11px !important; }
  #cam-reader select { background: #222 !important; color:#fff !important; border:1px solid #444 !important; border-radius:6px !important; padding:4px !important; }
