/* ==========================================================================
   GOOGLE STITCH DESIGN SYSTEM - COMPONENTES UNIFICADOS
   Projeto: CS HelpDesk Pro / MSP Multi-Tenant
   Tokens: Cobalt Navy (#00236f), Slate Light (#f8f9ff), Teal (#006a61)
   ========================================================================== */

/* --- Cards de KPIs e Estatísticas --- */
.stitch-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stitch-kpi-card {
  background: #ffffff;
  border: 1px solid var(--stitch-border, #eaedff);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 16px -2px rgba(0, 35, 111, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stitch-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px -2px rgba(0, 35, 111, 0.08);
}

.stitch-kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stitch-kpi-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--stitch-text-muted, #444651);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stitch-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--stitch-secondary, #eaedff);
  color: var(--stitch-primary, #00236f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.stitch-kpi-value {
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--stitch-text, #131b2e);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.375rem;
}

.stitch-kpi-subtitle {
  font-size: 0.75rem;
  color: var(--stitch-text-muted, #74777f);
}

/* --- Container e Tabela Stitch --- */
.stitch-table-card {
  background: #ffffff;
  border: 1px solid var(--stitch-border, #eaedff);
  border-radius: 12px;
  box-shadow: 0 4px 16px -2px rgba(0, 35, 111, 0.05);
  overflow: hidden;
  margin-bottom: 2rem;
}

.stitch-table-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--stitch-border, #eaedff);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.stitch-table-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--stitch-text, #131b2e);
  margin: 0;
}

.stitch-table-subtitle {
  font-size: 0.8125rem;
  color: var(--stitch-text-muted, #74777f);
  margin-top: 2px;
}

.stitch-table-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.stitch-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.stitch-table th {
  background: #f8f9ff;
  padding: 0.875rem 1.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--stitch-text-muted, #444651);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--stitch-border, #eaedff);
}

.stitch-table td {
  padding: 1rem 1.25rem;
  font-size: 0.875rem;
  color: var(--stitch-text, #131b2e);
  border-bottom: 1px solid var(--stitch-border, #eaedff);
  vertical-align: middle;
}

.stitch-table tr:last-child td {
  border-bottom: none;
}

.stitch-table tr:hover td {
  background-color: #fbfbfe;
}

/* --- Badges e Chips Stitch --- */
.stitch-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stitch-badge-primary {
  background: #eaedff;
  color: #00236f;
  border: 1px solid #d2dbff;
}

.stitch-badge-success {
  background: #ccfbf1;
  color: #006a61;
  border: 1px solid #99f6e4;
}

.stitch-badge-warning {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.stitch-badge-danger {
  background: #ffebe8;
  color: #ba1a1a;
  border: 1px solid #ffdad6;
}

/* --- Cards de Usuários / Papéis RBAC --- */
.stitch-role-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stitch-role-card {
  background: #ffffff;
  border: 1.5px solid var(--stitch-border, #eaedff);
  border-radius: 10px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
}

.stitch-role-card:hover {
  border-color: var(--stitch-primary, #00236f);
  background: #f8f9ff;
}

.stitch-role-card.active {
  border-color: var(--stitch-primary, #00236f);
  background: #eaedff;
  box-shadow: 0 0 0 2px rgba(0, 35, 111, 0.15);
}

.stitch-role-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #f0f3ff;
  color: var(--stitch-primary, #00236f);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stitch-role-name {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--stitch-text, #131b2e);
  margin-bottom: 2px;
}

.stitch-role-desc {
  font-size: 0.75rem;
  color: var(--stitch-text-muted, #74777f);
  line-height: 1.4;
}

/* --- Cards de Tutoriais da Base de Conhecimento --- */
.stitch-kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.stitch-kb-card {
  background: #ffffff;
  border: 1px solid var(--stitch-border, #eaedff);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 4px 16px -2px rgba(0, 35, 111, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.stitch-kb-card:hover {
  transform: translateY(-2px);
  border-color: var(--stitch-primary, #00236f);
  box-shadow: 0 8px 24px -4px rgba(0, 35, 111, 0.1);
}

.stitch-kb-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stitch-kb-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #e2e7ff;
  color: #00236f;
  letter-spacing: 0.01em;
}

.stitch-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.stitch-status-pill.active {
  background: #dcfce7;
  color: #166534;
}

.stitch-status-pill.inactive {
  background: #fee2e2;
  color: #991b1b;
}

.stitch-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.stitch-status-dot.active {
  background: #16a34a;
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.stitch-status-dot.inactive {
  background: #dc2626;
}

.stitch-kb-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--stitch-text, #131b2e);
  margin-bottom: 0.5rem;
  line-height: 1.4;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
}

.stitch-kb-excerpt {
  font-size: 0.8125rem;
  color: var(--stitch-text-muted, #444651);
  line-height: 1.5;
  margin-bottom: 0.875rem;
  flex: 1;
}

.stitch-kb-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 1rem;
}

.stitch-kb-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  background: #f2f3ff;
  color: #264191;
  letter-spacing: 0.01em;
}

.stitch-kb-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid var(--stitch-border, #eaedff);
  padding-top: 0.75rem;
  margin-top: auto;
  flex-wrap: wrap;
}

.btn-stitch-read {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #eaedff;
  color: #00236f;
  border: 1px solid #dce1ff;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-stitch-read:hover {
  background: #00236f;
  color: #ffffff;
  border-color: #00236f;
}

.btn-stitch-edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #ffffff;
  color: #444651;
  border: 1px solid #c5c5d3;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-stitch-edit:hover {
  background: #f2f3ff;
  color: #00236f;
  border-color: #00236f;
}

.btn-stitch-danger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-stitch-danger:hover {
  background: #be123c;
  color: #ffffff;
  border-color: #be123c;
}

.btn-stitch-success {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f0fdf4;
  color: #15803d;
  border: 1px solid #bbf7d0;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-stitch-success:hover {
  background: #15803d;
  color: #ffffff;
  border-color: #15803d;
}

.stitch-kb-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--stitch-border, #eaedff);
  padding-top: 0.75rem;
  margin-top: auto;
}

/* --- Modo Escuro Stitch --- */
[data-theme="dark"] .stitch-kpi-card,
[data-theme="dark"] .stitch-table-card,
[data-theme="dark"] .stitch-role-card,
[data-theme="dark"] .stitch-kb-card {
  background: #10172a !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .stitch-table th {
  background: #0b1120 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #94a3b8 !important;
}

[data-theme="dark"] .stitch-table td {
  border-color: rgba(255, 255, 255, 0.08) !important;
  color: #f1f5f9 !important;
}

[data-theme="dark"] .stitch-table tr:hover td {
  background-color: rgba(255, 255, 255, 0.03) !important;
}

[data-theme="dark"] .stitch-kpi-title,
[data-theme="dark"] .stitch-table-title,
[data-theme="dark"] .stitch-role-name,
[data-theme="dark"] .stitch-kb-title {
  color: #ffffff !important;
}

/* ==========================================================================
   FRAMEWORK DE LAYOUT STITCH UNIFICADO (MULTI-TELA)
   ========================================================================== */

.stitch-workspace {
  background-color: #faf8ff !important;
  padding: 1.5rem 2rem 4rem 2rem !important;
  max-width: 1480px !important;
  margin: 0 auto !important;
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif !important;
  box-sizing: border-box !important;
}

[data-theme="dark"] .stitch-workspace {
  background-color: #090d16 !important;
}

/* Header & Breadcrumb Toolbar */
.stitch-header-card {
  margin-bottom: 1.5rem !important;
  width: 100% !important;
}

.stitch-breadcrumb {
  display: flex !important;
  align-items: center !important;
  gap: 0.375rem !important;
  font-size: 0.8125rem !important;
  color: #444651 !important;
  margin-bottom: 0.625rem !important;
}

[data-theme="dark"] .stitch-breadcrumb {
  color: #94a3b8 !important;
}

.stitch-breadcrumb a {
  color: #444651 !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 4px !important;
  transition: color 0.15s !important;
}

.stitch-breadcrumb a:hover {
  color: #00236f !important;
}

[data-theme="dark"] .stitch-breadcrumb a:hover {
  color: #60a5fa !important;
}

.stitch-title-group {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  flex-wrap: wrap !important;
  gap: 1.25rem !important;
  width: 100% !important;
}

.stitch-title-status {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  background: #006a61 !important;
  display: inline-block !important;
  flex-shrink: 0 !important;
}

.stitch-page-title {
  font-size: 1.625rem !important;
  font-weight: 700 !important;
  margin: 0 !important;
  color: #131b2e !important;
  letter-spacing: -0.02em !important;
}

[data-theme="dark"] .stitch-page-title {
  color: #f8fafc !important;
}

.stitch-page-subtitle {
  font-size: 0.8125rem !important;
  color: #444651 !important;
  margin: 4px 0 0 0 !important;
}

[data-theme="dark"] .stitch-page-subtitle {
  color: #94a3b8 !important;
}

/* Stepper Tabs Bar (Pills Flutuantes) */
.stitch-steps-bar {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  margin-bottom: 1.5rem !important;
  overflow: visible !important;
  flex-wrap: wrap !important;
}

.stitch-step-item {
  display: inline-flex !important;
  align-items: center !important;
  gap: 0.375rem !important;
  padding: 0.375rem 0.875rem !important;
  border-radius: 9999px !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  color: #444651 !important;
  text-decoration: none !important;
  background: transparent !important;
  white-space: nowrap !important;
  border: none !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}

.stitch-step-item.active {
  background: #eaedff !important;
  color: #00236f !important;
  font-weight: 700 !important;
}

[data-theme="dark"] .stitch-step-item {
  color: #94a3b8 !important;
}

[data-theme="dark"] .stitch-step-item.active {
  background: rgba(59, 130, 246, 0.15) !important;
  color: #93c5fd !important;
}

.stitch-step-num {
  width: 22px !important;
  height: 22px !important;
  border-radius: 50% !important;
  background: #e2e7ff !important;
  color: #444651 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 0.75rem !important;
  font-weight: 700 !important;
}

.stitch-step-item.active .stitch-step-num {
  background: #00236f !important;
  color: #ffffff !important;
}

[data-theme="dark"] .stitch-step-num {
  background: #1e293b !important;
  color: #94a3b8 !important;
}

[data-theme="dark"] .stitch-step-item.active .stitch-step-num {
  background: #3b82f6 !important;
  color: #ffffff !important;
}

/* Cards & Modulos */
.stitch-card {
  background: #ffffff !important;
  border: 1px solid #eaedff !important;
  border-radius: 16px !important;
  padding: 1.5rem !important;
  box-shadow: 0 1px 3px rgba(0, 35, 111, 0.04) !important;
  margin-bottom: 1.5rem !important;
}

[data-theme="dark"] .stitch-card {
  background: #111827 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

.stitch-card-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 1.25rem !important;
  padding-bottom: 0.75rem !important;
  border-bottom: 1px solid #f2f3ff !important;
}

[data-theme="dark"] .stitch-card-header {
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

.stitch-card-title-group {
  display: flex !important;
  align-items: center !important;
  gap: 0.75rem !important;
}

.stitch-card-icon {
  width: 34px !important;
  height: 34px !important;
  border-radius: 8px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 1.125rem !important;
}

.stitch-card-title {
  font-size: 1rem !important;
  font-weight: 700 !important;
  color: #131b2e !important;
  margin: 0 !important;
}

[data-theme="dark"] .stitch-card-title {
  color: #f8fafc !important;
}

.stitch-card-subtitle {
  font-size: 0.75rem !important;
  color: #444651 !important;
  margin: 2px 0 0 0 !important;
}

[data-theme="dark"] .stitch-card-subtitle {
  color: #94a3b8 !important;
}

.stitch-card-badge {
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  padding: 0.25rem 0.625rem !important;
  border-radius: 9999px !important;
}

.stitch-card-badge-required {
  background: #dcfce7 !important;
  color: #15803d !important;
}

.stitch-card-badge-optional {
  background: #f1f5f9 !important;
  color: #475569 !important;
}

/* Grids e Form Groups */
.stitch-grid-2 {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 1rem !important;
}

.stitch-grid-3 {
  display: grid !important;
  grid-template-columns: repeat(3, 1fr) !important;
  gap: 1rem !important;
}

.stitch-grid-4 {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 1rem !important;
}

@media (max-width: 768px) {
  .stitch-grid-2,
  .stitch-grid-3,
  .stitch-grid-4 {
    grid-template-columns: 1fr !important;
  }
}

.stitch-form-group {
  display: flex !important;
  flex-direction: column !important;
  gap: 0.375rem !important;
}

.stitch-label {
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  color: #444651 !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
}

[data-theme="dark"] .stitch-label {
  color: #cbd5e1 !important;
}

.stitch-help-text {
  font-size: 0.6875rem !important;
  color: #64748b !important;
  margin-top: 2px !important;
}

/* Layout de 2 Colunas */
.stitch-2col-layout {
  display: grid !important;
  grid-template-columns: 1fr 360px !important;
  gap: 1.5rem !important;
  align-items: start !important;
}

@media (max-width: 1100px) {
  .stitch-2col-layout {
    grid-template-columns: 1fr !important;
  }
}

.stitch-sidebar-sticky {
  position: sticky !important;
  top: 5rem !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 1.25rem !important;
}

