/* Ant Design CRM — global content harmonization for all legacy pages */

:root {
  --crm-sider-width: 220px;
  --crm-header-height: 64px;
  --antd-primary: #0d9488;
  --antd-primary-hover: #0f766e;
  --antd-bg: #f1f5f9;
  --antd-border: #e2e8f0;
  --antd-text: rgba(0, 0, 0, 0.88);
  --antd-text-secondary: rgba(0, 0, 0, 0.45);
  --crm-sider-bg: #ffffff;
  --crm-sider-shadow: 0 1px 3px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --crm-header-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.03);
}

.crm-page-content {
  margin-left: var(--crm-sider-width);
  margin-top: var(--crm-header-height);
  min-height: calc(100vh - var(--crm-header-height));
  padding: 24px;
  background: var(--antd-bg);
  transition: margin-left 0.2s;
}

.crm-antd-surface {
  max-width: 1280px;
  margin: 0 auto;
}

/* Sidebar shell: white floating panel on soft slate canvas */
.crm-app-sider.ant-layout-sider {
  background: var(--crm-sider-bg) !important;
  border-right: 1px solid var(--antd-border);
  box-shadow: var(--crm-sider-shadow);
}

.crm-app-sider .ant-layout-sider-children {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

/* Sidebar brand: logo stacked above app name */
.crm-app-sider .crm-brand-wrap {
  border-bottom: 1px solid #e2e8f0;
  padding: 18px 14px 16px;
  width: 100%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 -1px 0 rgba(15, 23, 42, 0.03);
}

.crm-app-sider .crm-brand-link {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  text-align: center;
  text-decoration: none;
  color: inherit;
}

.crm-app-sider .crm-brand-logo {
  display: block;
  align-self: center;
  width: auto;
  max-width: 100%;
  height: 56px;
  flex-shrink: 0;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 2px 6px rgba(15, 23, 42, 0.08));
}

.crm-app-sider.ant-layout-sider-collapsed .crm-brand-logo {
  width: auto;
  max-width: 48px;
  height: 36px;
}

.crm-app-sider .crm-brand-name {
  display: block;
  width: 100%;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #334155;
  white-space: normal;
  word-break: break-word;
  overflow: visible;
  text-overflow: unset;
}

.crm-side-menu.ant-menu {
  font-size: 14px;
  padding: 10px 8px 16px;
  background: transparent !important;
}

.crm-side-menu .ant-menu-item,
.crm-side-menu .ant-menu-submenu-title {
  height: 40px !important;
  line-height: 40px !important;
  margin-block: 2px !important;
  margin-inline: 0 !important;
  width: 100% !important;
  border-radius: 10px !important;
  color: #475569;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.crm-side-menu .ant-menu-item:hover,
.crm-side-menu .ant-menu-submenu-title:hover {
  color: #0f766e !important;
  background: rgba(13, 148, 136, 0.08) !important;
}

.crm-side-menu .ant-menu-submenu-open > .ant-menu-submenu-title {
  color: #0f766e !important;
  background: rgba(13, 148, 136, 0.06) !important;
}

.crm-side-menu .ant-menu-sub.ant-menu-inline {
  background: transparent !important;
  padding-left: 0 !important;
}

.crm-side-menu .ant-menu-sub .ant-menu-item {
  padding-left: 36px !important;
  height: 40px !important;
  line-height: 40px !important;
}

.crm-side-menu .ant-menu-title-content,
.crm-side-menu .ant-menu-title-content a {
  font-size: 14px;
  font-weight: 500;
  color: inherit;
}

.crm-side-menu .ant-menu-item-icon,
.crm-side-menu .ant-menu-submenu-title .anticon {
  font-size: 16px;
}

.crm-side-menu .ant-menu-item-selected {
  color: #0f766e !important;
  background: linear-gradient(90deg, rgba(13, 148, 136, 0.14), rgba(13, 148, 136, 0.06)) !important;
  box-shadow: inset 3px 0 0 #0d9488;
  font-weight: 600;
}

.crm-side-menu .ant-menu-item-selected .ant-menu-title-content a {
  color: #0f766e;
}

.crm-side-menu .ant-menu-item-selected .ant-menu-item-icon {
  color: #0d9488;
}

.crm-app-header.ant-layout-header {
  background: rgba(255, 255, 255, 0.92) !important;
  border-bottom: 1px solid var(--antd-border);
  backdrop-filter: blur(10px);
  box-shadow: var(--crm-header-shadow);
}

.crm-header-btn-mobile {
  display: inline-flex !important;
}

.crm-header-btn-desktop {
  display: none !important;
}

.crm-app-header .crm-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
  height: 64px;
}

.crm-header-left {
  flex-shrink: 0;
}

.crm-header-marquee-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 32px;
}

.crm-header-marquee {
  display: none;
  flex: 1;
  min-width: 0;
  max-width: 100%;
  height: 32px;
  align-items: center;
  overflow: hidden;
  text-decoration: none;
  color: rgba(0, 0, 0, 0.55);
  font-size: 13px;
  line-height: 32px;
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
}

.crm-header-marquee:hover {
  color: rgba(0, 0, 0, 0.75);
}

.crm-header-marquee-static {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.crm-header-marquee-scroll {
  display: flex;
  width: max-content;
  animation: crm-header-marquee-scroll 28s linear infinite;
}

.crm-header-marquee:hover .crm-header-marquee-scroll {
  animation-play-state: paused;
}

.crm-header-marquee-track {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding-right: 48px;
}

.crm-header-marquee-item {
  white-space: nowrap;
}

.crm-header-marquee-item + .crm-header-marquee-item::before {
  content: '·';
  margin: 0 16px;
  color: rgba(0, 0, 0, 0.25);
}

@keyframes crm-header-marquee-scroll {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-50%);
  }
}

.crm-app-header .crm-header-company {
  display: none;
  align-items: center;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 32px;
  height: 32px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.75);
  padding-right: 12px;
  margin-right: 4px;
  border-right: 1px solid #e2e8f0;
  box-sizing: border-box;
}

.crm-app-header .crm-header-lang {
  display: inline-flex !important;
  align-items: center !important;
  height: 32px !important;
  line-height: 32px !important;
  padding-left: 8px !important;
  padding-right: 8px !important;
}

.crm-app-header .crm-header-actions .ant-btn-icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.crm-app-header .crm-header-actions .crm-header-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.crm-app-header .crm-header-actions .crm-header-user-name {
  display: none;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 32px;
  color: #334155;
}

@media (min-width: 768px) {
  .crm-header-marquee {
    display: flex;
  }

  .crm-app-header .crm-header-company {
    display: inline-flex;
    max-width: 240px;
  }

  .crm-app-header .crm-header-actions .crm-header-user-name {
    display: inline-block;
  }
}

@media (prefers-reduced-motion: reduce) {
  .crm-header-marquee-scroll {
    display: none;
  }

  .crm-header-marquee-static {
    display: block;
  }
}

@media (min-width: 992px) {
  .crm-header-btn-mobile {
    display: none !important;
  }

  .crm-header-btn-desktop {
    display: inline-flex !important;
  }

  .crm-mobile-nav-drawer {
    display: none !important;
  }
}

@media (min-width: 1200px) {
  .crm-app-header .crm-header-company {
    max-width: 320px;
  }
}

@media (max-width: 991px) {
  .crm-page-content { margin-left: 0; }
  .crm-app-sider { display: none !important; }
  .crm-app-header-wrap { margin-left: 0 !important; }
  .crm-app-header { left: 0 !important; }
}

.crm-auth-content {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  isolation: isolate;
  background-color: #0b1a2e;
  background-image:
    /* Soft center vignette so the form stays readable over the nebula */
    radial-gradient(ellipse 70% 65% at 50% 45%, rgba(8, 20, 40, 0.28) 0%, rgba(8, 20, 40, 0.45) 70%, rgba(6, 12, 28, 0.55) 100%),
    linear-gradient(180deg, rgba(12, 28, 58, 0.2) 0%, transparent 35%, rgba(8, 18, 40, 0.35) 100%),
    url('../images/auth-login-bg.jpg');
  background-size: cover, cover, cover;
  background-position: center, center, center;
  background-repeat: no-repeat;
}

/* Subtle edge fade — keep artwork visible, no competing patterns */
.crm-auth-content::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    ellipse 90% 80% at 50% 40%,
    transparent 35%,
    rgba(6, 12, 28, 0.35) 100%
  );
}

.crm-auth-content::after {
  content: none;
}

.crm-auth-content > * {
  position: relative;
  z-index: 1;
}

@media (min-width: 640px) {
  .crm-auth-content {
    padding: 24px;
  }
}

@media (min-width: 1024px) {
  .crm-auth-content {
    padding: 32px;
  }
}

.crm-auth-content > .crm-antd-surface {
  width: 100%;
  max-width: min(100%, 420px);
  background: transparent;
  box-shadow: none;
}

.crm-auth-shell {
  width: 100%;
}

.crm-auth-panel {
  width: 100%;
  animation: crm-auth-enter 0.35s ease-out both;
}

@keyframes crm-auth-enter {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .crm-auth-panel {
    animation: none;
  }
}

.crm-auth-brand-logo {
  display: block;
  margin: 0 auto 1.25rem;
  width: auto;
  max-width: min(100%, 280px);
  height: 64px;
  object-fit: contain;
  object-position: center;
}

.crm-auth-title {
  font-size: 1.125rem !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  color: rgba(15, 35, 55, 0.92) !important;
}

@media (min-width: 640px) {
  .crm-auth-title {
    font-size: 1.25rem !important;
  }
}

.crm-auth-subtitle {
  display: block;
  margin-top: 0.5rem !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  color: rgba(51, 80, 110, 0.9) !important;
}

.crm-auth-lang-float {
  position: fixed !important;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: inline-flex !important;
  align-items: center !important;
  height: 36px !important;
  line-height: 36px !important;
  padding: 0 14px !important;
  border-radius: 8px !important;
  border: 1px solid rgba(165, 243, 252, 0.4) !important;
  background: rgba(15, 35, 65, 0.5) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #e0f2fe !important;
  font-weight: 500 !important;
  box-shadow: 0 4px 20px rgba(8, 20, 40, 0.3);
}

.crm-auth-lang-float:hover {
  background: rgba(13, 148, 136, 0.45) !important;
  color: #ecfdf5 !important;
  border-color: rgba(94, 234, 212, 0.55) !important;
}

@media (min-width: 640px) {
  .crm-auth-lang-float {
    top: 24px;
    right: 24px;
  }
}

.crm-auth-form-card.ant-card {
  background: linear-gradient(
    165deg,
    rgba(248, 252, 255, 0.94) 0%,
    rgba(255, 255, 255, 0.9) 50%,
    rgba(240, 253, 250, 0.92) 100%
  ) !important;
  border: 1px solid rgba(186, 230, 253, 0.65) !important;
  border-radius: 12px !important;
  box-shadow:
    0 0 0 1px rgba(56, 189, 248, 0.08),
    0 12px 40px rgba(8, 20, 40, 0.4),
    0 0 40px rgba(45, 212, 191, 0.1) !important;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.crm-auth-form-card .ant-card-body {
  padding: 24px 20px;
}

@media (min-width: 480px) {
  .crm-auth-form-card .ant-card-body {
    padding: 32px 36px;
  }
}

.crm-auth-page-footer {
  margin: 20px 0 0;
  text-align: center;
  font-size: 0.75rem;
  line-height: 1.5;
  color: rgba(224, 242, 254, 0.78);
  text-shadow: 0 1px 3px rgba(6, 12, 28, 0.55);
}

/* ---- Typography ---- */
.crm-antd-surface h1,
.crm-antd-surface h2,
.crm-antd-surface h3 {
  color: var(--antd-text);
  font-weight: 600;
}

.crm-antd-surface h2.text-2xl,
.crm-antd-surface h2.text-xl {
  font-size: 20px;
  margin-bottom: 16px;
}

.crm-antd-surface h3.text-base,
.crm-antd-surface h3.font-semibold {
  font-size: 16px;
}

/* ---- Cards / surfaces ---- */
.crm-antd-surface .bg-white,
.crm-page-content .bg-white.rounded-xl,
.crm-page-content .bg-white.rounded-2xl {
  background: #fff !important;
  border: 1px solid var(--antd-border) !important;
  border-radius: 8px !important;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.03), 0 1px 6px -1px rgb(0 0 0 / 0.02);
}

.crm-antd-surface .shadow-sm,
.crm-antd-surface .shadow-lg {
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.03), 0 2px 8px rgb(0 0 0 / 0.04) !important;
}

/* ---- Buttons ---- */
.crm-antd-surface .bg-teal-600,
.crm-antd-surface button.bg-teal-600,
.crm-antd-surface a.bg-teal-600,
.crm-antd-surface [type="submit"].bg-teal-600 {
  background-color: var(--antd-primary) !important;
  border: 1px solid var(--antd-primary) !important;
  color: #fff !important;
  border-radius: 6px !important;
  font-weight: 500;
  transition: all 0.2s;
}

.crm-antd-surface .bg-teal-600:hover,
.crm-antd-surface button.bg-teal-600:hover,
.crm-antd-surface a.bg-teal-600:hover,
.crm-antd-surface .hover\:bg-teal-700:hover {
  background-color: var(--antd-primary-hover) !important;
  border-color: var(--antd-primary-hover) !important;
}

.crm-antd-surface a.border:not(.bg-teal-600),
.crm-antd-surface button.border:not(.bg-teal-600),
.crm-antd-surface .border.rounded-xl:not(.bg-teal-600) {
  border-color: #d9d9d9 !important;
  border-radius: 6px !important;
  background: #fff;
}

.crm-antd-surface a.border:hover:not(.bg-teal-600),
.crm-antd-surface button.border:hover:not(.bg-teal-600) {
  color: var(--antd-primary) !important;
  border-color: var(--antd-primary) !important;
}

/* ---- Forms (legacy native controls — exclude Ant Design widgets) ---- */
.crm-antd-surface input:where(
  [type="text"],
  [type="email"],
  [type="password"],
  [type="search"],
  [type="number"],
  [type="date"]
):not([class^="ant-"]),
.crm-antd-surface input[type="file"],
.crm-antd-surface select,
.crm-antd-surface textarea:not([class^="ant-"]) {
  border: 1px solid #d9d9d9 !important;
  border-radius: 6px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  transition: all 0.2s;
  background: #fff;
}

.crm-antd-surface input:where(
  [type="text"],
  [type="email"],
  [type="password"],
  [type="search"],
  [type="number"],
  [type="date"]
):not([class^="ant-"]):focus,
.crm-antd-surface select:focus,
.crm-antd-surface textarea:not([class^="ant-"]):focus {
  border-color: var(--antd-primary) !important;
  box-shadow: 0 0 0 2px rgb(13 148 136 / 0.1) !important;
  outline: none !important;
}

.crm-antd-surface .ant-select .ant-select-input,
.crm-antd-surface .ant-select input,
.crm-antd-surface .ant-picker input,
.crm-antd-surface .ant-input-number input {
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  background: transparent !important;
  outline: none !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  min-height: unset !important;
}

.crm-antd-surface .crm-filter-bar .ant-select {
  min-width: 200px;
}

.crm-antd-surface .crm-filter-bar .ant-select-selector {
  border-radius: 8px !important;
}

.crm-antd-surface label {
  color: var(--antd-text);
  font-size: 14px;
  font-weight: 500;
}

/* ---- Tables ---- */
.crm-antd-surface table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--antd-border);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  font-size: 14px;
}

.crm-antd-surface thead {
  background: #fafafa;
}

.crm-antd-surface thead th {
  color: var(--antd-text-secondary);
  font-weight: 500;
  padding: 12px 16px;
  border-bottom: 1px solid var(--antd-border);
  text-align: left;
}

/* Respect Tailwind alignment utilities (higher specificity than the default left). */
.crm-antd-surface thead th.text-center {
  text-align: center;
}

.crm-antd-surface thead th.text-right {
  text-align: right;
}

.crm-antd-surface tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f5f5f5;
  color: var(--antd-text);
}

.crm-antd-surface tbody tr:hover {
  background: #fafafa;
}

.crm-antd-surface tbody tr:last-child td {
  border-bottom: none;
}

/* ---- Tabs (pipeline etc.) ---- */
.crm-antd-surface .border-b a,
.crm-antd-surface .flex.gap-1.border-b a {
  border-bottom: 2px solid transparent;
  color: var(--antd-text-secondary);
  padding: 12px 16px;
  margin-bottom: -1px;
  font-weight: 500;
}

.crm-antd-surface .border-b a.border-teal-600,
.crm-antd-surface .flex.gap-1.border-b a.border-teal-600 {
  border-bottom-color: var(--antd-primary) !important;
  color: var(--antd-primary) !important;
}

/* ---- Tags / badges ---- */
.crm-antd-surface .rounded-full,
.crm-antd-surface .rounded-lg.text-xs {
  border-radius: 4px !important;
  font-size: 12px;
  padding: 2px 8px;
}

/* ---- Lists / dividers ---- */
.crm-antd-surface .divide-y > * + * {
  border-top: 1px solid #f0f0f0;
}

.crm-antd-surface .border-t,
.crm-antd-surface hr {
  border-color: #f0f0f0 !important;
}

/* ---- Links ---- */
.crm-antd-surface a.text-teal-600,
.crm-antd-surface .hover\:text-teal-600:hover {
  color: var(--antd-primary) !important;
}

/* ---- Kanban ---- */
.crm-antd-surface .kanban-drop-zone {
  background: #fff;
  border: 1px solid var(--antd-border);
  border-radius: 0 0 8px 8px;
}

.crm-antd-surface .kanban-card {
  border-bottom: 1px solid #f5f5f5;
}

/* ---- Alerts / flash legacy ---- */
.crm-antd-surface .bg-teal-50.border-teal-200 {
  background: #e6fffb !important;
  border-color: #87e8de !important;
  border-radius: 8px;
}

.crm-antd-surface .bg-amber-50,
.crm-antd-surface .bg-red-50 {
  border-radius: 8px;
}

/* ---- Pagination ---- */
.crm-antd-surface .rounded-lg.text-xs.bg-teal-50 {
  background: #f0fdfa !important;
  color: var(--antd-primary) !important;
  border: 1px solid #99f6e4;
}

/* ---- Grid cards hover ---- */
.crm-antd-surface a.block.bg-white:hover,
.crm-antd-surface a.hover\:shadow-md:hover {
  border-color: #99f6e4 !important;
}

/* ---- Details / descriptions ---- */
.crm-antd-surface .text-slate-500 { color: var(--antd-text-secondary) !important; }
.crm-antd-surface .text-slate-800,
.crm-antd-surface .text-slate-700 { color: var(--antd-text) !important; }

/* ---- Print ---- */
@media print {
  /* Avoid trailing blank pages from shell / viewport min-heights */
  html, body {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  #antd-app-shell,
  .no-print,
  .crm-app-sider,
  .crm-app-header-wrap {
    display: none !important;
  }
  .crm-page-content {
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }
  .crm-antd-surface {
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 0 !important;
    height: auto !important;
    overflow: visible !important;
  }
  /* Screen table chrome uses overflow:hidden; that clips multi-page print. */
  .crm-antd-surface table {
    overflow: visible !important;
  }
}
