/* =============================================================
   shadcn/ui Design System — Perfex CRM Override
   Tasarım: Minimal, temiz, nötr renkler + tek accent
   Loads after app-css so all rules take priority.
   ============================================================= */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --sh-bg:          hsl(0 0% 100%);
  --sh-fg:          hsl(222.2 84% 4.9%);
  --sh-card:        hsl(0 0% 100%);
  --sh-muted:       hsl(210 40% 96%);
  --sh-muted-fg:    hsl(215.4 16.3% 46.9%);
  --sh-border:      hsl(214.3 31.8% 91.4%);
  --sh-primary:     hsl(222.2 47.4% 11.2%);
  --sh-accent:      hsl(210 40% 96%);
  --sh-destructive: hsl(0 84.2% 60.2%);
  --sh-success:     hsl(142.1 76.2% 36.3%);
  --sh-warning:     hsl(37.7 92.1% 50.2%);
  --sh-ring:        hsl(222.2 84% 4.9%);
  --sh-radius:      0.5rem;
  --sh-transition:  150ms ease;
}

/* ── Body & Layout ─────────────────────────────────────────── */
body {
  background-color: hsl(210 40% 97.5%) !important;
  color: var(--sh-fg) !important;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  -webkit-font-smoothing: antialiased !important;
}

/* ── Header ─────────────────────────────────────────────────── */
#header {
  background: var(--sh-card) !important;
  box-shadow: none !important;
  border-bottom: 1px solid var(--sh-border) !important;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  background: var(--sh-card) !important;
  border-right: 1px solid var(--sh-border) !important;
}

[dir="rtl"] .sidebar {
  border-right: 0 !important;
  border-left: 1px solid var(--sh-border) !important;
}

.sidebar ul.nav li a {
  color: var(--sh-muted-fg) !important;
  font-weight: 500 !important;
  border-radius: calc(var(--sh-radius) - 2px) !important;
  border: 1px solid transparent !important;
  transition: background-color var(--sh-transition), color var(--sh-transition) !important;
}

.sidebar > ul.nav > li:hover a:first-child,
.sidebar > ul.nav > li.active a:first-child {
  background: var(--sh-muted) !important;
  box-shadow: none !important;
  border: 1px solid transparent !important;
  color: var(--sh-fg) !important;
}

.sidebar ul.nav li.active > a,
.sidebar ul.nav > li > a:hover,
.sidebar ul.nav > li > a:focus,
.sidebar ul.nav li.active > a .menu-icon,
.sidebar ul.nav > li > a:hover .menu-icon,
.sidebar ul.nav > li > a:focus .menu-icon {
  color: var(--sh-fg) !important;
}

.sidebar > ul.nav > li {
  border-left: 2px solid transparent !important;
}

[dir="rtl"] .sidebar > ul.nav > li {
  border-right: 2px solid transparent !important;
  border-left: 0 !important;
}

/* ── Quick Stats Cards ───────────────────────────────────────── */
.top_stats_wrapper {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: var(--sh-radius) !important;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04) !important;
  padding: 1.375rem 1.5rem 1.25rem !important;
  transition: border-color var(--sh-transition), box-shadow var(--sh-transition) !important;
}

.top_stats_wrapper:hover {
  border-color: hsl(214.3 31.8% 82%) !important;
  box-shadow: 0 2px 8px 0 rgb(0 0 0 / 0.06) !important;
}

/* ── Progress Bars ──────────────────────────────────────────── */
.progress,
.progress-bar-mini {
  background-color: var(--sh-muted) !important;
  border-radius: 9999px !important;
  box-shadow: none !important;
  height: 5px !important;
  overflow: hidden !important;
}

.progress-bar {
  border-radius: 9999px !important;
  transition: width 700ms cubic-bezier(0.4, 0, 0.2, 1) !important;
  box-shadow: none !important;
}

.progress-bar-danger  { background-color: var(--sh-destructive) !important; }
.progress-bar-success { background-color: var(--sh-success) !important; }
.progress-bar-default { background-color: var(--sh-primary) !important; }
.progress-bar-warning { background-color: var(--sh-warning) !important; }
.progress-bar-info    { background-color: hsl(199 89% 48%) !important; }

/* ── Panel / Card ───────────────────────────────────────────── */
.panel_s,
.panel {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: var(--sh-radius) !important;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04) !important;
  margin-bottom: 1.5rem !important;
}

.panel-body {
  background: transparent !important;
  border-radius: var(--sh-radius) !important;
}

.panel-heading {
  background: transparent !important;
  border-bottom: 1px solid var(--sh-border) !important;
  padding: 0.875rem 1.25rem !important;
}

.panel-title {
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  color: var(--sh-fg) !important;
}

.panel-footer {
  background: transparent !important;
  border-top: 1px solid var(--sh-border) !important;
}

._total {
  font-size: 1.375rem !important;
  font-weight: 700 !important;
  color: var(--sh-fg) !important;
  display: block !important;
  margin-bottom: 0.125rem !important;
  font-variant-numeric: tabular-nums !important;
}

/* ── Tables ─────────────────────────────────────────────────── */
.table {
  border-collapse: collapse !important;
}

.table > thead > tr > th {
  background-color: var(--sh-muted) !important;
  border-bottom: 1px solid var(--sh-border) !important;
  border-top: none !important;
  font-size: 0.6875rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  color: var(--sh-muted-fg) !important;
  padding: 0.625rem 1rem !important;
  white-space: nowrap !important;
}

.table > tbody > tr > td {
  border-top: 1px solid var(--sh-border) !important;
  padding: 0.75rem 1rem !important;
  vertical-align: middle !important;
  color: var(--sh-fg) !important;
  font-size: 0.84375rem !important;
}

.table > tbody > tr {
  transition: background-color var(--sh-transition) !important;
}

.table > tbody > tr:hover > td,
.table > tbody > tr:hover > th {
  background-color: var(--sh-accent) !important;
}

.table-striped > tbody > tr:nth-of-type(odd) {
  background-color: hsl(210 40% 98%) !important;
}

/* ── Badge ──────────────────────────────────────────────────── */
.badge {
  border-radius: 9999px !important;
  font-size: 0.6875rem !important;
  font-weight: 500 !important;
  padding: 0.15rem 0.5rem !important;
  letter-spacing: 0.02em !important;
}

.label {
  border-radius: 9999px !important;
  font-size: 0.6875rem !important;
  font-weight: 500 !important;
  padding: 0.2rem 0.55rem !important;
}

/* ── HR / Dividers ──────────────────────────────────────────── */
hr {
  border-color: var(--sh-border) !important;
  border-top-width: 1px !important;
  opacity: 1 !important;
  margin: 0 !important;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn-default {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  color: var(--sh-fg) !important;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.04) !important;
  transition: background-color var(--sh-transition), border-color var(--sh-transition) !important;
}

.btn-default:hover,
.btn-default:focus {
  background: var(--sh-accent) !important;
  border-color: hsl(214.3 31.8% 82%) !important;
  color: var(--sh-fg) !important;
}

.btn-primary {
  background: var(--sh-primary) !important;
  border-color: var(--sh-primary) !important;
  color: hsl(0 0% 100%) !important;
  box-shadow: none !important;
  transition: background-color var(--sh-transition) !important;
}

.btn-primary:hover,
.btn-primary:focus {
  background: hsl(222.2 47.4% 18%) !important;
  border-color: hsl(222.2 47.4% 18%) !important;
  color: hsl(0 0% 100%) !important;
}

.btn-danger {
  background: var(--sh-destructive) !important;
  border-color: var(--sh-destructive) !important;
  color: hsl(0 0% 100%) !important;
  box-shadow: none !important;
}

.btn-danger:hover,
.btn-danger:focus {
  background: hsl(0 84.2% 52%) !important;
  border-color: hsl(0 84.2% 52%) !important;
  color: hsl(0 0% 100%) !important;
}

.btn-success {
  background: var(--sh-success) !important;
  border-color: var(--sh-success) !important;
  color: hsl(0 0% 100%) !important;
  box-shadow: none !important;
}

.btn-link {
  color: var(--sh-muted-fg) !important;
  text-decoration: none !important;
  transition: color var(--sh-transition) !important;
}

.btn-link:hover,
.btn-link:focus {
  color: var(--sh-fg) !important;
  text-decoration: none !important;
}

.btn:focus,
.btn:active:focus {
  outline: 2px solid var(--sh-ring) !important;
  outline-offset: 2px !important;
  box-shadow: none !important;
}

/* ── Dropdown ───────────────────────────────────────────────── */
.dropdown-menu {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: var(--sh-radius) !important;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06) !important;
  padding: 0.25rem !important;
}

.dropdown-menu > li > a {
  border-radius: calc(var(--sh-radius) - 4px) !important;
  padding: 0.4rem 0.75rem !important;
  font-size: 0.84375rem !important;
  color: var(--sh-fg) !important;
  transition: background-color var(--sh-transition) !important;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > .active > a,
.dropdown-menu > .active > a:hover,
.dropdown-menu > .active > a:focus {
  background-color: var(--sh-accent) !important;
  color: var(--sh-fg) !important;
}

.dropdown-menu > li.disabled > a {
  color: var(--sh-muted-fg) !important;
}

.dropdown-menu .divider {
  background-color: var(--sh-border) !important;
  margin: 0.25rem 0 !important;
}

.dropdown-header {
  color: var(--sh-muted-fg) !important;
  font-size: 0.6875rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.06em !important;
  padding: 0.25rem 0.75rem 0.125rem !important;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  border-radius: var(--sh-radius) !important;
  border-width: 1px !important;
  border-style: solid !important;
  font-size: 0.84375rem !important;
}

.alert-success {
  background-color: hsl(142.1 76.2% 95%) !important;
  border-color: hsl(142.1 76.2% 80%) !important;
  color: hsl(142.1 76.2% 20%) !important;
}

.alert-danger,
.alert-error {
  background-color: hsl(0 84.2% 96%) !important;
  border-color: hsl(0 84.2% 85%) !important;
  color: hsl(0 84.2% 30%) !important;
}

.alert-warning {
  background-color: hsl(37.7 92.1% 95%) !important;
  border-color: hsl(37.7 92.1% 82%) !important;
  color: hsl(37.7 92.1% 25%) !important;
}

.alert-info {
  background-color: hsl(199 89% 95%) !important;
  border-color: hsl(199 89% 80%) !important;
  color: hsl(199 89% 20%) !important;
}

/* ── Input / Form Controls ───────────────────────────────────── */
.form-control {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: calc(var(--sh-radius) - 2px) !important;
  box-shadow: none !important;
  color: var(--sh-fg) !important;
  font-size: 0.84375rem !important;
  transition: border-color var(--sh-transition), box-shadow var(--sh-transition) !important;
}

.form-control:focus {
  border-color: hsl(222.2 47.4% 50%) !important;
  box-shadow: 0 0 0 2px hsl(222.2 47.4% 11.2% / 0.12) !important;
  outline: none !important;
}

.form-control::placeholder {
  color: var(--sh-muted-fg) !important;
  opacity: 1 !important;
}

/* ── Modal ──────────────────────────────────────────────────── */
.modal-content {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: var(--sh-radius) !important;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1) !important;
}

.modal-header {
  border-bottom: 1px solid var(--sh-border) !important;
  padding: 1rem 1.5rem !important;
}

.modal-header .modal-title {
  font-size: 1rem !important;
  font-weight: 600 !important;
  color: var(--sh-fg) !important;
}

.modal-footer {
  border-top: 1px solid var(--sh-border) !important;
  padding: 0.75rem 1.5rem !important;
}

/* ── Misc typography ────────────────────────────────────────── */
.text-muted {
  color: var(--sh-muted-fg) !important;
}

a {
  color: hsl(222.2 47.4% 40%) !important;
  transition: color var(--sh-transition) !important;
}

a:hover,
a:focus {
  color: var(--sh-primary) !important;
}

a.text-danger,  .text-danger  { color: var(--sh-destructive) !important; }
a.text-success, .text-success { color: var(--sh-success) !important; }
a.text-warning, .text-warning { color: var(--sh-warning) !important; }
a.text-info,    .text-info    { color: hsl(199 89% 40%) !important; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination > li > a,
.pagination > li > span {
  border: 1px solid var(--sh-border) !important;
  color: var(--sh-fg) !important;
  transition: background-color var(--sh-transition) !important;
}

.pagination > li > a:hover {
  background: var(--sh-accent) !important;
}

.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover {
  background-color: var(--sh-primary) !important;
  border-color: var(--sh-primary) !important;
  color: hsl(0 0% 100%) !important;
}

/* ── Selectpicker ───────────────────────────────────────────── */
.bootstrap-select .btn {
  border: 1px solid var(--sh-border) !important;
  background: var(--sh-card) !important;
  color: var(--sh-fg) !important;
  box-shadow: none !important;
}

/* ── Sidebar Drag-to-Reorder ────────────────────────────────── */
.sidebar-sortable-item {
  position: relative !important;
}

.sidebar-drag-handle {
  position: absolute !important;
  right: 6px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  cursor: grab !important;
  color: transparent !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 20px !important;
  height: 20px !important;
  border-radius: 4px !important;
  transition: color var(--sh-transition), background-color var(--sh-transition) !important;
  z-index: 10 !important;
  line-height: 1 !important;
}

[dir="rtl"] .sidebar-drag-handle {
  right: auto !important;
  left: 6px !important;
}

.sidebar-sortable-item:hover .sidebar-drag-handle {
  color: hsl(215.4 16.3% 60%) !important;
}

.sidebar-drag-handle:hover {
  color: hsl(215.4 16.3% 36%) !important;
  background-color: var(--sh-muted) !important;
}

.sidebar-drag-handle:active {
  cursor: grabbing !important;
}

.sidebar-sort-placeholder {
  background: linear-gradient(90deg, var(--sh-muted) 0%, transparent 100%) !important;
  border: 1px dashed var(--sh-border) !important;
  border-radius: calc(var(--sh-radius) - 2px) !important;
  margin: 2px 0 !important;
  opacity: 0.7 !important;
}

#side-menu .ui-sortable-helper {
  background: var(--sh-card) !important;
  border: 1px solid var(--sh-border) !important;
  border-radius: calc(var(--sh-radius) - 2px) !important;
  box-shadow: 0 4px 12px rgb(0 0 0 / 0.1) !important;
  opacity: 0.95 !important;
  list-style: none !important;
  width: 213px !important;
}

/* ── CRM Topbar ─────────────────────────────────────────────── */
.crm-topbar {
    background: #f9f9f9;
    border-bottom: 1px solid #cbd5e1;
    padding: 6px 13px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 2px;
}
.crm-tab-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 13px;
    font-size: 14px;
    font-weight: 600;
    color: #363e48;
    text-decoration: none !important;
    border: 1px solid transparent;
    border-radius: 0.375rem;
    white-space: nowrap;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.crm-tab-link:hover,
.crm-tab-link:focus {
    color: #111827;
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.15);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    text-decoration: none !important;
}
.crm-tab-link .crm-tab-icon {
    color: #6b7280;
    font-size: 14px;
}
.crm-tab-link:hover .crm-tab-icon,
.crm-tab-link:focus .crm-tab-icon {
    color: #111827;
}
.crm-tab-active > .crm-tab-link {
    color: #111827;
    background: #ffffff;
    border-color: rgba(15, 23, 42, 0.15);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.crm-tab-active > .crm-tab-link .crm-tab-icon {
    color: #111827;
}

/* ── CRM Kanban Board ────────────────────────────────────────── */

/* Column wrapper */
.kan-ban-col .border-right.panel_s {
    border: 1px solid #e2e8f0 !important;
    border-right: 1px solid #e2e8f0 !important;
    border-radius: 0.75rem !important;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    background: #f8fafc;
    margin-bottom: 0;
}
#kan-ban .border-right:last-child {
    border: 1px solid #e2e8f0 !important;
}

/* Column header */
.crm-kb-header.panel-heading {
    background: #ffffff !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-radius: 0 !important;
    padding: 10px 12px !important;
    color: #111827 !important;
}
.crm-kb-drag-icon {
    color: #9ca3af;
    font-size: 11px;
    cursor: grab;
}
.crm-kb-status-name {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #111827 !important;
}
.crm-kb-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: #475569;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
}
.crm-kb-header-value {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
    white-space: nowrap;
}
.crm-kb-header-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 0.375rem;
    color: #9ca3af !important;
    background: transparent;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    text-decoration: none !important;
    font-size: 12px;
}
.crm-kb-header-btn:hover {
    background: #f1f5f9 !important;
    border-color: #e2e8f0;
    color: #374151 !important;
}

/* Column content area */
.kan-ban-content {
    background: #f1f5f9 !important;
    padding: 8px !important;
}

/* Card override */
#kan-ban .panel-body.crm-kb-card {
    border: 1px solid #e2e8f0 !important;
    border-radius: 0.5rem !important;
    padding: 10px 12px !important;
    margin: 0 0 6px 0 !important;
    background: #ffffff !important;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04) !important;
    position: relative;
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
#kan-ban .panel-body.crm-kb-card:hover {
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.08) !important;
    border-color: #cbd5e1 !important;
}

/* Lead name row — keep drag handle bg image, just fix layout */
#kan-ban .panel-body.crm-kb-card .lead-name {
    margin-left: 0 !important;
    padding-left: 20px !important;
    margin-bottom: 6px !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
}

/* Lead link */
.crm-kb-lead-link {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #111827 !important;
    text-decoration: none !important;
    line-height: 1.35 !important;
    display: block;
    min-width: 0;
}
.crm-kb-lead-link:hover {
    color: #2563eb !important;
    text-decoration: none !important;
}

/* Card meta */
.crm-kb-meta {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 20px;
}

/* Card footer */
.crm-kb-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    padding-left: 20px;
}
.crm-kb-dates {
    font-size: 11px;
    color: #9ca3af;
    line-height: 1.6;
}
.crm-kb-dates .bold {
    color: #6b7280 !important;
    font-weight: 500;
}
.crm-kb-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #9ca3af;
    flex-shrink: 0;
}
.crm-kb-icons span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Tags */
.kanban-tags {
    margin-top: 6px !important;
    padding-left: 20px;
    flex-wrap: wrap !important;
    gap: 4px !important;
}

/* Expand button */
.kan-ban-expand-top {
    position: absolute !important;
    top: 6px !important;
    right: 6px !important;
    background: transparent !important;
    color: #d1d5db !important;
    padding: 2px 4px !important;
    border-radius: 4px !important;
    font-size: 10px !important;
    transition: all 0.15s ease;
    line-height: 1 !important;
}
.kan-ban-expand-top:hover {
    background: #f1f5f9 !important;
    color: #6b7280 !important;
}

/* Expandable detail section */
.crm-kb-details {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}
.crm-kb-detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}
.crm-kb-detail-label {
    color: #9ca3af;
    min-width: 72px;
    flex-shrink: 0;
    font-weight: 500;
}
.crm-kb-detail-value {
    color: #374151;
    font-weight: 500;
    word-break: break-word;
}
.crm-kb-detail-value a {
    color: #2563eb;
    text-decoration: none;
}
.crm-kb-detail-value a:hover {
    text-decoration: underline;
}

/* Load more button */
.kanban-load-more a.btn.btn-default {
    border: 1px dashed #cbd5e1 !important;
    background: transparent !important;
    color: #6b7280 !important;
    font-size: 12px !important;
    border-radius: 0.5rem !important;
    padding: 6px !important;
    box-shadow: none !important;
    transition: all 0.15s ease;
}
.kanban-load-more a.btn.btn-default:hover:not(.disabled) {
    background: #e2e8f0 !important;
    border-color: #94a3b8 !important;
    color: #374151 !important;
}

/* Empty state */
.kan-ban-content .kanban-empty h4 {
    color: #94a3b8 !important;
    font-size: 13px !important;
    font-weight: 400 !important;
}

/* Drag-drop placeholder */
.ui-state-highlight-card {
    border: 2px dashed #e2e8f0 !important;
    background: #f8fafc !important;
    border-radius: 0.5rem !important;
}

/* Current user's lead — blue left accent */
#kan-ban .lead-kan-ban.current-user-lead .panel-body.crm-kb-card {
    border-left: 3px solid #3b82f6 !important;
}

/* Sort bar */
.kanban-leads-sort {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 10px;
    padding: 4px 0;
}
.kanban-leads-sort a {
    color: #6b7280;
    text-decoration: none;
}
.kanban-leads-sort a:hover {
    color: #111827;
}
