/* ============================================================
   CENTRAL DE APPS - ESTILOS CHATWOOT
   Design idêntico ao Chatwoot
   ============================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Cores do Chatwoot */
  --woot-primary: #1f93ff;
  --woot-primary-dark: #1976d2;
  --woot-primary-light: #ebf5ff;
  --woot-secondary: #3c4858;

  /* Backgrounds */
  --bg-body: #f8fafc;
  --bg-white: #ffffff;
  --bg-light: #f4f6fb;
  --bg-dark: #1f2d3d;
  --bg-sidebar: #293f51;

  /* Textos */
  --text-dark: #1f2d3d;
  --text-light: #6e84a3;
  --text-muted: #8492a6;
  --text-white: #ffffff;

  /* Bordas */
  --border-light: #e8e8e8;
  --border-normal: #d3d5d8;

  /* Status */
  --success: #44ce4b;
  --warning: #ffc532;
  --danger: #ff382d;
  --info: #1f93ff;

  /* Shadows (Chatwoot style) */
  --shadow-small: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.1);

  /* Radius */
  --radius-small: 4px;
  --radius-normal: 8px;
  --radius-large: 12px;

  /* Font */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

body {
  font-family: var(--font-family);
  background: var(--bg-body);
  color: var(--text-dark);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LOADING E ERROS (Estilo Chatwoot)
   ============================================================ */

.loading-screen,
.error-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  z-index: 1000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--woot-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-screen p {
  margin-top: 16px;
  color: var(--text-light);
  font-size: 14px;
}

.error-screen .error-icon {
  font-size: 56px;
  margin-bottom: 20px;
}

.error-screen h2 {
  margin-bottom: 8px;
  color: var(--text-dark);
  font-size: 20px;
  font-weight: 600;
}

.error-screen p {
  color: var(--text-light);
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}

/* ============================================================
   BOTÕES (Estilo Chatwoot)
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: var(--radius-normal);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: var(--font-family);
}

.btn-primary {
  background: var(--woot-primary);
  color: var(--text-white);
}

.btn-primary:hover {
  background: var(--woot-primary-dark);
}

.btn-secondary {
  background: var(--bg-white);
  color: var(--text-dark);
  border: 1px solid var(--border-normal);
}

.btn-secondary:hover {
  background: var(--bg-light);
}

.btn-success {
  background: var(--success);
  color: var(--text-white);
}

.btn-danger {
  background: var(--danger);
  color: var(--text-white);
}

.btn-danger:hover {
  background: #e02d22;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-normal);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background: var(--bg-light);
  color: var(--woot-primary);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* ============================================================
   PAINEL PRINCIPAL
   ============================================================ */

.main-panel {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-body);
}

/* ============================================================
   HEADER COM ABAS (Estilo Chatwoot)
   ============================================================ */

.tabs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  height: 56px;
  flex-shrink: 0;
}

.tabs-container {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: none;
}

.tabs-container::-webkit-scrollbar {
  display: none;
}

.tab-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-normal);
  background: transparent;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  font-family: var(--font-family);
}

.tab-item:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.tab-item.active {
  background: var(--woot-primary-light);
  color: var(--woot-primary);
}

.tab-item .tab-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tab-item .tab-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================================================
   ÁREA DE CONTEÚDO
   ============================================================ */

.content-area {
  flex: 1;
  position: relative;
  background: var(--bg-body);
  overflow: hidden;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}

.empty-state .empty-icon {
  font-size: 56px;
  margin-bottom: 20px;
  opacity: 0.8;
}

.empty-state h3 {
  color: var(--text-dark);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-light);
  font-size: 14px;
}

#content-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: var(--bg-white);
}

.iframe-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.95);
  z-index: 5;
}

.iframe-loading p {
  margin-top: 16px;
  color: var(--text-light);
}

/* ============================================================
   BADGES E TAGS (Estilo Chatwoot)
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 100px;
  background: var(--bg-light);
  color: var(--text-light);
}

.badge-primary {
  background: var(--woot-primary-light);
  color: var(--woot-primary);
}

.badge-success {
  background: #e6f9e6;
  color: var(--success);
}

.badge-warning {
  background: #fff8e6;
  color: #b8860b;
}

.badge-danger {
  background: #ffe6e6;
  color: var(--danger);
}

/* ============================================================
   FORMULÁRIOS (Estilo Chatwoot)
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--font-family);
  border: 1px solid var(--border-normal);
  border-radius: var(--radius-normal);
  background: var(--bg-white);
  color: var(--text-dark);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus,
.form-select:focus {
  outline: none;
  border-color: var(--woot-primary);
  box-shadow: 0 0 0 3px rgba(31, 147, 255, 0.1);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--woot-primary);
}

/* ============================================================
   CARDS (Estilo Chatwoot)
   ============================================================ */

.card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-large);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

.card-body {
  padding: 20px;
}

/* ============================================================
   TABELAS (Estilo Chatwoot)
   ============================================================ */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
}

.table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-light);
  background: var(--bg-light);
}

.table td {
  font-size: 14px;
  color: var(--text-dark);
}

.table tr:hover td {
  background: var(--bg-light);
}

/* ============================================================
   MODAL (Estilo Chatwoot)
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.hidden {
  display: none;
}

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-large);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: var(--shadow-large);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-dark);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-small);
  cursor: pointer;
  color: var(--text-light);
  font-size: 20px;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--bg-light);
  color: var(--text-dark);
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-light);
}

/* ============================================================
   LISTA DE ITENS (Estilo Chatwoot)
   ============================================================ */

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.15s ease;
}

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

.list-item:hover {
  background: var(--bg-light);
}

.list-item-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-normal);
  font-size: 20px;
  flex-shrink: 0;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-actions {
  display: flex;
  gap: 4px;
}

/* ============================================================
   TOGGLE SWITCH (Estilo Chatwoot)
   ============================================================ */

.toggle {
  position: relative;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border-normal);
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: var(--bg-white);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-small);
}

.toggle input:checked + .toggle-slider {
  background: var(--woot-primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Toggle com label inline */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle-group .toggle-label {
  font-size: 14px;
  color: var(--text-dark);
  margin: 0;
}

/* ============================================================
   ALERTAS (Estilo Chatwoot)
   ============================================================ */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-normal);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-info {
  background: var(--woot-primary-light);
  color: var(--woot-primary-dark);
}

.alert-success {
  background: #e6f9e6;
  color: #0d6d0d;
}

.alert-warning {
  background: #fff8e6;
  color: #8b6914;
}

.alert-danger {
  background: #ffe6e6;
  color: #c41e16;
}

/* ============================================================
   ÍCONES DE ABAS
   ============================================================ */

.icon-svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ============================================================
   CHIPS DE TIMES
   ============================================================ */

.team-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg-light);
  border: 1px solid var(--border-light);
  border-radius: 100px;
  font-size: 12px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.15s ease;
}

.team-chip:hover {
  border-color: var(--woot-primary);
  color: var(--woot-primary);
}

.team-chip.selected {
  background: var(--woot-primary-light);
  border-color: var(--woot-primary);
  color: var(--woot-primary);
}

.team-chip .remove {
  margin-left: 4px;
  font-size: 14px;
  line-height: 1;
}

/* ============================================================
   DRAG AND DROP
   ============================================================ */

.draggable {
  cursor: grab;
}

.draggable:active {
  cursor: grabbing;
}

.drag-handle {
  color: var(--text-muted);
  cursor: grab;
}

.drag-over {
  border-top: 2px solid var(--woot-primary);
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

@media (max-width: 768px) {
  .tabs-header {
    padding: 0 12px;
  }

  .tab-item {
    padding: 8px 10px;
    font-size: 13px;
  }

  .tab-item .tab-name {
    max-width: 100px;
  }

  .modal {
    max-width: 100%;
    margin: 0;
    border-radius: var(--radius-normal);
  }
}

/* ============================================================
   SCROLLBAR CUSTOMIZADO (Estilo Chatwoot)
   ============================================================ */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-normal);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
