/* EVOX Design Freeze Phase 3 — Forms, Tables & Admin Workflows */
:root{
  --evox-control-h:44px;
  --evox-control-h-lg:50px;
  --evox-control-radius:12px;
  --evox-table-min:760px;
  --evox-admin-sticky-top:calc(var(--evox-header-h,72px) + 12px);
}

/* Forms */
.evox-form,
form.evox-enhanced-form{
  display:grid;
  gap:18px;
}

.evox-form-section{
  padding:clamp(16px,2vw,24px);
  background:var(--evox-surface,#fff);
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:16px;
  box-shadow:var(--evox-shadow-sm,0 1px 2px rgba(16,24,40,.05));
}

.evox-form-section__header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}

.evox-form-section__title{
  margin:0;
  color:var(--evox-text,#172033);
  font-size:1.05rem;
  font-weight:800;
}

.evox-form-section__description{
  margin:5px 0 0;
  color:var(--evox-text-muted,#667085);
  font-size:.88rem;
  line-height:1.8;
}

.evox-form-grid{
  display:grid;
  grid-template-columns:repeat(12,minmax(0,1fr));
  gap:16px;
}

.evox-field{grid-column:span 6;min-width:0}
.evox-field--full{grid-column:1/-1}
.evox-field--third{grid-column:span 4}
.evox-field--quarter{grid-column:span 3}

.evox-field label,
.evox-field__label{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin-bottom:7px;
  color:var(--evox-text,#172033);
  font-size:.88rem;
  font-weight:700;
}

.evox-required-mark{
  color:var(--evox-danger,#d92d20);
  font-weight:800;
}

.evox-field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.evox-field select,
.evox-field textarea,
.evox-control,
form.evox-enhanced-form input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]),
form.evox-enhanced-form select,
form.evox-enhanced-form textarea{
  width:100%;
  min-height:var(--evox-control-h);
  padding:10px 12px;
  border:1px solid var(--evox-border-strong,#cfd7e3);
  border-radius:var(--evox-control-radius);
  background:var(--evox-surface,#fff);
  color:var(--evox-text,#172033);
  font:inherit;
  line-height:1.5;
  transition:border-color 150ms ease,box-shadow 150ms ease,background 150ms ease;
}

.evox-field textarea,
form.evox-enhanced-form textarea{
  min-height:108px;
  resize:vertical;
}

.evox-field input:focus,
.evox-field select:focus,
.evox-field textarea:focus,
form.evox-enhanced-form input:focus,
form.evox-enhanced-form select:focus,
form.evox-enhanced-form textarea:focus{
  border-color:var(--evox-primary,#163a5f);
  outline:0;
  box-shadow:0 0 0 3px rgba(22,58,95,.13);
}

.evox-field input[disabled],
.evox-field select[disabled],
.evox-field textarea[disabled],
form.evox-enhanced-form :is(input,select,textarea)[disabled]{
  cursor:not-allowed;
  background:var(--evox-surface-muted,#f4f6f8);
  color:var(--evox-text-subtle,#98a2b3);
}

.evox-field__hint,
.evox-control-hint{
  display:block;
  margin-top:6px;
  color:var(--evox-text-muted,#667085);
  font-size:.78rem;
  line-height:1.7;
}

.evox-field__error,
.evox-control-error{
  display:none;
  margin-top:6px;
  color:var(--evox-danger,#d92d20);
  font-size:.78rem;
  line-height:1.7;
}

.evox-field.is-invalid .evox-field__error,
.evox-field [aria-invalid="true"] ~ .evox-field__error,
.evox-control-error.is-visible{display:block}

.evox-field.is-invalid input,
.evox-field.is-invalid select,
.evox-field.is-invalid textarea,
[aria-invalid="true"]{
  border-color:var(--evox-danger,#d92d20)!important;
  box-shadow:0 0 0 3px rgba(217,45,32,.10)!important;
}

.evox-check-group,
.evox-radio-group{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px 18px;
}

.evox-check,
.evox-radio{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:40px;
  cursor:pointer;
}

.evox-check input,
.evox-radio input{
  width:18px;
  height:18px;
  accent-color:var(--evox-primary,#163a5f);
}

.evox-file-control{
  display:grid;
  place-items:center;
  min-height:122px;
  padding:18px;
  border:1px dashed var(--evox-border-strong,#cfd7e3);
  border-radius:14px;
  background:var(--evox-surface-soft,#f8fafc);
  text-align:center;
}

.evox-file-control:hover{
  border-color:var(--evox-primary,#163a5f);
  background:var(--evox-primary-soft,#eaf1f8);
}

.evox-form-actions{
  position:sticky;
  bottom:0;
  z-index:20;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:10px;
  margin-top:8px;
  padding:12px 0 calc(12px + env(safe-area-inset-bottom));
  background:linear-gradient(to top,var(--evox-page-bg,#f7f9fc) 70%,transparent);
}

/* Filters and toolbars */
.evox-admin-toolbar{
  position:sticky;
  top:var(--evox-admin-sticky-top);
  z-index:30;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:16px;
  padding:12px;
  background:rgba(255,255,255,.95);
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:14px;
  box-shadow:var(--evox-shadow-sm,0 1px 2px rgba(16,24,40,.05));
  backdrop-filter:blur(14px);
}

.evox-toolbar__primary,
.evox-toolbar__secondary{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
}

.evox-search-box{
  position:relative;
  min-width:min(340px,100%);
}

.evox-search-box input{
  width:100%;
  min-height:42px;
  padding-inline:38px 12px;
  border:1px solid var(--evox-border-strong,#cfd7e3);
  border-radius:11px;
  background:var(--evox-surface,#fff);
}

.evox-search-box::before{
  content:"⌕";
  position:absolute;
  right:13px;
  top:50%;
  transform:translateY(-50%);
  color:var(--evox-text-muted,#667085);
  pointer-events:none;
}

.evox-filter-panel{
  display:none;
  margin-bottom:16px;
  padding:16px;
  background:var(--evox-surface,#fff);
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:14px;
}

.evox-filter-panel.is-open{display:block}

.evox-active-filters{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin:0 0 14px;
}

.evox-filter-chip{
  display:inline-flex;
  align-items:center;
  gap:7px;
  min-height:34px;
  padding:5px 10px;
  border-radius:999px;
  background:var(--evox-primary-soft,#eaf1f8);
  color:var(--evox-primary,#163a5f);
  font-size:.8rem;
  font-weight:700;
}

/* Tables */
.evox-table-card{
  min-width:0;
  overflow:hidden;
  background:var(--evox-surface,#fff);
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:16px;
  box-shadow:var(--evox-shadow-sm,0 1px 2px rgba(16,24,40,.05));
}

.evox-table-card__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px;
  border-bottom:1px solid var(--evox-border,#dfe5ec);
}

.evox-table-scroll{
  width:100%;
  overflow:auto;
  overscroll-behavior-inline:contain;
  scrollbar-width:thin;
}

.evox-table-scroll table,
table.evox-data-table{
  width:100%;
  min-width:var(--evox-table-min);
  border-collapse:separate;
  border-spacing:0;
  background:var(--evox-surface,#fff);
}

.evox-table-scroll th,
.evox-table-scroll td,
table.evox-data-table th,
table.evox-data-table td{
  padding:12px 14px;
  border-bottom:1px solid var(--evox-border,#e4e8ef);
  text-align:right;
  vertical-align:middle;
  white-space:nowrap;
}

.evox-table-scroll th,
table.evox-data-table th{
  position:sticky;
  top:0;
  z-index:2;
  background:var(--evox-surface-strong,#f0f3f7);
  color:var(--evox-text-muted,#667085);
  font-size:.78rem;
  font-weight:800;
}

.evox-table-scroll tbody tr:hover,
table.evox-data-table tbody tr:hover{
  background:var(--evox-primary-soft,#f1f6fb);
}

.evox-table-scroll tbody tr:last-child td,
table.evox-data-table tbody tr:last-child td{
  border-bottom:0;
}

.evox-row-actions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:6px;
}

.evox-row-action{
  min-width:36px;
  min-height:36px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:9px;
  background:var(--evox-surface,#fff);
  color:var(--evox-text,#172033);
  cursor:pointer;
}

.evox-row-action:hover{
  border-color:var(--evox-primary,#163a5f);
  color:var(--evox-primary,#163a5f);
}

.evox-table-card__footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 16px;
  border-top:1px solid var(--evox-border,#dfe5ec);
}

.evox-pagination{
  display:flex;
  align-items:center;
  gap:5px;
}

.evox-page-button{
  min-width:38px;
  min-height:38px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:9px;
  background:var(--evox-surface,#fff);
  color:var(--evox-text,#172033);
  text-decoration:none;
  cursor:pointer;
}

.evox-page-button[aria-current="page"]{
  border-color:var(--evox-primary,#163a5f);
  background:var(--evox-primary,#163a5f);
  color:#fff;
}

/* Statuses */
.evox-state{
  display:grid;
  place-items:center;
  min-height:220px;
  padding:28px;
  text-align:center;
}

.evox-state__icon{
  width:54px;
  height:54px;
  display:grid;
  place-items:center;
  margin-bottom:12px;
  border-radius:16px;
  background:var(--evox-primary-soft,#eaf1f8);
  color:var(--evox-primary,#163a5f);
  font-size:1.25rem;
  font-weight:900;
}

.evox-state__title{
  margin:0;
  color:var(--evox-text,#172033);
  font-size:1.05rem;
  font-weight:800;
}

.evox-state__message{
  max-width:520px;
  margin:7px auto 0;
  color:var(--evox-text-muted,#667085);
  font-size:.88rem;
  line-height:1.8;
}

.evox-loading-row td{padding:16px!important}

.evox-skeleton-line{
  height:12px;
  border-radius:999px;
  background:linear-gradient(90deg,#edf1f5 25%,#f7f9fb 37%,#edf1f5 63%);
  background-size:400% 100%;
  animation:evox-skeleton 1.35s ease infinite;
}

@keyframes evox-skeleton{
  0%{background-position:100% 50%}
  100%{background-position:0 50%}
}

.evox-inline-alert{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:12px 14px;
  border:1px solid var(--evox-border,#dfe5ec);
  border-radius:12px;
  background:var(--evox-surface,#fff);
  font-size:.86rem;
  line-height:1.8;
}

.evox-inline-alert--error{
  border-color:rgba(217,45,32,.24);
  background:rgba(217,45,32,.05);
  color:#8a1c15;
}

.evox-inline-alert--success{
  border-color:rgba(3,152,85,.24);
  background:rgba(3,152,85,.05);
  color:#027a48;
}

/* Mobile table cards */
@media (max-width:760px){
  .evox-form-grid{grid-template-columns:minmax(0,1fr)}
  .evox-field,
  .evox-field--full,
  .evox-field--third,
  .evox-field--quarter{grid-column:1/-1}

  .evox-admin-toolbar{
    position:relative;
    top:auto;
    align-items:stretch;
    flex-direction:column;
  }

  .evox-toolbar__primary,
  .evox-toolbar__secondary{
    width:100%;
  }

  .evox-search-box{width:100%;min-width:0}

  .evox-form-actions{
    margin-inline:-8px;
    padding-inline:8px;
  }

  .evox-form-actions .evox-btn,
  .evox-form-actions button,
  .evox-form-actions input[type="submit"]{
    flex:1 1 calc(50% - 5px);
  }

  .evox-table-card[data-evox-mobile-cards="true"] .evox-table-scroll{
    overflow:visible;
  }

  .evox-table-card[data-evox-mobile-cards="true"] table{
    min-width:0;
  }

  .evox-table-card[data-evox-mobile-cards="true"] thead{
    position:absolute;
    width:1px;
    height:1px;
    overflow:hidden;
    clip:rect(0 0 0 0);
    white-space:nowrap;
  }

  .evox-table-card[data-evox-mobile-cards="true"] tbody,
  .evox-table-card[data-evox-mobile-cards="true"] tr,
  .evox-table-card[data-evox-mobile-cards="true"] td{
    display:block;
    width:100%;
  }

  .evox-table-card[data-evox-mobile-cards="true"] tr{
    margin:10px;
    width:calc(100% - 20px);
    padding:8px 12px;
    border:1px solid var(--evox-border,#dfe5ec);
    border-radius:13px;
    background:var(--evox-surface,#fff);
  }

  .evox-table-card[data-evox-mobile-cards="true"] td{
    display:grid;
    grid-template-columns:minmax(100px,38%) minmax(0,1fr);
    gap:10px;
    padding:9px 0;
    border-bottom:1px dashed var(--evox-border,#e4e8ef);
    white-space:normal;
  }

  .evox-table-card[data-evox-mobile-cards="true"] td:last-child{border-bottom:0}

  .evox-table-card[data-evox-mobile-cards="true"] td::before{
    content:attr(data-label);
    color:var(--evox-text-muted,#667085);
    font-size:.76rem;
    font-weight:800;
  }

  .evox-table-card__footer{
    align-items:stretch;
    flex-direction:column;
  }

  .evox-pagination{justify-content:center}
}

@media (max-width:480px){
  .evox-form-actions .evox-btn,
  .evox-form-actions button,
  .evox-form-actions input[type="submit"]{
    flex-basis:100%;
  }
}

@media (prefers-reduced-motion:reduce){
  .evox-skeleton-line{animation:none}
}
