/* =====================================================
   HIDROFOX SYSTEM — CSS (Mobile-First App Style)
   ===================================================== */

:root {
  --bg:         #0a0a14;
  --bg-card:    #111827;
  --bg-input:   #1f2937;
  --blue:       #1d4ed8;
  --blue-light: #3b82f6;
  --red:        #dc2626;
  --orange:     #f97316;
  --text:       #f1f5f9;
  --text-muted: #94a3b8;
  --border:     #1e3a5f;
  --success:    #22c55e;
  --warning:    #eab308;
  --radius:     12px;
  --radius-sm:  8px;
  --shadow:     0 4px 24px rgba(0,0,0,.6);
  --nav-h:      70px;
  --header-h:   64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overscroll-behavior: none;
}

/* ——— SCROLLBAR ——— */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--blue); border-radius: 4px; }

/* ——— HEADER ——— */
.app-header {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--header-h);
  background: linear-gradient(135deg, #0d1b3e 0%, #1a0a0a 100%);
  border-bottom: 2px solid var(--red);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(220,38,38,.3);
}
.app-header .logo-wrap { display: flex; align-items: center; gap: 10px; }
.app-header img.logo { height: 48px; width: auto; border-radius: 6px; }
.app-header .title {
  font-size: 13px; font-weight: 700; color: var(--text);
  line-height: 1.2;
}
.app-header .title span { color: var(--orange); }
.app-header .header-actions { display: flex; gap: 8px; }
.header-btn {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  color: var(--text); font-size: 20px;
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none;
  transition: background .2s;
}
.header-btn:hover { background: rgba(255,255,255,.15); }

/* ——— MAIN CONTENT ——— */
.app-content {
  padding-top: calc(var(--header-h) + 12px);
  padding-bottom: calc(var(--nav-h) + 12px);
  padding-left: 12px; padding-right: 12px;
  min-height: 100vh;
}

/* ——— BOTTOM NAV ——— */
.app-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: var(--nav-h);
  background: #0d1120;
  border-top: 2px solid var(--blue);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,.5);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 6px 12px;
  color: var(--text-muted);
  text-decoration: none; font-size: 10px; font-weight: 600;
  border-radius: 10px;
  transition: all .2s;
  min-width: 60px; text-align: center;
}
.nav-item .nav-icon { font-size: 22px; transition: transform .2s; }
.nav-item:hover, .nav-item.active {
  color: var(--orange);
}
.nav-item.active .nav-icon { transform: scale(1.2); }
.nav-item.active-red { color: var(--red) !important; }

/* ——— CARDS ——— */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title {
  font-size: 14px; font-weight: 700;
  color: var(--blue-light);
  display: flex; align-items: center; gap: 8px;
}
.card-title .icon { font-size: 18px; }

/* ——— FORM ELEMENTS ——— */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: .5px;
}
.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 15px;
  padding: 12px 14px;
  transition: border-color .2s, box-shadow .2s;
  -webkit-appearance: none;
}
.form-control:focus {
  outline: none;
  border-color: var(--blue-light);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
.form-control::placeholder { color: var(--text-muted); font-size: 13px; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

/* ——— TOGGLE BUTTONS (Serviços) ——— */
.toggle-group {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 4px;
}
.toggle-btn {
  background: var(--bg-input);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px; font-weight: 600;
  padding: 7px 12px;
  cursor: pointer;
  transition: all .2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.toggle-btn.active {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  border-color: var(--blue-light);
  color: #fff;
  box-shadow: 0 2px 10px rgba(59,130,246,.4);
}

/* ——— PAYMENT SELECTOR ——— */
.payment-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-top: 4px;
}
.payment-card {
  background: var(--bg-input);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center; cursor: pointer;
  transition: all .2s;
}
.payment-card .p-icon { font-size: 24px; display: block; margin-bottom: 4px; }
.payment-card .p-label { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.payment-card.selected {
  border-color: var(--orange);
  background: rgba(249,115,22,.1);
  box-shadow: 0 0 15px rgba(249,115,22,.3);
}
.payment-card.selected .p-label { color: var(--orange); }

/* ——— GUARANTEE SELECTOR ——— */
.guarantee-group { display: flex; gap: 8px; margin-top: 4px; }
.guarantee-btn {
  flex: 1; padding: 12px 4px; text-align: center;
  background: var(--bg-input); border: 2px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 700; color: var(--text-muted);
  transition: all .2s;
}
.guarantee-btn.active {
  border-color: var(--success);
  background: rgba(34,197,94,.1);
  color: var(--success);
}

/* ——— BUTTONS ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 700; cursor: pointer;
  padding: 14px 20px; transition: all .2s;
  text-decoration: none; -webkit-tap-highlight-color: transparent;
  min-height: 50px; width: 100%;
}
.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff; box-shadow: 0 4px 15px rgba(29,78,216,.5);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(29,78,216,.6); }
.btn-red {
  background: linear-gradient(135deg, #b91c1c 0%, var(--red) 100%);
  color: #fff; box-shadow: 0 4px 15px rgba(220,38,38,.4);
}
.btn-orange {
  background: linear-gradient(135deg, #ea6c10 0%, var(--orange) 100%);
  color: #fff; box-shadow: 0 4px 15px rgba(249,115,22,.4);
}
.btn-green {
  background: linear-gradient(135deg, #16a34a 0%, var(--success) 100%);
  color: #fff; box-shadow: 0 4px 15px rgba(34,197,94,.4);
}
.btn-outline {
  background: transparent; border: 2px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--blue-light); color: var(--blue-light); }
.btn-sm { padding: 8px 14px; font-size: 13px; min-height: 38px; width: auto; }
.btn-icon { font-size: 18px; }

/* ——— PHOTO UPLOAD ——— */
.photo-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center; cursor: pointer;
  transition: all .2s;
  position: relative;
}
.photo-upload-area:hover { border-color: var(--blue-light); }
.photo-upload-area input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2;
}
.photo-preview {
  width: 100%; max-height: 200px; object-fit: cover;
  border-radius: 8px; display: none;
}
.photo-placeholder { color: var(--text-muted); }
.photo-placeholder .ph-icon { font-size: 40px; display: block; }
.photo-placeholder p { font-size: 13px; margin-top: 6px; }

/* ——— SIGNATURE CANVAS ——— */
.signature-wrap {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  position: relative;
  overflow: hidden;
}
#signatureCanvas {
  display: block; width: 100%; height: 180px;
  cursor: crosshair; touch-action: none;
}
.sig-actions {
  display: flex; gap: 8px; margin-top: 8px;
}
.sig-clear {
  background: rgba(220,38,38,.15); border: 1px solid var(--red);
  color: var(--red); border-radius: 6px; padding: 6px 14px;
  font-size: 12px; font-weight: 700; cursor: pointer;
}
.sig-legal {
  background: rgba(249,115,22,.08);
  border: 1px solid rgba(249,115,22,.3);
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.6;
  color: #fbbf24;
  text-align: center;
}

/* ——— NF UPLOAD ——— */
.nf-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  position: relative; text-align: center;
}
.nf-area input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 2;
}
.nf-label { font-size: 13px; color: var(--text-muted); }
.nf-selected { font-size: 12px; color: var(--success); margin-top: 4px; }

/* ——— SEARCH BAR ——— */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 14px;
}
.search-bar .form-control { flex: 1; }
.search-bar .btn-sm { flex-shrink: 0; width: auto; }

/* ——— CLIENT CARDS (lista) ——— */
.client-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; transition: all .2s;
  text-decoration: none; color: inherit;
}
.client-card:hover { border-color: var(--blue-light); transform: translateY(-1px); }
.client-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  object-fit: cover; background: var(--bg-input);
  border: 2px solid var(--border); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; overflow: hidden;
}
.client-avatar img { width: 100%; height: 100%; object-fit: cover; }
.client-info { flex: 1; min-width: 0; }
.client-name { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.client-badge {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; white-space: nowrap;
}
.badge-blue { background: rgba(59,130,246,.2); color: var(--blue-light); }
.badge-green { background: rgba(34,197,94,.2); color: var(--success); }
.badge-red { background: rgba(220,38,38,.2); color: #f87171; }
.badge-orange { background: rgba(249,115,22,.2); color: var(--orange); }

/* ——— DASHBOARD ——— */
.dash-hero {
  background: linear-gradient(135deg, #0d1b3e 0%, #1a0a0a 60%, #2d1a00 100%);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  border: 1px solid rgba(220,38,38,.3);
  text-align: center;
}
.dash-hero img { height: 90px; margin: 0 auto 10px; display: block; }
.dash-hero h2 { font-size: 16px; color: var(--orange); }
.dash-hero p { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; text-align: center;
}
.stat-num { font-size: 28px; font-weight: 900; color: var(--orange); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.quick-btn {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 12px; text-align: center;
  cursor: pointer; text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: all .2s;
}
.quick-btn:hover { transform: translateY(-2px); border-color: var(--blue-light); }
.quick-btn .q-icon { font-size: 32px; }
.quick-btn .q-label { font-size: 12px; font-weight: 700; }

/* ——— LOGIN ——— */
.login-page {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(ellipse at top, #0d1b3e 0%, #0a0a14 50%, #1a0a0a 100%);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo img { width: 180px; filter: drop-shadow(0 4px 20px rgba(249,115,22,.5)); }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.login-title { text-align: center; font-size: 18px; font-weight: 900; margin-bottom: 24px; }
.login-title span { color: var(--orange); }

/* ——— RECIBO ——— */
.recibo-page { padding: 16px; }
.recibo-header {
  text-align: center; padding: 20px;
  background: linear-gradient(135deg, #0d1b3e, #1a0a0a);
  border-radius: var(--radius);
  border: 1px solid var(--red);
  margin-bottom: 16px;
}
.recibo-header img { height: 80px; }
.recibo-header h1 { font-size: 16px; color: var(--orange); margin-top: 8px; }
.recibo-header p { font-size: 11px; color: var(--text-muted); }

.recibo-section { margin-bottom: 14px; }
.recibo-section h3 {
  font-size: 12px; font-weight: 700; color: var(--blue-light);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px; margin-bottom: 10px;
}
.recibo-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
.recibo-row .r-label { color: var(--text-muted); }
.recibo-row .r-value { font-weight: 600; text-align: right; max-width: 60%; }

.servico-tag {
  display: inline-block; background: rgba(59,130,246,.2);
  color: var(--blue-light); border-radius: 12px;
  padding: 4px 10px; font-size: 11px; font-weight: 600;
  margin: 3px;
}

.valor-destaque {
  background: linear-gradient(135deg, rgba(29,78,216,.2), rgba(220,38,38,.2));
  border: 1px solid rgba(249,115,22,.3);
  border-radius: var(--radius-sm); padding: 16px;
  text-align: center; margin: 12px 0;
}
.valor-num { font-size: 28px; font-weight: 900; color: var(--orange); }
.valor-label { font-size: 11px; color: var(--text-muted); }

.assinatura-box {
  border: 1px solid var(--border); border-radius: 8px;
  overflow: hidden; margin: 8px 0;
}
.assinatura-box img { width: 100%; background: #fff; }
.assinatura-legal {
  font-size: 10px; color: #fbbf24; text-align: center;
  padding: 8px; line-height: 1.5;
  background: rgba(249,115,22,.05); border-top: 1px solid rgba(249,115,22,.2);
}

.share-bar {
  position: sticky; bottom: 0; left: 0; right: 0;
  background: var(--bg); border-top: 1px solid var(--border);
  padding: 12px; display: flex; gap: 8px;
}

/* ——— MODAL ——— */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.8);
  z-index: 200; display: flex; align-items: flex-end;
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  background: var(--bg-card); border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px; margin: 0 auto;
  padding: 20px; max-height: 80vh; overflow-y: auto;
  transform: translateY(100%); transition: transform .3s;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 40px; height: 4px; background: var(--border);
  border-radius: 4px; margin: 0 auto 16px;
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* ——— ALERTS ——— */
.alert {
  padding: 12px 14px; border-radius: 8px; font-size: 13px;
  margin-bottom: 12px; display: flex; align-items: center; gap: 10px;
}
.alert-success { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.3); color: var(--success); }
.alert-error { background: rgba(220,38,38,.1); border: 1px solid rgba(220,38,38,.3); color: #f87171; }
.alert-info { background: rgba(59,130,246,.1); border: 1px solid rgba(59,130,246,.3); color: var(--blue-light); }

/* ——— DIVIDER ——— */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ——— SPINNER ——— */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ——— EMPTY STATE ——— */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .e-icon { font-size: 56px; display: block; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ——— CHAR COUNTER ——— */
.char-counter { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 4px; }
.char-counter.warn { color: var(--warning); }
.char-counter.over { color: var(--red); }

/* ——— PRICE FIELDS ——— */
.price-input-wrap { position: relative; }
.price-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-weight: 700; font-size: 14px;
  pointer-events: none;
}
.price-input-wrap .form-control { padding-left: 34px; }

/* ——— ADMIN TABLE ——— */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th {
  text-align: left; padding: 10px 8px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted); font-size: 11px; text-transform: uppercase;
}
.admin-table td { padding: 12px 8px; border-bottom: 1px solid var(--border); }
.admin-table tr:last-child td { border-bottom: none; }

/* ——— UTILITY ——— */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.hidden { display: none !important; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }
.font-bold { font-weight: 700; }
.text-orange { color: var(--orange); }
.text-blue { color: var(--blue-light); }
.text-green { color: var(--success); }
.text-red { color: #f87171; }

/* ——— RESPONSIVE fallback for desktop ——— */
@media (min-width: 481px) {
  body { box-shadow: 0 0 40px rgba(0,0,0,.8); }
  .app-nav { border-radius: 0; }
}

/* ——— PRINT (PDF recibo) ——— */
@media print {
  .app-nav, .app-header, .share-bar, .btn { display: none !important; }
  body { background: #fff; color: #000; max-width: none; }
  .app-content { padding: 0; }
}
