/* ==========================================================================
   My List — Custom Table Builder Styles (v4.1.5)
   ========================================================================== */

/* ── Container & Layout ─────────────────────────────────────────────────── */
.ml-table-builder-wrapper {
  max-width: 100%;
  margin: 0 auto;
  font-family: inherit;
  color: #1f2937;
}

.ml-tb-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e5e7eb;
}

@media (min-width: 768px) {
  .ml-tb-header {
    flex-direction: row;
    align-items: center;
  }
}

.ml-tb-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 6px 0;
  color: #111827;
}

.ml-tb-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.ml-tb-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  margin-bottom: 24px;
  overflow: hidden;
}

.ml-tb-card__header {
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  background: #fafafa;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ml-tb-card__title {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.ml-tb-card__hint {
  font-size: 13px;
  color: #6b7280;
}

.ml-tb-card__body {
  padding: 20px;
}

/* ── Notices ─────────────────────────────────────────────────────────────── */
.ml-tb-notice {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.2s ease;
}

.ml-tb-notice--success {
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.ml-tb-notice--error {
  background-color: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.ml-tb-notice--info {
  background-color: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* ── Table List View ─────────────────────────────────────────────────────── */
.ml-tb-sortable-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ml-tb-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  background: #ffffff;
  transition: background 0.15s ease;
}

.ml-tb-item:last-child {
  border-bottom: none;
}

.ml-tb-item:hover {
  background: #f9fafb;
}

@media (min-width: 768px) {
  .ml-tb-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.ml-tb-item__drag-handle {
  cursor: grab;
  font-size: 20px;
  color: #9ca3af;
  padding: 4px 8px;
  user-select: none;
  display: flex;
  align-items: center;
}

.ml-tb-item__drag-handle:active {
  cursor: grabbing;
}

.ml-tb-item__info {
  flex: 1;
  min-width: 0;
}

.ml-tb-item__title {
  font-size: 16px;
  font-weight: 600;
  color: #111827;
  margin: 0 0 6px 0;
  word-break: break-word;
}

.ml-tb-item__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
}

.ml-tb-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.ml-tb-badge--preset {
  background: #e0f2fe;
  color: #0369a1;
}

.ml-tb-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* ── Empty State ─────────────────────────────────────────────────────────── */
.ml-tb-empty-state {
  text-align: center;
  padding: 48px 20px;
}

.ml-tb-empty-state__icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.ml-tb-empty-state h4 {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 6px 0;
}

.ml-tb-empty-state p {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 20px 0;
}

/* ── Editor Layout ───────────────────────────────────────────────────────── */
.ml-tb-editor-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 80px;
}

@media (min-width: 1024px) {
  .ml-tb-editor-layout {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    align-items: flex-start;
  }
}

.ml-tb-form-group {
  margin-bottom: 18px;
}

.ml-tb-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.ml-tb-input,
.ml-tb-textarea,
.ml-tb-select {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  color: #1f2937;
  background: #ffffff;
  transition: border-color 0.15s ease;
}

.ml-tb-input:focus,
.ml-tb-textarea:focus,
.ml-tb-select:focus {
  border-color: #1c82f5;
  outline: none;
  box-shadow: 0 0 0 2px rgba(28, 130, 245, 0.2);
}

.ml-tb-align-group {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

.ml-tb-align-label {
  font-size: 13px;
  color: #6b7280;
}

.ml-tb-btn-group {
  display: inline-flex;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #d1d5db;
}

.ml-tb-btn-choice {
  background: #ffffff;
  border: none;
  border-right: 1px solid #d1d5db;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  color: #4b5563;
  transition: all 0.15s ease;
}

.ml-tb-btn-choice:last-child {
  border-right: none;
}

.ml-tb-btn-choice:hover {
  background: #f3f4f6;
}

.ml-tb-btn-choice.active {
  background: #1c82f5;
  color: #ffffff;
  font-weight: 600;
}

.ml-tb-btn-toggle {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #374151;
}

.ml-tb-btn-toggle.active {
  background: #1c82f5;
  border-color: #1c82f5;
  color: #ffffff;
}

/* ── Presets Grid ────────────────────────────────────────────────────────── */
.ml-tb-presets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
}

.ml-tb-preset-btn {
  background: #ffffff;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ml-tb-preset-btn:hover {
  border-color: #93c5fd;
}

.ml-tb-preset-btn.active {
  border-color: #1c82f5;
  background: #eff6ff;
}

.ml-tb-preset-preview {
  width: 100%;
  height: 28px;
  border-radius: 4px;
  border: 1px solid #d1d5db;
  overflow: hidden;
  display: block;
}

.ml-tb-preset-bar {
  display: block;
  height: 10px;
  width: 100%;
}

.ml-tb-preset-name {
  font-size: 12px;
  font-weight: 500;
  color: #1f2937;
}

/* ── Color Pickers ───────────────────────────────────────────────────────── */
.ml-tb-colors-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f3f4f6;
}

.ml-tb-color-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ml-tb-color-label {
  font-size: 12px;
  font-weight: 500;
  color: #4b5563;
}

.ml-tb-color-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ml-tb-color-input {
  -webkit-appearance: none;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  padding: 1px;
  cursor: pointer;
  background: none;
}

.ml-tb-color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.ml-tb-color-input::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

.ml-tb-hex-input {
  width: 80px;
  font-size: 12px;
  padding: 5px 8px;
  text-transform: uppercase;
}

.ml-tb-header-settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f3f4f6;
}

@media (min-width: 600px) {
  .ml-tb-header-settings-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── Column & Row Builder ────────────────────────────────────────────────── */
.ml-tb-section-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  display: block;
  margin-bottom: 8px;
}

.ml-tb-col-inputs-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.ml-tb-col-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}

.ml-tb-col-num {
  font-size: 12px;
  font-weight: 600;
  color: #6b7280;
  min-width: 50px;
}

.ml-tb-col-input {
  flex: 1;
  font-size: 13px;
  padding: 6px 10px;
}

.ml-tb-rows-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ml-tb-row-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.ml-tb-row-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed #f3f4f6;
}

.ml-tb-row-drag-handle {
  cursor: grab;
  font-size: 16px;
  color: #9ca3af;
  margin-right: 6px;
}

.ml-tb-row-cells-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.ml-tb-cell-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.ml-tb-cell-label {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ml-tb-cell-input {
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
}

/* ── Live Preview Box ────────────────────────────────────────────────────── */
.ml-tb-preview-card {
  position: sticky;
  top: 20px;
}

.ml-tb-live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  animation: mlPulse 2s infinite;
}

@keyframes mlPulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.ml-tb-preview-body {
  background: #f8fafc;
  padding: 24px 16px;
  border-radius: 0 0 10px 10px;
  overflow-x: auto;
}

/* ── Sticky Footer ───────────────────────────────────────────────────────── */
.ml-tb-sticky-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  padding: 14px 24px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 999;
}

/* ── Public Profile Table Styles ─────────────────────────────────────────── */
.ml-custom-tables-section {
  width: 100%;
  margin: 32px 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.ml-custom-table-card {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background-color: #ffffff;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.ml-custom-table-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px 0;
  line-height: 1.35;
  word-break: break-word;
}

.ml-custom-table-desc {
  font-size: 14px;
  margin: 0 0 20px 0;
  line-height: 1.6;
  opacity: 0.85;
  word-break: break-word;
}

/* Responsive Table Wrapper */
.ml-custom-table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  scrollbar-width: thin;
}

.ml-custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
  border: 1px solid #e5e7eb;
  background: transparent;
}

.ml-custom-table th,
.ml-custom-table td {
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  vertical-align: middle;
}

.ml-custom-table th {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.ml-custom-table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.015);
}

.ml-custom-table-empty {
  font-style: italic;
  padding: 24px;
  opacity: 0.65;
}

/* Mobile Adaptation */
@media (max-width: 640px) {
  .ml-custom-table-card {
    padding: 16px;
    border-radius: 8px;
  }
  .ml-custom-table-title {
    font-size: 18px;
  }
  .ml-custom-table th,
  .ml-custom-table td {
    padding: 10px 12px;
    font-size: 13px;
  }
}
