/* ============================================================
   RING DEFECT SYSTEM — Enterprise Light Theme (Linear/Vercel style)
   ============================================================ */

:root {
  /* Colors - Enterprise Palette */
  --bg-body:       #F7F8FA;
  --bg-surface:    #FFFFFF;
  --bg-elevated:   #FFFFFF;
  
  --border-light:  #E5E7EB;
  --border-focus:  #2563EB;
  
  --text-main:     #111827;
  --text-muted:    #6B7280;
  --text-dim:      #9CA3AF;
  
  --color-primary: #2563EB;
  --color-primary-hover: #1D4ED8;
  
  --color-success: #10B981;
  --color-success-bg: #ECFDF5;
  --color-success-border: #D1FAE5;
  
  --color-warning: #F59E0B;
  --color-warning-bg: #FFFBEB;
  --color-warning-border: #FEF3C7;
  
  --color-danger:  #EF4444;
  --color-danger-bg: #FEF2F2;

  /* Typography */
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Metrics */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  --header-h: 56px;
  --nav-h: 64px;
  
  /* Shadows - subtle and crisp */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  --transition: 0.15s ease-in-out;
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
.login-wrapper {
  position: fixed; inset: 0; z-index: 1000;
  background-color: var(--bg-body);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%; max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 24px; }
.login-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 48px; height: 48px;
  background: var(--color-primary); color: #fff;
  border-radius: 12px; margin-bottom: 16px;
}
.login-title { font-size: 20px; font-weight: 700; color: var(--text-main); letter-spacing: -0.02em; }
.login-sub { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

.login-form .form-group { margin-bottom: 16px; }
.login-error {
  font-size: 13px; color: var(--color-danger);
  background: var(--color-danger-bg);
  padding: 8px 12px; border-radius: var(--radius-sm);
  margin-bottom: 16px; text-align: center; font-weight: 500;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-light);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 100%; padding: 0 16px;
  max-width: 800px; margin: 0 auto;
}
.header-logo { display: flex; align-items: center; gap: 8px; }
.logo-icon-sm {
  color: var(--color-primary); display: flex; align-items: center;
}
.logo-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

.header-right { display: flex; align-items: center; gap: 12px; }
.user-badge {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  background: var(--bg-body); padding: 4px 8px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-light);
}
.btn-logout {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--transition);
}
.btn-logout:hover { color: var(--color-danger); }

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-light);
  display: flex; justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); transition: color var(--transition);
}
.nav-btn.hidden { display: none !important; }
.nav-btn:hover { color: var(--text-main); }
.nav-btn.active { color: var(--color-primary); }
.nav-icon { width: 22px; height: 22px; }
.nav-label { font-size: 11px; font-weight: 500; }

/* ============================================================
   MAIN LAYOUT & TABS
   ============================================================ */
.app-main {
  padding-top: calc(var(--header-h) + 24px);
  padding-bottom: calc(var(--nav-h) + 24px);
  padding-left: 16px; padding-right: 16px;
  max-width: 600px; margin: 0 auto;
}

.tab-pane { display: none; animation: fadeIn 0.2s ease-out forwards; }
.tab-pane.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header { margin-bottom: 20px; }
.section-title { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; color: var(--text-main); }
.section-sub { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   CARDS & CONTAINERS
   ============================================================ */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px; margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   FORM ELEMENTS (Enterprise Style)
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-main); margin-bottom: 6px;
}
.form-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-family: var(--font-family); font-size: 14px; color: var(--text-main);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none; -webkit-appearance: none;
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.form-input.readonly { background: var(--bg-body); color: var(--text-muted); cursor: not-allowed; }

.form-textarea { resize: vertical; min-height: 80px; }

/* Group Selector */
.group-selector { display: flex; gap: 8px; }
.group-btn {
  flex: 1; padding: 10px;
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
  color: var(--text-muted); cursor: pointer; transition: all var(--transition);
}
.group-btn.selected {
  background: rgba(37, 99, 235, 0.05);
  border-color: var(--color-primary); color: var(--color-primary);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; font-family: var(--font-family); font-size: 14px; font-weight: 500;
  border-radius: var(--radius-md); border: 1px solid transparent; cursor: pointer;
  transition: all var(--transition); text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-full { width: 100%; }

.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-hover); }

.btn-secondary { background: var(--bg-body); color: var(--text-main); border-color: var(--border-light); }
.btn-secondary:hover { background: var(--border-light); }

.btn-outline { background: transparent; color: var(--text-main); border-color: var(--border-light); }
.btn-outline:hover { border-color: var(--text-muted); }

.btn-success { background: var(--color-success); color: #fff; box-shadow: var(--shadow-sm); }

.btn-icon {
  background: transparent; border: none; cursor: pointer;
  padding: 4px; color: var(--text-muted); font-size: 16px; display: flex; align-items: center;
}

/* ============================================================
   SCANNER SPECIFICS
   ============================================================ */
.qr-status {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 16px; gap: 12px; color: var(--text-dim);
}
.scanner-result {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--color-success-bg); border: 1px solid var(--color-success-border);
  padding: 12px 16px; border-radius: var(--radius-md); margin-bottom: 16px;
}
.result-content { display: flex; flex-direction: column; }
.result-label { font-size: 12px; color: var(--text-muted); }
.result-value { font-size: 16px; color: var(--color-success); font-weight: 600; }
.divider-text {
  text-align: center; font-size: 12px; color: var(--text-muted); margin: 12px 0;
  display: flex; align-items: center; gap: 8px;
}
.divider-text::before, .divider-text::after { content: ''; flex: 1; height: 1px; background: var(--border-light); }
.manual-input-row { display: flex; gap: 8px; }

/* ============================================================
   STATS & LISTS
   ============================================================ */
.stats-row { display: flex; gap: 12px; margin-bottom: 20px; }
.stat-chip {
  flex: 1; background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column;
}
.stat-txt { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }
.text-success { color: var(--color-success); }

.defect-list { display: flex; flex-direction: column; gap: 12px; }

.defect-card {
  background: var(--bg-surface); border: 1px solid var(--border-light);
  border-radius: var(--radius-lg); padding: 16px;
  transition: box-shadow var(--transition);
}
.defect-card:hover { box-shadow: var(--shadow-md); }

.defect-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.defect-id { font-size: 12px; font-weight: 600; color: var(--text-muted); }

.status-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; border: 1px solid transparent;
}
.status-pending { background: var(--color-warning-bg); color: var(--color-warning); border-color: var(--color-warning-border); }
.status-inprog  { background: rgba(37, 99, 235, 0.1); color: var(--color-primary); border-color: rgba(37, 99, 235, 0.2); }
.status-fixed   { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success-border); }
.status-verified {
  background-color: var(--color-success);
  color: #166534;
}

.defect-product { font-size: 16px; font-weight: 600; color: var(--text-main); margin-bottom: 8px; }
.defect-desc { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.4; }

.defect-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.meta-tag {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  background: var(--bg-body); padding: 2px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border-light);
}

.defect-info-box {
  font-size: 13px; padding: 8px 12px; border-radius: var(--radius-sm); margin-bottom: 12px;
}
.info-inprog { background: rgba(37, 99, 235, 0.05); color: var(--color-primary); border-left: 3px solid var(--color-primary); }
.info-fixed  { background: var(--color-success-bg); color: var(--color-success); border-left: 3px solid var(--color-success); }
.info-verified {
  background-color: var(--color-success);
  border-left-color: #22c55e;
  color: #14532d;
}

/* History Filters */
.filter-row { display: flex; gap: 8px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 4px; }
.filter-btn {
  padding: 6px 12px; border: 1px solid var(--border-light); border-radius: 99px;
  background: var(--bg-surface); color: var(--text-muted); font-size: 13px; font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.filter-btn.active { background: var(--text-main); color: #fff; border-color: var(--text-main); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 14px; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(17, 24, 39, 0.4); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center; padding: 16px;
  transition: opacity var(--transition);
}
.modal-box {
  width: 100%; max-width: 500px; background: var(--bg-surface);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  overflow: hidden; animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.modal-header { padding: 20px 20px 16px; border-bottom: 1px solid var(--border-light); }
.modal-title { font-size: 18px; font-weight: 600; color: var(--text-main); letter-spacing: -0.01em; }

.modal-body { padding: 20px; }
.modal-info {
  background: var(--bg-body); border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: 12px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px;
}

.modal-footer { padding: 16px 20px 20px; display: flex; gap: 12px; justify-content: flex-end; }
.modal-footer .btn { flex: 1; }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 300;
  display: flex; flex-direction: column; gap: 8px; width: 90%; max-width: 400px;
}
.toast {
  background: var(--bg-surface); border: 1px solid var(--border-light); box-shadow: var(--shadow-md);
  padding: 12px 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500;
  animation: slideDown 0.2s ease forwards; display: flex; align-items: center; gap: 8px;
}
.toast.hide { opacity: 0; transform: translateY(-10px); transition: 0.2s; }
@keyframes slideDown { from { transform: translateY(-10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.toast-success { border-left: 3px solid var(--color-success); }
.toast-error   { border-left: 3px solid var(--color-danger); }
.toast-info    { border-left: 3px solid var(--color-primary); }

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .bottom-nav { border-top: none; background: transparent; backdrop-filter: none; top: 0; bottom: auto; right: auto; left: 200px; height: var(--header-h); width: 400px; }
  .nav-btn { flex-direction: row; }
  .app-main { padding-top: calc(var(--header-h) + 32px); }
}
