/* ===== Theme Demo Section ===== */
.td-section { padding: 60px 0; min-height: 900px; contain: layout style; }
.td-tabs { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 32px; }
.td-tab {
  padding: 10px 28px; border: 2px solid #e5e7eb; border-radius: 50px;
  background: #fff; color: #6b7280; font-family: inherit; font-size: 0.95rem;
  font-weight: 600; cursor: pointer; transition: all 0.3s ease;
}
.td-tab:hover { border-color: var(--primary-color, #3b82f6); color: var(--primary-color, #3b82f6); }
.td-tab.active {
  background: var(--primary-color, #3b82f6); color: #fff;
  border-color: var(--primary-color, #3b82f6); box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}
.td-layout { display: grid; grid-template-columns: 1fr 410px; gap: 40px; align-items: start; min-height: 820px; }
.td-controls { display: flex; flex-direction: column; gap: 24px; }
.td-preview-col { position: sticky; top: 20px; }

/* Collapsible Panels */
.td-panel {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 16px;
  overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.td-panel-header {
  display: flex; align-items: center; gap: 8px; padding: 16px 20px;
  cursor: pointer; user-select: none; transition: background 0.2s;
  font-size: 15px; font-weight: 600; color: #1f2937;
}
.td-panel-header:hover { background: #f9fafb; }
.td-panel-header::before { content: ''; width: 4px; height: 20px; background: linear-gradient(135deg, #3b82f6, #60a5fa); border-radius: 2px; }
.td-panel-header::after {
  content: '\f078'; font-family: 'Font Awesome 6 Free'; font-weight: 900;
  font-size: 12px; margin-right: auto; transition: transform 0.3s; color: #9ca3af;
}
.td-panel-header.collapsed::after { transform: rotate(-180deg); }
.td-panel-body { max-height: 0; overflow: hidden; transition: max-height 0.4s ease, padding 0.3s ease, opacity 0.3s ease; opacity: 0; padding: 0 20px; }
.td-panel-body.expanded { max-height: 4000px; opacity: 1; padding: 16px 20px 20px; }

/* Color Grid */
.td-color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 14px; }
.td-color-item { display: flex; flex-direction: column; gap: 8px; padding: 14px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px; transition: all 0.3s; }
.td-color-item:hover { border-color: #3b82f6; box-shadow: 0 4px 12px rgba(59,130,246,0.1); }
.td-color-label { font-size: 12px; font-weight: 600; color: #374151; }
.td-color-wrapper { display: flex; flex-direction: column; gap: 6px; }
.td-color-input { width: 100%; height: 40px; border: 2px solid #e5e7eb; border-radius: 8px; cursor: pointer; padding: 2px; transition: border-color 0.3s; }
.td-color-input:hover { border-color: #3b82f6; }
.td-color-preview { width: 100%; height: 6px; border-radius: 3px; border: 1px solid #e5e7eb; }
.td-color-row { display: flex; align-items: center; gap: 8px; }
.td-color-code {
  width: 100%; padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: 6px;
  font-family: 'Courier New', monospace; font-size: 11px; text-align: center;
  text-transform: uppercase; direction: ltr; transition: border-color 0.3s;
}
.td-color-code:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,0.15); }
.td-reset-btn {
  padding: 5px 10px; background: #f3f4f6; border: 1px solid #e5e7eb; border-radius: 5px;
  font-size: 10px; font-family: inherit; color: #6b7280; cursor: pointer;
  white-space: nowrap; transition: all 0.2s;
}
.td-reset-btn:hover { background: #e5e7eb; color: #374151; }

/* Font Grid */
.td-font-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.td-font-item { display: flex; flex-direction: column; gap: 10px; }
.td-font-label { font-size: 13px; font-weight: 600; color: #374151; }
.td-font-select {
  width: 100%; padding: 10px 14px; border: 2px solid #e5e7eb; border-radius: 10px;
  font-size: 13px; transition: border-color 0.3s; background: #fff; color: #1f2937;
}
.td-font-select:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.td-font-preview {
  padding: 14px; background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 10px;
  font-size: 15px; text-align: center; min-height: 48px; display: flex;
  align-items: center; justify-content: center;
}

/* Sections Management */
.td-sections-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.td-sections-title { font-size: 15px; font-weight: 700; color: #1f2937; display: flex; align-items: center; gap: 8px; }
.td-add-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, #10b981, #059669); color: #fff;
  padding: 8px 16px; border: none; border-radius: 8px; font-weight: 600;
  font-size: 12px; cursor: pointer; transition: all 0.3s; font-family: inherit;
}
.td-add-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,185,129,0.3); }
.td-sections-list { display: flex; flex-direction: column; gap: 10px; }
.td-section-item {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px;
  display: flex; align-items: center; gap: 16px; transition: all 0.3s ease; cursor: grab;
}
.td-section-item:hover { border-color: #3b82f6; box-shadow: 0 4px 15px rgba(59,130,246,0.15); }
.td-section-item.dragging { opacity: 0.5; border-color: #3b82f6; background: rgba(59,130,246,0.05); }
.td-section-item.drag-over { border-color: #10b981; border-style: dashed; }
.td-drag-handle { color: #9ca3af; cursor: grab; font-size: 18px; padding: 4px; }
.td-drag-handle:active { cursor: grabbing; }
.td-sec-icon {
  width: 44px; height: 44px; background: linear-gradient(135deg, #3b82f6, #60a5fa);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; flex-shrink: 0;
}
.td-sec-info { flex: 1; min-width: 0; }
.td-sec-name { font-weight: 600; color: #1f2937; font-size: 15px; margin-bottom: 2px; }
.td-sec-type { font-size: 12px; color: #6b7280; }
.td-sec-actions { display: flex; align-items: center; gap: 8px; }
.td-toggle { position: relative; width: 44px; height: 24px; background: #d1d5db; border-radius: 12px; cursor: pointer; transition: all 0.3s ease; }
.td-toggle.active { background: #10b981; }
.td-toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px;
  background: #fff; border-radius: 50%; transition: all 0.3s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.td-toggle.active::after { left: 22px; }
.td-sec-btn {
  width: 36px; height: 36px; border: none; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; font-size: 14px;
}
.td-edit-btn { background: rgba(59,130,246,0.1); color: #3b82f6; }
.td-edit-btn:hover { background: #3b82f6; color: #fff; }
.td-del-btn { background: rgba(239,68,68,0.1); color: #ef4444; }
.td-del-btn:hover { background: #ef4444; color: #fff; }
.td-sections-empty {
  text-align: center; padding: 40px 20px; color: #6b7280;
  border: 2px dashed #d1d5db; border-radius: 12px;
}
.td-sections-empty i { font-size: 36px; margin-bottom: 12px; opacity: 0.5; display: block; }

/* Phone Preview */
.td-preview-header { text-align: center; margin-bottom: 16px; }
.td-preview-title { font-size: 16px; font-weight: 700; color: #1f2937; margin-bottom: 4px; }
.td-preview-subtitle { font-size: 12px; color: #9ca3af; }
.td-lang-tabs { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.td-lang-tab {
  padding: 6px 20px; border: 2px solid #e5e7eb; border-radius: 8px; background: #fff;
  font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.3s; font-family: inherit;
}
.td-lang-tab.active { border-color: #2563eb; color: #fff; background:#2563eb}
.td-device-wrapper { position: relative; display: flex; justify-content: center; }
.td-device-wrapper::before {
  content: ''; position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%);
  width: 200px; height: 20px; background: radial-gradient(ellipse, rgba(0,0,0,0.15) 0%, transparent 70%); border-radius: 50%;
}
.td-mobile-frame {
  width: 380px; height: 780px; overflow: hidden;
  background: linear-gradient(145deg, #1f2937, #111827); border-radius: 52px; padding: 14px;
  box-shadow: 0 50px 100px -20px rgba(0,0,0,0.25), 0 30px 60px -30px rgba(0,0,0,0.3),
              inset 0 1px 0 rgba(255,255,255,0.1), 0 0 0 1px rgba(0,0,0,0.3);
  position: relative;
}
.td-notch {
  position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
  width: 25px; height: 25px; background: #000; border-radius: 50%; z-index: 10;
}
.td-notch::before {
  content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 8px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent); border-radius: 2px;
}
.td-screen {
  width: 100%; height: 100%; border-radius: 38px; overflow: hidden;
  position: relative; background: #ffffff;
}
.td-screen iframe { width: 100%; height: 100%; border: none; }
.td-home-indicator {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  width: 100px; height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px;
}

/* Modals */
.td-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  opacity: 0; visibility: hidden; transition: all 0.3s;
}
.td-modal-overlay.active { opacity: 1; visibility: visible; }
.td-modal {
  background: #fff; border-radius: 16px; width: 90%; max-width: 600px; max-height: 85vh;
  overflow: hidden; transform: scale(0.9) translateY(20px); transition: all 0.3s;
  box-shadow: 0 25px 80px rgba(0,0,0,0.3);
}
.td-modal-overlay.active .td-modal { transform: scale(1) translateY(0); }
.td-modal-head {
  padding: 18px 22px; border-bottom: 1px solid #e5e7eb;
  display: flex; align-items: center; justify-content: space-between;
}
.td-modal-head h3 { font-size: 16px; font-weight: 700; color: #1f2937; display: flex; align-items: center; gap: 8px; margin: 0; }
.td-modal-close {
  width: 32px; height: 32px; border: none; background: #f3f4f6; border-radius: 8px;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: #6b7280; font-size: 16px; transition: all 0.3s;
}
.td-modal-close:hover { background: #ef4444; color: #fff; }
.td-modal-content { padding: 22px; overflow-y: auto; max-height: calc(85vh - 130px); }
.td-modal-foot {
  padding: 14px 22px; border-top: 1px solid #e5e7eb;
  display: flex; gap: 10px; justify-content: flex-end;
}
.td-modal-btn {
  padding: 10px 20px; border: none; border-radius: 8px; font-weight: 600;
  font-size: 13px; cursor: pointer; transition: all 0.3s; font-family: inherit;
}
.td-modal-btn.cancel { background: #f3f4f6; color: #6b7280; }
.td-modal-btn.cancel:hover { background: #e5e7eb; }
.td-modal-btn.save { background: linear-gradient(135deg, #3b82f6, #2563eb); color: #fff; }
.td-modal-btn.save:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59,130,246,0.3); }
.td-modal-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* Available sections grid in add modal */
.td-avail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.td-avail-item {
  padding: 14px; border: 2px solid #e5e7eb; border-radius: 10px;
  cursor: pointer; transition: all 0.3s; text-align: center;
}
.td-avail-item:hover { border-color: #3b82f6; background: rgba(59,130,246,0.05); }
.td-avail-item.selected { border-color: #3b82f6; background: rgba(59,130,246,0.1); }
.td-avail-item i { font-size: 24px; color: #3b82f6; margin-bottom: 6px; display: block; }
.td-avail-item .name { font-weight: 600; color: #1f2937; font-size: 13px; }
.td-avail-item .desc { font-size: 10px; color: #9ca3af; margin-top: 2px; }

/* Edit form fields */
.td-field { margin-bottom: 16px; }
.td-field label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.td-field input[type="text"], .td-field input[type="number"], .td-field input[type="url"],
.td-field textarea, .td-field select {
  width: 100%; padding: 10px 14px; border: 2px solid #e5e7eb; border-radius: 8px;
  font-size: 13px; transition: border-color 0.3s; font-family: inherit;
}
.td-field input:focus, .td-field textarea:focus, .td-field select:focus {
  outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.td-field textarea { resize: vertical; min-height: 70px; }
.td-field-check { display: flex; align-items: center; gap: 10px; padding: 10px 0; }
.td-field-check input[type="checkbox"] { width: 18px; height: 18px; accent-color: #3b82f6; }

/* Demo badge */
.td-demo-badge {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(245,158,11,0.1);
  color: #d97706; padding: 6px 16px; border-radius: 20px; font-size: 12px;
  font-weight: 600; border: 1px solid rgba(245,158,11,0.2); margin-bottom: 24px;
}

/* Responsive */
@media (max-width: 992px) {
.logo {margin-right:10px;}
  .td-section { min-height: auto; }
  .td-layout { display:block;width:100%; min-height: auto; }
  .td-sec-info {min-width:110px;}
  .td-section-item {    flex-wrap: wrap;}
  .td-preview-col { position: static; order: -1;margin-top:20px; }
  .td-mobile-frame { width: 320px; height: 660px; border-radius: 44px; padding: 12px; }
  .td-screen { border-radius: 32px; }
  .td-device-wrapper { margin-bottom: 24px; }
}
@media (max-width: 600px) {
  .td-color-grid { grid-template-columns: 1fr 1fr; }
  .td-font-grid { grid-template-columns: 1fr; }
  .td-mobile-frame { width: 280px; height: 580px; border-radius: 38px; padding: 10px; }
  .td-screen { border-radius: 28px; }
  .td-notch { width: 20px; height: 20px; top: 16px; }
  .td-avail-grid { grid-template-columns: 1fr; }
}
