/* ============================================================
   Roiar — components.css (botões, formulários, navbar, footer,
   cards, tabelas, modais, toasts, tabs, paginação, skeletons…)
   ============================================================ */

/* ============ Botões ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .7rem 1.25rem; border-radius: var(--radius-md);
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 600; font-size: var(--text-sm); letter-spacing: .01em;
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease,
              transform .15s ease, box-shadow .15s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--green); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--green-dark); }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: var(--teal-dark); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--title); }
.btn-secondary:hover { border-color: var(--teal); color: var(--teal); }
.btn-ghost { background: transparent; color: var(--teal); }
.btn-ghost:hover { background: var(--teal-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover { background: #FBD9D9; }
.btn-outline-light { background: transparent; border-color: rgba(255,255,255,.4); color: #fff; }
.btn-outline-light:hover { border-color: #fff; background: rgba(255,255,255,.08); }

.btn-sm { padding: .45rem .85rem; font-size: var(--text-xs); }
.btn-lg { padding: .9rem 1.6rem; font-size: var(--text-md); }
.btn-block { width: 100%; }

/* Estado "greyed out" — sempre por último para vencer no cascade.
   Usado no acesso bloqueado à calculadora em /conta. */
.btn:disabled, .btn.is-greyed {
  background: var(--greyed);
  border-color: var(--greyed);
  color: var(--greyed-text);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  filter: grayscale(1);
  opacity: .65;
}

/* ============ Formulários ============ */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field > label { font-size: var(--text-sm); font-weight: 600; color: var(--title); }
.hint { font-size: var(--text-xs); color: var(--body); }
.input, .select, .textarea {
  width: 100%; padding: .65rem .85rem;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); color: var(--title); font-size: var(--text-sm);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(2,145,173,.15); }
.input:disabled, .select:disabled { background: var(--surface-alt); color: var(--greyed-text); cursor: not-allowed; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }
.form-section { font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .08em; color: var(--teal); font-weight: 700; margin: 1.25rem 0 .75rem; }
form .form-section:first-child { margin-top: 0; }
.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-size: var(--text-sm); color: var(--body); margin: .5rem 0 1.25rem; }
.checkbox input { margin-top: .25rem; accent-color: var(--teal); width: 1rem; height: 1rem; flex-shrink: 0; }
.link-btn { display: block; margin: 1rem auto 0; background: none; border: 0; color: var(--teal); font-size: var(--text-sm); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ============ Navbar ============ */
.navbar { position: sticky; top: 0; z-index: var(--z-navbar); background: var(--navy); }
.navbar-inner { display: flex; align-items: center; gap: 2rem; height: var(--navbar-h); }
.navbar-brand { display: inline-flex; align-items: center; gap: .6rem; color: #fff; font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.navbar-brand:hover { text-decoration: none; color: #fff; }
.brand-mark { width: 32px; height: 32px; flex-shrink: 0; }
.brand-logo { display: block; height: 40px; width: auto; }
.footer-brand .brand-logo { height: 32px; }
.navbar-collapse { display: flex; align-items: center; gap: 2rem; margin-left: auto; }
.navbar-nav { display: flex; align-items: center; gap: .25rem; }
.navbar-nav a { color: #CBD5E1; font-size: var(--text-sm); font-weight: 600; padding: .5rem .9rem; border-radius: var(--radius-md); position: relative; }
.navbar-nav a:hover { color: #fff; background: rgba(255,255,255,.07); text-decoration: none; }
.navbar-nav a.active { color: #fff; }
.navbar-nav a.active::after { content: ""; position: absolute; left: .9rem; right: .9rem; bottom: .12rem; height: 2px; background: var(--teal); border-radius: 1px; }
.navbar-toggle { display: none; margin-left: auto; background: none; border: 0; color: #fff; padding: .5rem; cursor: pointer; }

.user-menu { position: relative; }
.user-menu-btn { display: flex; align-items: center; gap: .55rem; background: none; border: 0; cursor: pointer; color: #fff; padding: .35rem .5rem; border-radius: var(--radius-full); }
.user-menu-btn:hover { background: rgba(255,255,255,.08); }
.avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--teal); color: #fff; font-size: var(--text-sm); font-weight: 700; flex-shrink: 0; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.25rem; }
.user-menu-name { font-size: var(--text-sm); font-weight: 600; }
.user-menu-panel { position: absolute; right: 0; top: calc(100% + .5rem); min-width: 235px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: .4rem; z-index: var(--z-dropdown); }
.user-menu-head { padding: .65rem .75rem; border-bottom: 1px solid var(--border); margin-bottom: .4rem; }
.user-menu-head strong { display: block; color: var(--title); font-size: var(--text-sm); }
.user-menu-head span { font-size: var(--text-xs); color: var(--body); word-break: break-all; }
.user-menu-panel a, .user-menu-logout { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .75rem; border-radius: var(--radius-md); color: var(--title); font-size: var(--text-sm); font-weight: 500; background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none; }
.user-menu-panel a:hover, .user-menu-logout:hover { background: var(--surface-alt); text-decoration: none; }
.user-menu-logout { color: var(--danger); }

@media (max-width: 860px) {
  .navbar-toggle { display: block; }
  .navbar-collapse { display: none; position: absolute; top: var(--navbar-h); left: 0; right: 0; background: var(--navy); flex-direction: column; align-items: stretch; gap: 0; padding: .75rem 1.25rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,.1); }
  .navbar.open .navbar-collapse { display: flex; }
  .navbar-nav { flex-direction: column; align-items: stretch; gap: .25rem; }
  .navbar-nav a { padding: .8rem .5rem; }
  .navbar-actions { margin-top: .75rem; display: flex; flex-direction: column; align-items: stretch; gap: .5rem; }
}

/* ============ Footer ============ */
.footer { background: var(--navy); color: #94A3B8; padding-top: 3.5rem; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2.5rem; padding-bottom: 2.5rem; }
.footer h4 { color: #fff; font-size: var(--text-sm); text-transform: uppercase; letter-spacing: .08em; margin-bottom: .9rem; font-weight: 600; }
.footer nav, .footer > .container > div > div:last-child { display: flex; flex-direction: column; gap: .5rem; font-size: var(--text-sm); }
.footer a { color: #94A3B8; }
.footer a:hover { color: var(--teal-light); }
.footer-brand p { margin-top: .9rem; font-size: var(--text-sm); max-width: 34ch; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,.1); padding: 1.25rem 0; font-size: var(--text-xs); color: #7C8BA1; }
@media (max-width: 860px) { .footer-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 520px) { .footer-grid { grid-template-columns: 1fr; } }

/* ============ Cards e badges ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.card-pad { padding: 1.5rem; }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .22rem .65rem; border-radius: var(--radius-full); font-size: var(--text-xs); font-weight: 700; letter-spacing: .02em; }
.badge-green  { background: var(--green-soft); color: var(--green-dark); }
.badge-teal   { background: var(--teal-soft); color: var(--teal-dark); }
.badge-navy   { background: var(--navy); color: #fff; }
.badge-grey   { background: var(--surface-alt); color: var(--body); }
.badge-red    { background: var(--danger-soft); color: var(--danger); }
.badge-orange { background: var(--warning-soft); color: var(--warning); }

/* ============ Tabelas ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--body); font-weight: 600; padding: .65rem .75rem; border-bottom: 1px solid var(--border-strong); white-space: nowrap; }
.table td { padding: .75rem; border-bottom: 1px solid var(--border); color: var(--title); vertical-align: middle; }
.table tbody tr:hover td { background: #FAFBFE; }
.table .actions { display: flex; gap: .4rem; }

/* ============ Modal ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.55); display: grid; place-items: center; padding: 1rem; z-index: var(--z-modal); }
.modal { background: var(--surface); border-radius: var(--radius-xl); width: 100%; max-width: 520px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modal-in .18s ease; }
.modal-lg { max-width: 780px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.35rem; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-header h3 { font-size: var(--text-lg); }
.modal-close { background: none; border: 0; cursor: pointer; color: var(--body); padding: .35rem; border-radius: var(--radius-sm); display: grid; place-items: center; }
.modal-close:hover { color: var(--danger); background: var(--danger-soft); }
.modal-body { padding: 1.35rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: .75rem; padding: 1rem 1.35rem; border-top: 1px solid var(--border); }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

/* ============ Toasts ============ */
.toast-container { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .6rem; z-index: var(--z-toast); max-width: min(92vw, 380px); }
.toast { display: flex; align-items: flex-start; gap: .7rem; background: var(--navy); color: #E2E8F0; padding: .85rem 1rem; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: var(--text-sm); cursor: pointer; animation: toast-in .22s ease; }
.toast svg { flex-shrink: 0; margin-top: .1rem; }
.toast-success svg { color: var(--green); }
.toast-error svg { color: #F87171; }
.toast-warning svg { color: #FBBF24; }
.toast-info svg { color: #38BDF8; }
.toast.hide { opacity: 0; transform: translateY(6px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

/* ============ Tabs e segmented control ============ */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { background: none; border: 0; cursor: pointer; padding: .7rem 1rem; color: var(--body); font-weight: 600; font-size: var(--text-sm); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--title); }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.segmented { display: inline-flex; background: var(--surface-alt); border-radius: var(--radius-full); padding: 4px; gap: 2px; }
.segmented button { border: 0; background: transparent; padding: .45rem 1rem; border-radius: var(--radius-full); font-size: var(--text-sm); font-weight: 600; color: var(--body); cursor: pointer; display: inline-flex; align-items: center; gap: .45rem; }
.segmented button.active { background: var(--surface); color: var(--title); box-shadow: var(--shadow-sm); }

/* ============ Paginação ============ */
.pagination { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-top: 2rem; }
.page-btn { min-width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; padding: 0 .6rem; border-radius: var(--radius-md); border: 1px solid var(--border-strong); background: var(--surface); color: var(--title); font-weight: 600; font-size: var(--text-sm); cursor: pointer; }
.page-btn:hover:not(:disabled) { border-color: var(--teal); color: var(--teal); }
.page-btn:disabled { color: var(--greyed-text); background: var(--surface-alt); cursor: not-allowed; }
.page-info { font-size: var(--text-sm); color: var(--body); padding: 0 .5rem; }

/* ============ Skeletons, spinner, vazio, progresso ============ */
.skeleton { background: var(--surface-alt); border-radius: var(--radius-md); animation: skeleton-pulse 1.4s ease infinite; }
.skeleton-card { height: 360px; border-radius: var(--radius-lg); }
.skeleton-product { height: 340px; border-radius: var(--radius-lg); }
@keyframes skeleton-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; align-items: center; justify-content: center; gap: .75rem; padding: 2.5rem; color: var(--body); font-size: var(--text-sm); }
.empty-state { text-align: center; padding: 3.5rem 1.5rem; }
.empty-state .empty-icon { width: 64px; height: 64px; margin: 0 auto 1rem; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); color: var(--teal); }
.empty-state h3 { margin-bottom: .35rem; }
.empty-state p { max-width: 46ch; margin: 0 auto 1.25rem; }
.progress { height: 8px; background: var(--surface-alt); border-radius: var(--radius-full); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: var(--radius-full); transition: width .3s ease; }

/* ============ Breadcrumbs e listas chave-valor ============ */
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; font-size: var(--text-sm); color: var(--body); margin: 2rem 0 1.25rem; }
.breadcrumbs a { color: var(--body); }
.breadcrumbs a:hover { color: var(--teal); }
.breadcrumbs .sep { color: var(--border-strong); }
.kv-list { display: flex; flex-direction: column; gap: .55rem; margin: 1rem 0; }
.kv-list > div { display: flex; justify-content: space-between; gap: 1rem; font-size: var(--text-sm); }
.kv-list span { color: var(--body); }
.kv-list strong { color: var(--title); text-align: right; }
