/* ============================================
   SUPERVENDAS — DARK MODE CRM / KANBAN
   ============================================ */

:root {
  --bg: #0f172a;
  --bg-2: #111c33;
  --card: #1e293b;
  --card-2: #243349;
  --border: #2d3b55;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #facc15;
  --shadow: 0 6px 20px rgba(0,0,0,0.35);
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  height: 100%;
  overflow: hidden;
}

button { font-family: inherit; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  outline: none;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.25);
}
textarea { resize: vertical; min-height: 80px; }

/* ===== LOGIN ===== */
.login-wrapper {
  width: 100%;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1e293b 0%, #0f172a 60%);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  width: 380px;
  max-width: 92%;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 24px;
  margin: 0 0 4px 0;
  text-align: center;
  letter-spacing: 0.5px;
}
.login-card .brand {
  color: var(--primary);
}
.login-card p.subtitle {
  text-align: center;
  color: var(--text-muted);
  margin: 0 0 28px 0;
  font-size: 13px;
}
.login-card form { display: flex; flex-direction: column; gap: 14px; }
.login-card label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: -8px;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .05s;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  height: 58px;
}
.topbar .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.topbar .logo span { color: var(--primary); }
.topbar .actions { display: flex; align-items: center; gap: 8px; }
.topbar .user-info {
  display: flex; flex-direction: column; align-items: flex-end;
  margin-right: 12px;
  line-height: 1.2;
}
.topbar .user-info .name { font-size: 13px; font-weight: 600; }
.topbar .user-info .role {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .15s;
}
.btn-icon:hover { background: var(--card); }
.btn-icon.danger { color: var(--red); border-color: rgba(239,68,68,0.4); }
.btn-icon.danger:hover { background: rgba(239,68,68,0.15); }

/* ===== KANBAN ===== */
.kanban-wrapper {
  display: flex;
  height: calc(100vh - 58px);
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
  gap: 14px;
  scroll-behavior: smooth;
}
.kanban-wrapper::-webkit-scrollbar { height: 10px; }
.kanban-wrapper::-webkit-scrollbar-track { background: transparent; }
.kanban-wrapper::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}

.column {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 290px;
  min-width: 290px;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.column.dragging-col { opacity: 0.4; }
.column.drop-col { outline: 2px dashed var(--primary); }

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.column-header h3 {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.column-header .count {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-right: 8px;
}
.column-header input.rename-input {
  font-size: 13px;
  padding: 4px 8px;
}
.col-menu {
  position: relative;
}
.col-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 16px;
}
.col-menu-btn:hover { background: var(--card-2); color: var(--text); }
.col-menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 160px;
  display: none;
  z-index: 10;
  box-shadow: var(--shadow);
}
.col-menu-dropdown.open { display: block; }
.col-menu-dropdown button {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
}
.col-menu-dropdown button:hover { background: var(--card); }
.col-menu-dropdown button.danger { color: var(--red); }

.column-body {
  padding: 10px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.column-body.drop-target {
  background: rgba(37,99,235,0.08);
}
.column-body::-webkit-scrollbar { width: 6px; }
.column-body::-webkit-scrollbar-thumb {
  background: var(--border); border-radius: 8px;
}

.add-column-btn {
  background: var(--card);
  border: 1px dashed var(--border);
  color: var(--text-muted);
  width: 290px;
  min-width: 290px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  padding: 14px;
  align-self: flex-start;
  transition: background .15s, color .15s;
}
.add-column-btn:hover { background: var(--card-2); color: var(--text); }

/* ===== CARD ===== */
.card {
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: transform .08s, border-color .15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card:hover { border-color: var(--primary); }
.card.dragging { opacity: 0.5; }
.card .name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.card .plan {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
}
.card .meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.card .meta span { display: inline-flex; align-items: center; gap: 4px; }

/* ===== MODAL ===== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 560px;
  max-width: 92%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; margin: 0; }
.modal-body {
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-body label {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
}
.btn-ghost:hover { background: var(--card-2); }
.btn-danger {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}
.btn-danger:hover { background: #dc2626; }

.close-x {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
}
.close-x:hover { color: var(--text); }

/* ===== DETALHES VENDA ===== */
.detail-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
}
.detail-section h4 {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}
.detail-grid .item .lbl { font-size: 11px; color: var(--text-muted); }
.detail-grid .item .val { font-size: 13px; }

/* ===== COMENTÁRIOS ===== */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}
.comment {
  background: var(--bg-2);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.comment.admin { border-left-color: var(--yellow); }
.comment .head {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.comment .head .author { color: var(--text); font-weight: 600; }
.comment .text { font-size: 13px; white-space: pre-wrap; }

.comment-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.comment-form textarea { min-height: 56px; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}
.toast {
  background: var(--card);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  font-size: 13px;
  box-shadow: var(--shadow);
  min-width: 240px;
  animation: toast-in 0.25s ease-out;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--yellow); }
.toast.fade-out { animation: toast-out 0.25s ease-in forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(-8px); }
}

/* ===== LOADING / EMPTY ===== */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  color: var(--text-muted);
  font-size: 14px;
}
.loading-screen .spinner {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
  padding: 14px 6px;
  font-style: italic;
}

/* ===== FAB MOBILE ===== */
.fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 26px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(37,99,235,0.45);
  display: none;
  z-index: 50;
}
.fab:active { transform: scale(0.95); }

/* ===== USERS TABLE ===== */
.users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.users-table th, .users-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.users-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge.admin { background: rgba(250,204,21,0.15); color: var(--yellow); }
.badge.vendedor { background: rgba(37,99,235,0.15); color: var(--primary); }
.badge.on { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.off { background: rgba(239,68,68,0.15); color: var(--red); }

.modal.large { width: 760px; }

/* ===== MOBILE ===== */
@media (max-width: 720px) {
  .topbar { padding: 10px 12px; height: 54px; }
  .topbar .logo { font-size: 16px; }
  .topbar .user-info .name { font-size: 12px; }
  .topbar .user-info .role { font-size: 10px; }
  .btn-icon { padding: 6px 10px; font-size: 12px; }

  .kanban-wrapper {
    padding: 10px;
    gap: 10px;
    height: calc(100vh - 54px);
    scroll-snap-type: x mandatory;
  }
  .column, .add-column-btn {
    width: 84vw;
    min-width: 84vw;
    scroll-snap-align: start;
  }

  .modal { width: 100%; max-width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
  .row-2 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  .fab { display: flex; align-items: center; justify-content: center; }
  .topbar .actions .hide-mobile { display: none; }
}
