/* =============================================
   SUPPLIERS PAGE — suppliers.css
   Contains everything the suppliers page needs
   beyond sistema.css: layout, page header,
   table, search, action buttons, empty state,
   modal and form styles.
   ============================================= */

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-color);
  margin: 0;
}

.page-subtitle {
  font-size: 0.875rem;
  color: #999;
  margin: 0.15rem 0 0;
}

body.dark .page-subtitle { color: #888; }

/* ============================================
   PRIMARY BUTTON
   ============================================ */

.admin-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  border-radius: 8px;
  background-color: var(--primary-color);
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.admin-button:hover  { transform: translateY(-1.5px); box-shadow: 0 4px 14px rgba(29,78,216,0.4); background-color: #1554C8; }
.admin-button:active { transform: translateY(0); box-shadow: none; }

/* ============================================
   SECONDARY BUTTON
   ============================================ */

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 1rem;
  background-color: transparent;
  color: var(--text-color);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-secondary:hover { background-color: rgba(0,0,0,0.05); border-color: #ccc; }
body.dark .btn-secondary { border-color: #555; }
body.dark .btn-secondary:hover { background-color: rgba(255,255,255,0.06); border-color: #666; }

/* ============================================
   ADMIN PANEL
   ============================================ */

.admin-panel {
  border-radius: 14px;
  padding: 1.5rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
}

body.dark .admin-panel {
  background: var(--card-bg);
  border-color: var(--border);
}

/* ============================================
   TABLE CONTROLS / SEARCH
   ============================================ */

.table-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.search-field {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search-field .search-icon {
  position: absolute;
  left: 0.7rem;
  font-size: 1.1rem;
  color: #aaa;
  pointer-events: none;
  line-height: 1;
}

.search-field input {
  padding: 0.55rem 0.9rem 0.55rem 2.3rem;
  min-width: 300px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-color);
  font-size: 0.9rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

body.dark .search-field input {
  background-color: #1A182A;
  border-color: var(--border);
  color: var(--text-color);
}

body.dark .search-field input::placeholder { color: #555; }

/* ============================================
   TABLE
   ============================================ */

.admin-table-wrapper { overflow-x: auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table thead { background-color: transparent; }

.admin-table th {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: #999;
  padding: 0.65rem 0.75rem;
  border-bottom: 2px solid #e8e8e8;
  white-space: nowrap;
  text-align: left;
}

body.dark .admin-table th {
  color: #666;
  border-bottom-color: #2e2f30;
}

.admin-table td {
  font-size: 0.875rem;
  padding: 0.7rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid #eeeeee;
}

body.dark .admin-table td { border-bottom-color: #2e2f30; }
.admin-table tbody tr:nth-child(even)           { background-color: rgba(0,0,0,0.022); }
body.dark .admin-table tbody tr:nth-child(even) { background-color: rgba(255,255,255,0.022); }
.admin-table tbody tr:hover { background-color: rgba(29,78,216,0.1) !important; }
body.dark .admin-table tbody tr:hover { background-color: rgba(29,78,216,0.08) !important; }

.col-name  { font-weight: 500; }
.col-phone { white-space: nowrap; }
.wa-icon { font-size: 0.9rem; color: #25D366; vertical-align: middle; }
.wa-link {
  display: inline-flex;
  align-items: center;
  color: #25D366;
  text-decoration: none;
  border-radius: 4px;
  transition: opacity 0.15s ease;
}
.wa-link:hover { opacity: 0.75; }
.wa-link .wa-icon { font-size: 1rem; }

.admin-table th.col-actions,
.admin-table td.col-actions {
  text-align: right;
  white-space: nowrap;
}

/* ============================================
   ICON / ACTION BUTTONS
   ============================================ */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 1rem;
  background-color: transparent;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover { transform: scale(1.08); }

.edit-btn { color: var(--primary-color); }
.edit-btn:hover { background-color: rgba(29,78,216,0.15); }

.delete-btn { color: #cc4c4c; }
.delete-btn:hover { background-color: rgba(204,76,76,0.12); }
body.dark .delete-btn { color: #ef9a9a; }
body.dark .delete-btn:hover { background-color: rgba(239,154,154,0.1); }

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: 3.5rem 2rem;
  color: #999;
}

.empty-state i {
  font-size: 3.2rem;
  margin-bottom: 0.85rem;
  opacity: 0.45;
  display: block;
}

.empty-state p { margin: 0; font-size: 0.95rem; }
.empty-hint { font-size: 0.85rem; color: #bbb; margin-top: 0.4rem !important; }

body.dark .empty-state { color: #666; }
body.dark .empty-hint  { color: #555; }

/* ============================================
   TEXT HELPERS
   ============================================ */

.text-muted { color: #bbb; font-size: inherit; }
body.dark .text-muted { color: #555; }

/* ============================================
   TOAST NOTIFICATION
   ============================================ */

.app-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.75rem 1.15rem;
  border-radius: 10px;
  background: var(--sidebar-color);
  color: var(--text-color);
  border-left: 4px solid var(--primary-color);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  font-size: 0.875rem;
  font-weight: 500;
  max-width: 340px;
  transition: opacity 0.25s ease, transform 0.25s ease;
  animation: toastSlideIn 0.25s ease-out;
}

.app-toast.app-toast-error { border-left-color: #cc4c4c; }

.app-toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
}

.app-toast-icon      { font-size: 1.1rem; color: var(--primary-color); flex-shrink: 0; }
.app-toast-error-icon { color: #cc4c4c; }

@keyframes toastSlideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);   opacity: 1; }
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden { display: none !important; }
body.modal-open { overflow: hidden; }

.input-error {
  border-color: #cc4c4c !important;
  box-shadow: 0 0 0 3px rgba(204,76,76,0.12) !important;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60%  { transform: translateX(-5px); }
  40%,80%  { transform: translateX(5px); }
}

/* ============================================
   SUPPLIER MODAL
   ============================================ */

.supplier-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}

.supplier-modal-overlay.hidden { display: none; }

.supplier-modal {
  width: min(100%, 580px);
  background: var(--sidebar-color);
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.25);
  overflow: hidden;
  animation: supplierSlideIn 0.22s ease-out;
  display: flex;
  flex-direction: column;
  max-height: 94vh;
}

@keyframes supplierSlideIn {
  from { transform: scale(0.96) translateY(-16px); opacity: 0; }
  to   { transform: scale(1)    translateY(0);     opacity: 1; }
}

/* Modal header */
.supplier-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.15rem 1.35rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(29,78,216,0.08) 0%, rgba(29,78,216,0.02) 100%);
}

.supplier-modal-header h2 {
  margin: 0 0 0.1rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-color);
}

.supplier-modal-subtitle {
  margin: 0;
  font-size: 0.78rem;
  color: #999;
}

/* Close button */
.modal-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background-color: transparent;
  color: var(--text-color);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
  flex-shrink: 0;
}

.modal-close-btn:hover { background-color: rgba(0,0,0,0.07); }

/* Modal body */
.supplier-modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  flex: 1;
}

/* Modal footer */
.supplier-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ============================================
   FORM SECTIONS & FIELDS
   ============================================ */

.form-section { margin-bottom: 1.25rem; }

.form-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #999;
  margin-bottom: 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.form-row {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cep-row { grid-template-columns: minmax(0, 260px); }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-color);
}

.field-group .required { color: var(--primary-color); }

.field-group input,
.field-group select,
.field-group textarea {
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-color);
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

.field-group input:focus,
.field-group select:focus,
.field-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(29,78,216,0.12);
}

body.dark .field-group input,
body.dark .field-group select,
body.dark .field-group textarea {
  background-color: #2a2b2c;
  border-color: #3a3b3c;
  color: var(--text-color);
}

.field-group textarea {
  resize: vertical;
  min-height: 80px;
}

.cep-wrapper {
  display: flex;
  gap: 0.4rem;
  align-items: stretch;
}

.cep-lookup-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-color);
  font-size: 0.82rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.18s ease, border-color 0.18s ease;
  flex-shrink: 0;
}

.cep-lookup-btn:hover {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

.cep-status {
  font-size: 0.75rem;
  margin-top: 0.2rem;
}

.cep-status.error { color: #cc4c4c; }
.cep-status.success { color: #2e7d32; }

body.dark .cep-lookup-btn {
  background-color: #2a2b2c;
  border-color: #3a3b3c;
  color: var(--text-color);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 600px) {
  .page-header { flex-direction: column; align-items: flex-start; }
  .search-field input { min-width: 0; width: 100%; }
  .form-row.cols-2 { grid-template-columns: 1fr; }
  .form-row.cols-3 { grid-template-columns: 1fr; }
  .supplier-modal { max-height: 100vh; border-radius: 0; }
}
