/**
 * Global form field styling - matches Edit Customer (crm-field) design
 * Neutral slate grey, professional look. Applied everywhere in the app.
 * NO WHITE: admin area must not show white backgrounds.
 */

/* Nuclear: any .bg-white in admin area becomes slate (loaded last, wins over Tailwind) */
main#admin-page-content .bg-white,
main#admin-page-content [class*="bg-white"],
#admin-page-content .bg-white,
#admin-page-content [class*="bg-white"] {
  background-color: #f1f5f9 !important;
  background: #f1f5f9 !important;
}

/* All text inputs, selects, textareas - same as Edit Customer crm-field */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
  min-height: 44px !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.75rem !important;
  background: #f1f5f9 !important;
  color: #0f172a !important;
  font-size: 0.875rem !important;
  line-height: 1.25rem !important;
  padding: 0.625rem 0.875rem !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04) !important;
  transition: border-color 0.15s ease, box-shadow 0.15s ease !important;
}

/* Textarea: taller min-height, allow resize */
textarea {
  min-height: 88px !important;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8 !important;
}

/* Focus - neutral slate grey, no bright ring */
input:focus,
select:focus,
textarea:focus {
  outline: none !important;
  border-color: #94a3b8 !important;
  box-shadow: 0 0 0 1px #94a3b8 !important;
  --tw-ring-color: transparent !important;
  --tw-ring-shadow: none !important;
}

/* Hover */
input:hover,
select:hover,
textarea:hover {
  border-color: #94a3b8 !important;
}

/* .crm-field and .crm-select classes */
.crm-field,
.crm-select {
  border: 1px solid #cbd5e1 !important;
  border-radius: 0.75rem !important;
  background: #f1f5f9 !important;
}

.crm-field:focus,
.crm-select:focus {
  outline: none !important;
  border-color: #94a3b8 !important;
  box-shadow: 0 0 0 1px #94a3b8 !important;
}

/* ============================================
   Universal Admin Header - single row layout
   [hamburger][logo][search ----][actions][profile]
   Used across all admin pages via x-admin.header
   ============================================ */
/* Main content area: no white, match page background */
main#admin-page-content {
  background: #f1f5f9 !important;
}

/* Header: no white – slate-200 so it reads clearly as grey */

.admin-header-universal,
#admin-header {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  width: 100% !important;
  min-width: 0;
  height: 4rem;
  flex: 0 0 4rem;
  flex-shrink: 0;
  flex-wrap: nowrap;
  background: #e2e8f0;
  border-bottom: 1px solid #cbd5e1;
  padding: 0 1rem;
  gap: 0.75rem;
  box-sizing: border-box;
}
@media (min-width: 640px) {
  .admin-header-universal, #admin-header { padding: 0 1.5rem; gap: 1rem; }
}
@media (min-width: 1024px) {
  .admin-header-universal, #admin-header { padding: 0 2rem; }
}

.admin-header-inner {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.admin-header-hamburger {
  padding: 0.5rem;
  margin-left: -0.5rem;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-header-hamburger:hover { color: #475569; background: #f1f5f9; }

.admin-header-logo-wrap {
  flex-shrink: 0;
  margin-right: 0.25rem;
}
.admin-header-logo-wrap .admin-header-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.admin-header-logo-img {
  height: 2.25rem;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}
.admin-header-logo-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: #0f172a;
}

/* Search - flex-1, no overlap with icon */
#admin-header-search,
.admin-header-search {
  flex: 1;
  min-width: 0;
  max-width: 32rem;
  position: relative;
}
.admin-header-search-wrap {
  display: flex;
  align-items: center;
  min-height: 40px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  overflow: hidden;
}
.admin-header-search-wrap:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.2);
}
.admin-header-search-icon {
  flex-shrink: 0;
  padding: 0 0.75rem;
  display: flex;
  align-items: center;
  color: #94a3b8;
}
.admin-header-search-input {
  flex: 1;
  min-width: 0;
  border: none !important;
  background: transparent !important;
  padding: 0.5rem 0.75rem 0.5rem 0 !important;
  box-shadow: none !important;
  min-height: 0 !important;
  font-size: 0.875rem !important;
  outline: none !important;
}
.admin-header-search-loader {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
}
.admin-header-search-results {
  background: #f1f5f9;
  position: absolute;
  margin-top: 0.25rem;
  width: 100%;
  max-width: 32rem;
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 50;
  max-height: 24rem;
  overflow-y: auto;
}
.admin-header-search-empty {
  position: absolute;
  margin-top: 0.25rem;
  width: 100%;
  max-width: 32rem;
  background: #f1f5f9;
  border-radius: 0.75rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  border: 1px solid rgba(0,0,0,0.05);
  z-index: 50;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.875rem;
  color: #64748b;
}

/* Actions row - profile + icons in one line, pushed to right */
#admin-header-actions,
.admin-header-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin-left: auto;
  gap: 0.25rem;
  flex-wrap: nowrap;
}
@media (min-width: 640px) {
  #admin-header-actions, .admin-header-actions { gap: 0.5rem; }
}

.admin-header-action-item { position: relative; }
.admin-header-action-btn {
  padding: 0.5rem;
  color: #64748b;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
}
.admin-header-action-btn:hover { color: #475569; background: #f1f5f9; }
.admin-header-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  background: #f1f5f9;
  color: #475569;
}
.admin-header-action-icon:hover { background: #e2e8f0; }
.admin-header-action-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: #475569;
  text-decoration: none;
  border-radius: 0.5rem;
}
.admin-header-action-link:hover { color: #0f172a; background: #f1f5f9; }
.admin-header-action-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  color: #64748b;
  border-radius: 0.5rem;
  flex-shrink: 0;
  position: relative;
  text-decoration: none;
}
.admin-header-action-icon-btn:hover { color: #475569; background: #f1f5f9; }
.admin-header-action-icon-btn-badge { position: relative; }
.admin-header-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 1.125rem;
  height: 1.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.25rem;
  font-size: 0.625rem;
  font-weight: 700;
  color: #fff;
  border-radius: 9999px;
}
.admin-header-badge-amber { background: #f59e0b; }
.admin-header-badge-emerald { background: #10b981; }
.admin-header-badge-red { background: #ef4444; }

.admin-header-dropdown {
  position: absolute;
  right: 0;
  margin-top: 0.5rem;
  width: 14rem;
  background: #f1f5f9;
  border-radius: 0.5rem;
  box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  border: 1px solid #f1f5f9;
  padding: 0.25rem 0;
  z-index: 50;
}
.admin-header-dropdown-notif { width: 20rem; }
.admin-header-dropdown-profile { width: 12rem; }

/* Profile in header - aligned with actions */
.admin-header-profile { margin-left: 0.25rem; }
.admin-header-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem;
  background: transparent;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
}
.admin-header-profile-btn:hover { background: #f1f5f9; }
.admin-header-profile-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: #6366f1;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-header-profile-chevron {
  width: 1rem;
  height: 1rem;
  color: #94a3b8;
}
@media (max-width: 639px) {
  .admin-header-profile-chevron { display: none; }
}

/* ============================================
   Table toolbars (Export, Search, per-page, Filters)
   Prevent controls from touching the border line above
   ============================================ */
.admin-table-toolbar {
  padding-top: 1.25rem !important;
  padding-bottom: 1.25rem !important;
  background: transparent !important;
  background-color: transparent !important;
}

/* ============================================
   Global: white content boxes – restore padding (bedding) on all sides
   Applies to all admin white cards/panels so content has space from edges.
   Multiple selectors ensure we match regardless of class order.
   ============================================ */
#admin-page-content .bg-white.rounded-xl,
#admin-page-content .rounded-xl.bg-white,
main#admin-page-content .bg-white.rounded-xl,
.bg-white.rounded-xl.shadow-sm.border,
.bg-white.rounded-xl.border,
#admin-page-content [class*="bg-white"][class*="rounded-xl"] {
  padding: 1.5rem !important;
  box-sizing: border-box !important;
}

/* ============================================
   Table cards: no white background (transparent, no box)
   Use class admin-table-no-bg on table wrappers
   ============================================ */
.admin-table-no-bg {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
}

/* Tables: no white anywhere – wrapper, table, thead, tbody, th, td, rows (single source for all table pages) */
#admin-page-content .admin-table-no-bg,
#admin-page-content .admin-table-no-bg .overflow-x-auto,
#admin-page-content .admin-table-no-bg table,
#admin-page-content .admin-table-no-bg thead,
#admin-page-content .admin-table-no-bg thead tr,
#admin-page-content .admin-table-no-bg thead th,
#admin-page-content .admin-table-no-bg tbody,
#admin-page-content .admin-table-no-bg tbody tr,
#admin-page-content .admin-table-no-bg tbody td {
  background: transparent !important;
  background-color: transparent !important;
}
#admin-page-content .admin-table-no-bg tbody tr:hover {
  background: rgba(241, 245, 249, 0.6) !important;
  background-color: rgba(241, 245, 249, 0.6) !important;
}
#admin-page-content .admin-table-no-bg tbody tr:hover td {
  background: transparent !important;
}

/* Toolbar inside table block: buttons and inputs must not be white */
#admin-page-content .admin-table-toolbar input,
#admin-page-content .admin-table-toolbar select,
#admin-page-content .admin-table-toolbar .bg-white {
  background: #f1f5f9 !important;
  background-color: #f1f5f9 !important;
}
#admin-page-content .admin-table-toolbar a.bg-white,
#admin-page-content .admin-table-toolbar button.bg-white {
  background: #f1f5f9 !important;
  background-color: #f1f5f9 !important;
}

/* All tables in admin content: force transparent so no white shows (single source for table design) */
#admin-page-content table thead,
#admin-page-content table thead tr,
#admin-page-content table thead th,
#admin-page-content table tbody,
#admin-page-content table tbody tr,
#admin-page-content table tbody td {
  background: transparent !important;
  background-color: transparent !important;
}
#admin-page-content table tbody tr:hover td {
  background: transparent !important;
}
#admin-page-content table tbody tr:hover {
  background: rgba(241, 245, 249, 0.6) !important;
  background-color: rgba(241, 245, 249, 0.6) !important;
}

/* Any parent wrapper of table that has bg-white – force no white */
#admin-page-content div.bg-white.rounded-xl.shadow-sm.border,
#admin-page-content div.rounded-xl.shadow-sm.border.border-slate-200.p-4 {
  background: #f1f5f9 !important;
  background-color: #f1f5f9 !important;
  box-shadow: none !important;
}
