/* WP Flow - Admin Styles */

/* Button styling (teal theme) */
.wp-flow-button-primary,
.button-primary,
input[type=submit][name^=submit],
.wrap form input[type=submit],
.wrap form .button-primary {
  background-color: #008080 !important;
  color: #fff !important;
  font-weight: bold !important;
  border: none !important;
  box-shadow: none !important;
}
.wp-flow-button-primary:hover,
.button-primary:hover,
input[type=submit][name^=submit]:hover,
.wrap form input[type=submit]:hover,
.wrap form .button-primary:hover {
  background-color: #006666 !important;
  color: #fff !important;
}

/* "Add New" page title button alignment */
a.page-title-action.button.button-primary {
  margin-top: 10px !important;
  display: inline-block;
}

/* Switches (global within WP Flow pages) */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
  border-radius: 24px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}
input:checked + .slider {
  background: linear-gradient(135deg, #008080, #20b2aa);
}
input:checked + .slider:before {
  transform: translateX(26px);
}

/* Notices */
.notice.inline {
  margin: 5px 0;
  padding: 8px 12px;
}
.notice-success.inline {
  border-left-color: #00a32a;
  background: #f0fff4;
}
.notice-error.inline {
  border-left-color: #d63638;
  background: #ffeaea;
}

/* Inputs */
.setting-select,
.regular-text {
  transition: border-color 0.3s ease;
}
.setting-select:focus,
.regular-text:focus {
  border-color: #008080;
  box-shadow: 0 0 0 1px rgba(0, 128, 128, 0.1);
}

/* ============================================
   SIDEBAR - RESPONSIVE DESIGN
   ============================================ */

/* Sidebar Container - Desktop */
#wpflow-node-sidebar {
  position: fixed;
  top: 32px;
  right: -400px;
  width: 400px;
  height: calc(100vh - 32px);
  background: #fff;
  border-left: 1px solid #ddd;
  box-shadow: -2px 0 8px rgba(0,0,0,0.1);
  z-index: 9999;
  transition: right 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

#wpflow-node-sidebar.active {
  right: 0;
}

.sidebar-header {
  position: sticky;
  top: 0;
  background: #008080;
  color: white;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #006666;
  z-index: 10;
}

.sidebar-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.sidebar-close {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.sidebar-close:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar-content {
  padding: 20px;
}

.sidebar-section {
  margin-bottom: 25px;
}

.sidebar-section h4 {
  margin: 0 0 15px 0;
  color: #2c3e50;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 2px solid #008080;
  padding-bottom: 8px;
}

/* Opções no sidebar */
.sidebar-option {
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s;
}

.sidebar-option:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.sidebar-option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sidebar-option-number {
  font-weight: 600;
  color: #008080;
  font-size: 14px;
}

.sidebar-option-controls {
  display: flex;
  gap: 8px;
}

.sidebar-option label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #555;
}

.sidebar-option input[type="text"],
.sidebar-option textarea,
.sidebar-option select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  margin-bottom: 8px;
}

.sidebar-option textarea {
  min-height: 60px;
  resize: vertical;
}

/* Tags no sidebar */
.sidebar-tags {
  background: #f0f8ff;
  padding: 15px;
  border-radius: 6px;
  margin-top: 20px;
  border: 1px solid #cce7ff;
}

.sidebar-tags h4 {
  margin: 0 0 12px 0;
  color: #0277bd;
  font-size: 13px;
  border-bottom: 1px solid #90caf9;
}

.sidebar-tags .tag-item {
  display: inline-block;
  margin: 4px;
  padding: 6px 12px;
  background: #e1f5fe;
  border: 1px solid #0288d1;
  border-radius: 15px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.sidebar-tags .tag-item:hover {
  background: #0288d1;
  color: white;
  transform: translateY(-1px);
}

/* Campos de post_create no sidebar */
.sidebar-fields-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
  background: #fafafa;
}

.sidebar-field-item {
  background: white;
  padding: 10px;
  margin-bottom: 8px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}

.sidebar-field-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.sidebar-field-config {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #ddd;
  display: none;
}

.sidebar-field-config.active {
  display: block;
}

/* Botões no sidebar */
.sidebar-button {
  width: 100%;
  padding: 10px;
  background: #008080;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.sidebar-button:hover {
  background: #006666;
}

.sidebar-button-secondary {
  background: #f0f0f1;
  color: #333;
  border: 1px solid #ddd;
}

.sidebar-button-secondary:hover {
  background: #e0e0e1;
}

.sidebar-button-danger {
  background: #dc3232;
  font-size: 12px;
  padding: 6px 10px;
}

.sidebar-button-danger:hover {
  background: #c02828;
}

/* Botão Salvar Opções */
.sidebar-button-primary {
  background: #2196F3;
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
  width: 100%;
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
}

.sidebar-button-primary:hover {
  background: #1976D2;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(33, 150, 243, 0.3);
}

.sidebar-button-primary:disabled {
  background: #90CAF9;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.save-options-button {
  margin-bottom: 15px;
}

/* Notificação de salvamento */
.wpflow-save-notification {
  position: fixed;
  top: 32px;
  right: 20px;
  background: #4CAF50;
  color: white;
  padding: 15px 20px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 100000;
  font-size: 14px;
  animation: slideInFromRight 0.3s ease-out;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutToRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

/* Animação de pulso para o botão Save */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.pulse-animation {
  animation: pulse 1s ease-in-out infinite;
}

/* Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.3);
  z-index: 9998;
  display: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.active {
  display: block;
}

/* ============================================
   DRAWFLOW CANVAS - RESPONSIVE
   ============================================ */
#drawflow {
  width: 100%;
  height: calc(100vh - 200px);
  background: #fafafa;
  background-image:
    linear-gradient(#e0e0e0 1px, transparent 1px),
    linear-gradient(90deg, #e0e0e0 1px, transparent 1px);
  background-size: 20px 20px;
  position: relative;
  overflow: auto;
  touch-action: pan-x pan-y;
}

/* Bloco compacto */
.drawflow-node.compact {
  width: 250px !important;
  min-width: 250px;
}

.drawflow-node .config-button {
  display: block;
  width: 100%;
  padding: 10px;
  background: #f0f0f1;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  margin-top: 10px;
  transition: all 0.2s;
  font-size: 13px;
  font-weight: 500;
}

.drawflow-node .config-button:hover {
  background: #008080;
  color: white;
  border-color: #006666;
}

.drawflow-node .config-button .count {
  display: inline-block;
  background: #008080;
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  margin-left: 6px;
}

.drawflow-node .config-button:hover .count {
  background: white;
  color: #008080;
}

/* ============================================
   TABLET (≤ 1024px)
   ============================================ */
@media screen and (max-width: 1024px) {
  #wpflow-node-sidebar {
    width: 350px;
    right: -350px;
  }

  .drawflow-node.compact {
    width: 220px !important;
    min-width: 220px;
  }

  .sidebar-content {
    padding: 15px;
  }
}

/* ============================================
   MOBILE (≤ 768px)
   ============================================ */
@media screen and (max-width: 768px) {
  #wpflow-node-sidebar {
    top: auto;
    bottom: -100vh;
    right: 0;
    left: 0;
    width: 100%;
    height: 90vh;
    border-left: none;
    border-top: 1px solid #ddd;
    border-radius: 16px 16px 0 0;
    transition: bottom 0.3s ease;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
  }

  #wpflow-node-sidebar.active {
    bottom: 0;
  }

  .sidebar-header {
    border-radius: 16px 16px 0 0;
    padding: 12px 15px;
    position: relative;
  }

  .sidebar-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: rgba(255,255,255,0.5);
    border-radius: 2px;
  }

  .sidebar-header h3 {
    font-size: 15px;
    margin-top: 8px;
  }

  .sidebar-content {
    padding: 15px;
    padding-bottom: 30px;
  }

  #drawflow {
    height: calc(100vh - 350px);
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .drawflow-node {
    min-width: 200px;
    max-width: 250px;
  }

  .drawflow-node.compact {
    width: 200px !important;
    min-width: 200px;
  }

  .drawflow-node .title-box {
    font-size: 13px;
    padding: 8px 10px;
  }

  .drawflow-node .box {
    padding: 10px;
  }

  .drawflow-node textarea,
  .drawflow-node input[type="text"],
  .drawflow-node select {
    font-size: 14px;
    padding: 8px;
  }

  .drawflow-node .config-button {
    padding: 12px;
    font-size: 14px;
    touch-action: manipulation;
  }

  .sidebar-overlay.active {
    background: rgba(0,0,0,0.5);
  }

  .sidebar-option {
    padding: 10px;
  }

  .sidebar-option input,
  .sidebar-option textarea,
  .sidebar-option select {
    font-size: 14px;
    padding: 10px;
  }

  .sidebar-tags .tag-item {
    padding: 8px 14px;
    font-size: 13px;
    margin: 6px 4px;
  }

  .sidebar-button {
    padding: 14px;
    font-size: 15px;
  }
}

/* ============================================
   MOBILE PEQUENO (≤ 480px)
   ============================================ */
@media screen and (max-width: 480px) {
  #wpflow-node-sidebar {
    height: 95vh;
  }

  .drawflow-node.compact {
    width: 180px !important;
    min-width: 180px;
  }

  .sidebar-content {
    padding: 12px;
  }

  .sidebar-section h4 {
    font-size: 13px;
  }

  .sidebar-option {
    padding: 8px;
  }

  .sidebar-tags {
    padding: 12px;
  }
}

/* ============================================
   LANDSCAPE MOBILE
   ============================================ */
@media screen and (max-height: 500px) and (orientation: landscape) {
  #wpflow-node-sidebar {
    height: 100vh;
  }

  .sidebar-header {
    padding: 8px 15px;
  }

  .sidebar-content {
    padding: 10px 15px;
  }
}

/* ============================================
   TOUCH DEVICES
   ============================================ */
@media (hover: none) and (pointer: coarse) {
  .sidebar-close,
  .sidebar-button,
  .config-button,
  .tag-item {
    min-height: 44px;
    min-width: 44px;
  }

  .sidebar-close:active,
  .sidebar-button:active,
  .config-button:active,
  .tag-item:active {
    opacity: 0.7;
    transform: scale(0.98);
  }
}
