/* =============================================
   RAJ Measurement App - Shared Stylesheet
   ============================================= */

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

:root {
  --primary: #1565C0;
  --primary-dark: #0D47A1;
  --primary-light: #E3F2FD;
  --accent: #FF6F00;
  --danger: #C62828;
  --success: #2E7D32;
  --text: #212121;
  --text-muted: #757575;
  --border: #E0E0E0;
  --bg: #F5F7FA;
  --white: #FFFFFF;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
  --radius: 8px;
  --font: 'Segoe UI', Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  min-height: 100vh;
}

/* ---- Typography ---- */
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
.hindi { font-family: 'Noto Sans Devanagari', 'Mangal', Arial, sans-serif; }
.label-both { display: flex; flex-direction: column; gap: 1px; }
.label-both .hi { font-size: 0.78rem; color: var(--text-muted); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border: none; border-radius: var(--radius);
  font-size: 0.92rem; font-family: var(--font);
  cursor: pointer; transition: all 0.18s; text-decoration: none;
  font-weight: 500; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #E65100; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #B71C1C; }
.btn-outline {
  background: transparent; color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-icon { padding: 8px; border-radius: 50%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- Cards ---- */
.card {
  background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card-title {
  font-size: 1rem; font-weight: 600; color: var(--primary);
  margin-bottom: 16px; padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
  display: flex; justify-content: space-between; align-items: center;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 5px; font-weight: 500;
  font-size: 0.88rem; color: var(--text);
}
.form-label .hi { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius); font-size: 0.93rem; font-family: var(--font);
  transition: border-color 0.18s; background: var(--white);
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control.error { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-error { color: var(--danger); font-size: 0.8rem; margin-top: 4px; }
.form-section {
  background: var(--bg); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.form-section-title {
  font-size: 0.85rem; font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px;
}

/* ---- Header ---- */
.app-header {
  background: var(--primary); color: #fff;
  padding: 0 20px; height: 58px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2); position: sticky; top: 0; z-index: 100;
}
.app-header .logo-area { display: flex; align-items: center; gap: 10px; }
.app-header .shop-logo {
  width: 38px; height: 38px; border-radius: 50%;
  object-fit: cover; border: 2px solid rgba(255,255,255,0.4);
}
.app-header .shop-name { font-size: 1.05rem; font-weight: 600; }
.app-header .shop-name .hi { font-size: 0.75rem; opacity: 0.8; font-weight: 400; }
.header-actions { display: flex; align-items: center; gap: 8px; }

/* ---- Language Toggle ---- */
.lang-toggle {
  display: flex; background: rgba(255,255,255,0.15);
  border-radius: 20px; overflow: hidden;
}
.lang-toggle button {
  padding: 4px 10px; border: none; background: transparent;
  color: rgba(255,255,255,0.7); font-size: 0.78rem; cursor: pointer;
  transition: all 0.18s; font-family: var(--font);
}
.lang-toggle button.active { background: rgba(255,255,255,0.9); color: var(--primary); font-weight: 600; }

/* ---- Navigation ---- */
.nav-tabs {
  display: flex; background: var(--white); border-bottom: 2px solid var(--border);
  overflow-x: auto; padding: 0 20px;
}
.nav-tab {
  padding: 12px 18px; border: none; background: none; cursor: pointer;
  font-size: 0.88rem; color: var(--text-muted); border-bottom: 2.5px solid transparent;
  margin-bottom: -2px; white-space: nowrap; font-family: var(--font);
  transition: all 0.18s; font-weight: 500;
}
.nav-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.nav-tab:hover { color: var(--primary); }

/* ---- Main Layout ---- */
.main-content { max-width: 960px; margin: 0 auto; padding: 20px 16px; }
.page-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.page-title { font-size: 1.2rem; font-weight: 600; }
.page-title .hi { font-size: 0.82rem; color: var(--text-muted); font-weight: 400; }

/* ---- Search ---- */
.search-box {
  position: relative; width: 100%; max-width: 420px;
}
.search-box input {
  width: 100%; padding: 10px 16px 10px 40px;
  border: 1.5px solid var(--border); border-radius: 24px;
  font-size: 0.93rem; font-family: var(--font); background: var(--white);
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--primary-light); color: var(--primary);
  padding: 10px 14px; text-align: left; font-size: 0.83rem;
  font-weight: 600; white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAFA; }
.td-actions { display: flex; gap: 6px; }

/* ---- Toast ---- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius); color: #fff;
  font-size: 0.9rem; box-shadow: var(--shadow);
  animation: slideIn 0.3s ease; min-width: 220px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---- Badges ---- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-blue { background: var(--primary-light); color: var(--primary); }

/* ---- Loader ---- */
.loader-overlay {
  position: fixed; inset: 0; background: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center; z-index: 9998;
}
.loader {
  width: 40px; height: 40px; border: 4px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 16px;
}
.modal {
  background: var(--white); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ---- Empty State ---- */
.empty-state {
  text-align: center; padding: 50px 20px; color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.95rem; }

/* ---- Stats ---- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); text-align: center;
  border-top: 3px solid var(--primary);
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }

/* ---- Field Builder ---- */
.field-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 8px;
}
.field-item .drag-handle { color: var(--text-muted); cursor: grab; }
.field-item .field-names { flex: 1; display: flex; gap: 10px; }
.field-item .field-names input { flex: 1; }

/* ---- Print ---- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 13px; }
  .print-container { padding: 0; }
}
.print-container { max-width: 720px; margin: 0 auto; padding: 20px; }
.print-header {
  display: flex; align-items: center; gap: 16px;
  border-bottom: 2.5px solid var(--primary); padding-bottom: 14px; margin-bottom: 18px;
}
.print-logo { width: 70px; height: 70px; object-fit: contain; }
.print-shop-name { font-size: 1.4rem; font-weight: 700; color: var(--primary); }
.print-shop-name .hi { font-size: 1rem; font-weight: 500; color: var(--text-muted); }
.print-shop-detail { font-size: 0.85rem; color: var(--text-muted); }
.print-section { margin-bottom: 18px; }
.print-section-title {
  background: var(--primary); color: #fff;
  padding: 5px 12px; font-size: 0.82rem; font-weight: 600;
  border-radius: 4px; margin-bottom: 10px;
  display: flex; justify-content: space-between;
}
.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.print-field {
  display: flex; gap: 6px; padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.print-field-label { min-width: 140px; font-size: 0.83rem; color: var(--text-muted); }
.print-field-label .hi { font-size: 0.75rem; display: block; }
.print-field-value { font-weight: 500; font-size: 0.88rem; }
.print-measurement-table { width: 100%; border-collapse: collapse; }
.print-measurement-table th {
  background: var(--primary-light); color: var(--primary);
  padding: 7px 10px; font-size: 0.8rem; text-align: left;
}
.print-measurement-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.print-footer {
  margin-top: 24px; text-align: center; font-size: 0.78rem;
  color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 10px;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .main-content { padding: 12px 10px; }
  .page-header { flex-direction: row; align-items: center; gap: 8px; }
  .search-box { max-width: 100%; }
  .stats-row { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .app-header .shop-name .hi { display: none; }
  .card { padding: 14px; }
  .card-title { font-size: 0.92rem; }
  .btn { padding: 8px 14px; font-size: 0.88rem; }
  .modal { padding: 18px; }
  .form-section { padding: 12px; }
  /* Admin field builder mobile */
  .field-item .field-names { flex-direction: column; }
  .nav-tab { padding: 10px 12px; font-size: 0.82rem; }
}

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0D47A1 0%, #1565C0 50%, #1976D2 100%);
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: 12px;
  padding: 36px 32px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; }
.login-logo .app-title { font-size: 1.3rem; font-weight: 700; color: var(--primary); margin-top: 8px; }
.login-logo .app-title .hi { font-size: 0.85rem; color: var(--text-muted); font-weight: 400; }

/* ---- Misc ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
