/* StitchFlow ERP - sign in, user badge, and phone layout.
   Loaded after styles.css so it can adjust the existing desktop design. */

/* ------------------------------------------------------------- sign in */

.sf-login {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #10233b 0%, #1c3a5e 100%);
}

body.sf-locked > .app-shell { display: none; }

.sf-login__card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.sf-login__brand {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.06em;
  color: #10233b;
  text-align: center;
}

.sf-login__sub {
  margin: 6px 0 26px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.sf-login__label {
  font-size: 13px;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.sf-login__input {
  width: 100%;
  box-sizing: border-box;
  /* 16px keeps iOS from zooming in when the field is focused. */
  font-size: 16px;
  padding: 13px 14px;
  margin-bottom: 18px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
}

.sf-login__input:focus {
  outline: none;
  border-color: #2563eb;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.sf-login__button {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: #1d4ed8;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 48px;
}

.sf-login__button:disabled { background: #94a3b8; cursor: default; }
.sf-login__button:hover:not(:disabled) { background: #1e40af; }

.sf-login__error {
  color: #b91c1c;
  font-size: 14px;
  margin: 14px 0 0;
  min-height: 20px;
  text-align: center;
}

.sf-login__hint {
  margin: 18px 0 0;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

.sf-fatal {
  background: #7f1d1d;
  color: #fff;
  padding: 14px 18px;
  font-size: 14px;
}

/* --------------------------------------------------------- user badge */

.sf-userbadge {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  font-size: 13px;
}

.sf-userbadge__name { font-weight: 600; color: #0f172a; }

.sf-userbadge__role {
  color: #475569;
  background: #eef2ff;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
}

.sf-userbadge__out {
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 12px;
  min-height: 32px;
}

.sf-userbadge__out:hover { background: #f1f5f9; }

/* --------------------------------------------------- change password */

.sf-modal {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sf-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}

.sf-modal__card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 14px;
  padding: 26px 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

.sf-modal__title { margin: 0 0 4px; font-size: 18px; color: #0f172a; }
.sf-modal__sub   { margin: 0 0 20px; font-size: 13px; color: #64748b; }

.sf-modal__actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.sf-modal__cancel {
  flex: 0 0 auto;
  padding: 13px 18px;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  min-height: 48px;
}

.sf-modal__cancel:hover { background: #f1f5f9; }
.sf-modal__save { flex: 1 1 auto; margin: 0; }

/* ------------------------------------------------------ phones/tablets */

@media (max-width: 900px) {
  .app-shell {
    display: block;
    grid-template-columns: none;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px;
  }

  .sidebar .intro { display: none; }

  /* Turn the vertical menu into a horizontal strip of large tap targets. */
  .nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
  }

  .nav::-webkit-scrollbar { height: 0; }

  .nav-link {
    flex: 0 0 auto;
    white-space: nowrap;
    min-height: 44px;
    padding: 10px 16px;
    border-radius: 999px;
  }

  .content { padding: 16px; }

  .grid-two,
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .inline-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Entry forms: full-width fields, no iOS zoom, thumb-sized controls. */
  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  input,
  select,
  textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
  }

  button { min-height: 44px; }

  /* Wide report tables scroll sideways instead of squashing. */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table-wrap table { min-width: 560px; }

  .sf-userbadge {
    position: static;
    margin: 12px 0 0;
    justify-content: space-between;
    border-radius: 12px;
  }

  .panel-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat-card { padding: 12px; }
  .stat-card strong { font-size: 18px; }
  .sf-login__card { padding: 26px 20px; }
}

/* The size-wise quantity grid is the most-used input on the floor. styles.css
   collapses it to a single column on small screens, which turns a six-size
   entry into a long scroll. Keep it as a compact grid instead. */
@media (max-width: 900px) {
  .size-grid,
  .acceptance-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 10px;
  }

  .size-card { padding: 10px; }
  .size-card h4 { margin: 0 0 6px; font-size: 14px; }
  .size-card input { text-align: center; }
}

@media (max-width: 420px) {
  .size-grid,
  .acceptance-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
}
