/* src/modules/flow/flow.css — Redesign v2 (Padrão Memo) */

/* ============================================
   1. LISTAGEM — Layout Tabular
   ============================================ */

.flow-view {
  margin-top: var(--space-4);
  width: 100%;
  animation: fadeIn 0.3s ease-in-out;
}

/* Toolbar acima da lista */
.flow-list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.flow-list-toolbar .flow-list-count {
  font-size: var(--font-size-tiny);
  color: var(--muted-foreground);
  font-weight: 500;
}

.flow-list-toolbar .primary {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-tiny);
}

/* Lista tabular — sem cards */
.flow-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.flow-list-row {
  display: grid;
  grid-template-columns: 28px 1fr 120px 32px 100px;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background-color 0.12s ease;
}

.flow-list-row:last-child {
  border-bottom: none;
}

.flow-list-row:hover {
  background: var(--accent);
}

.flow-list-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  opacity: 0.6;
}

.flow-list-title {
  font-size: var(--font-size-tiny);
  font-weight: 500;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.flow-list-private-icon {
  color: var(--muted-foreground);
  opacity: 0.6;
  flex-shrink: 0;
}

.flow-list-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow: hidden;
}

.flow-list-tag {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--muted);
  color: var(--muted-foreground);
  border-radius: var(--radius-md);
  font-weight: 600;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.flow-list-author {
  display: flex;
  align-items: center;
  justify-content: center;
}

.flow-list-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.flow-list-date {
  font-size: 11px;
  color: var(--muted-foreground);
  text-align: right;
  white-space: nowrap;
}

/* Skeleton loading */
.flow-list-skeleton {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.flow-skeleton-row {
  height: 44px;
  background: linear-gradient(90deg, var(--muted) 25%, var(--accent) 50%, var(--muted) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   2. EMPTY STATE — Premium
   ============================================ */

.flow-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 40px;
  animation: fadeInFlow 0.4s ease-out;
}

.flow-empty-icon {
  color: var(--muted-foreground);
  opacity: 0.3;
  margin-bottom: 20px;
}

.flow-empty-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--foreground);
  margin: 0 0 8px 0;
}

.flow-empty-description {
  font-size: var(--font-size-tiny);
  color: var(--muted-foreground);
  margin: 0 0 28px 0;
  max-width: 360px;
  line-height: 1.5;
}

.flow-empty-cta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--font-size-tiny);
}

@keyframes fadeInFlow {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   3. EDITOR — Drawer Fullscreen
   ============================================ */

#flowEditorDrawer.drawer-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw !important;
  height: 100vh !important;
  border-radius: 0 !important;
  margin: 0 !important;
  border: none !important;
  z-index: 10001 !important;
  display: none;
  flex-direction: column;
  background: var(--background);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1 !important;
  visibility: visible !important;
}

#flowEditorDrawer.drawer-fullscreen.open {
  display: flex !important;
  transform: translateX(0) !important;
  margin: 0 !important;
}

#flowEditorDrawer.drawer-fullscreen.open {
  border-radius: 10px 0 0 0 !important;
  margin-top: 15px !important;
  margin-left: 15px !important;
}

/* Editor Header — hero title + compact actions */
.flow-editor-header {
  padding: 12px 20px !important;
  border-bottom: 1px solid var(--border);
}

.flow-editor-header .drawer-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.flow-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.flow-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--foreground);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.flow-back-btn:hover {
  background: var(--accent);
  border-color: var(--primary);
}

#flowEditorDrawer .drawer-title-input {
  background: transparent;
  border: none;
  font-size: 20px;
  font-weight: 600;
  color: var(--foreground);
  width: 100%;
  flex: 1;
  outline: none;
  min-width: 0;
  padding: 4px 0;
  letter-spacing: -0.01em;
}

#flowEditorDrawer .drawer-title-input::placeholder {
  color: var(--muted-foreground);
  opacity: 0.5;
  font-weight: 400;
}

/* Header action buttons */
.flow-editor-header .drawer-header-actions {
  position: static;
  transform: none;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.flow-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--background);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  padding: 0;
}

.flow-action-btn:hover {
  background: var(--accent);
  color: var(--foreground);
  border-color: var(--primary);
}

.flow-header-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.flow-save-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: opacity 0.12s ease;
  white-space: nowrap;
}

.flow-save-btn:hover {
  opacity: 0.9;
}

/* ============================================
   4. EDITOR — Body & Workspace
   ============================================ */

#flowEditorDrawer .drawer-header {
  z-index: 100;
  position: relative;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.drawer-body-fullscreen {
  height: calc(100vh - 60px);
  padding: 0 !important;
  overflow: hidden;
  z-index: 1;
}

/* Main Container Layout */
.flow-editor-container {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  background: var(--muted);
  overflow: hidden;
  position: relative;
}

/* Shapes Panel (Left) - Glassmorphism Floating */
.flow-editor-shapes-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  bottom: 12px;
  width: 200px;
  min-width: 180px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg, 8px);
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 100;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .flow-editor-shapes-panel {
  background: rgba(10, 10, 12, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.4);
}

.flow-editor-shapes-panel:hover {
  background: rgba(255, 255, 255, 0.85);
}

.dark .flow-editor-shapes-panel:hover {
  background: rgba(10, 10, 12, 0.95);
}

.flow-shapes-container {
  overflow-y: auto;
  padding: 12px;
  height: 100%;
  scrollbar-width: none;
}

.flow-shapes-container::-webkit-scrollbar {
  display: none;
}

.flow-editor-shapes-panel::-webkit-scrollbar {
  width: 4px;
}
.flow-editor-shapes-panel::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

.flow-shapes-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.flow-shapes-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.flow-shapes-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flow-shapes-group-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
  margin-bottom: 2px;
}

.flow-shapes-group-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.flow-shape-item {
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-md, 6px);
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: flex-start !important;
  gap: 8px;
  width: 100%;
}

.dark .flow-shape-item {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.05);
}

.flow-shape-item:hover {
  background: var(--background);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.dark .flow-shape-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.flow-shape-item svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
  opacity: 0.8;
  flex-shrink: 0;
}

.flow-shape-item span {
  font-size: 12px;
  font-weight: 500;
  color: var(--foreground);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Canvas Area (Center) */
.flow-editor-main {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: var(--background);
  background-image: radial-gradient(var(--border) 0.8px, transparent 0.8px);
  background-size: 24px 24px;
  display: flex;
  flex-direction: column;
  transition: background 0.1s ease-out;
}

.flow-editor-canvas-wrapper {
  flex: 1;
  position: relative;
  overflow: auto;
  width: 100%;
  height: 100%;
  contain: strict;
  /* Hide scrollbars but keep functionality */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.flow-editor-canvas-wrapper::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

.flow-canvas {
  display: block;
  background: transparent;
  width: 100%;
  height: 100%;
  touch-action: none; /* Previne scroll nativo em touch */
}

/* Toolbar - Glassmorphism Floating */
.flow-editor-toolbar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 4px 8px;
  border-radius: var(--radius-full, 99px);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.15);
  z-index: 1000;
}

.dark .flow-editor-toolbar {
  background: rgba(10, 10, 12, 0.85);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px -4px rgba(0, 0, 0, 0.5);
}

.flow-editor-toolbar-left,
.flow-editor-toolbar-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
}

.flow-tool-separator {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
}

.flow-tool-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0 6px;
  min-width: 30px;
}

.flow-tool-btn svg {
  width: 15px;
  height: 15px;
}

.flow-tool-btn:hover {
  background: var(--accent);
  color: var(--primary);
}

.flow-tool-btn.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

/* Sidebar Properties (Right) - Glassmorphism Floating */
.flow-editor-sidebar {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: 220px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius-lg, 8px);
  box-shadow: -4px 4px 20px -4px rgba(0, 0, 0, 0.08);
  padding: 16px;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  scrollbar-width: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.dark .flow-editor-sidebar {
  background: rgba(10, 10, 12, 0.8);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: -4px 4px 20px -4px rgba(0, 0, 0, 0.4);
}

.flow-editor-sidebar:hover {
  background: rgba(255, 255, 255, 0.85);
}

.dark .flow-editor-sidebar:hover {
  background: rgba(10, 10, 12, 0.95);
}

.flow-editor-sidebar::-webkit-scrollbar {
  width: 4px;
}
.flow-editor-sidebar::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 4px;
}

.flow-properties-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

/* ============================================
   5. DROPDOWN & MENUS
   ============================================ */

/* Dropdown Menu Styles */
.button-group {
  position: relative;
}

.button-group-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  box-shadow: var(--shadow-xl);
  display: none;
  flex-direction: column;
  min-width: 200px;
  z-index: 99999;
  overflow: hidden;
  padding: 6px;
}

.button-group-menu.active {
  display: flex !important;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.button-group-menu-item {
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--foreground);
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: var(--radius-sm, 4px);
  transition: background 0.2s;
}

.button-group-menu-item:hover {
  background: var(--accent);
  color: var(--primary);
}

.button-group-menu-item svg {
  opacity: 0.7;
}

/* Property Panel Inputs */
.form-input {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 4px);
  padding: 6px 8px;
  font-size: 12px;
  color: var(--foreground);
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
  height: 28px;
}

.form-input:focus {
  border-color: var(--primary);
}

/* ============================================
   6. SVG & INTERACTION
   ============================================ */

/* SVG Elements & Interaction */
.flow-node { cursor: move; }

.flow-area { cursor: move; }

.flow-text { cursor: move; user-select: none; }
.flow-text.selected {
  outline: 2px solid var(--primary);
  outline-offset: 4px;
}

.selection-box {
  fill: none;
  stroke: #3b82f6; /* Azul de Seleção */
  stroke-width: 1.5px;
  pointer-events: none;
}

.resize-handle {
  fill: #3b82f6; /* Azul de Seleção */
  stroke: #ffffff;
  stroke-width: 1.5px;
  cursor: pointer;
}

.resize-handle:hover {
  fill: #2563eb; /* Azul um pouco mais escuro no hover */
}

/* Utility */
.flow-zoom-level {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  padding: 0 8px;
  min-width: 50px;
  text-align: center;
}

/* ============================================
   7. MISC — Layout & Responsive
   ============================================ */

/* Hide main sidebar when flow editor is active */
body.flow-editor-active .sidebar {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .flow-list-row {
    grid-template-columns: 28px 1fr 32px;
    gap: 6px;
    padding: 8px 12px;
  }

  .flow-list-tags,
  .flow-list-date {
    display: none;
  }

  .flow-header-left {
    gap: 6px;
  }

  #flowEditorDrawer .drawer-title-input {
    font-size: 16px;
  }
}
