/* ========================================
   CRM System - Custom Styles
   ======================================== */
:root {
  --crm-primary: #3b82f6;
  --crm-success: #10b981;
  --crm-warning: #f59e0b;
  --crm-danger: #ef4444;
  --crm-info: #06b6d4;
  --crm-purple: #8b5cf6;
  --crm-bg: #f8fafc;
  --crm-card-bg: #ffffff;
  --crm-border: #e2e8f0;
  --crm-text: #1e293b;
  --crm-text-muted: #64748b;
  --crm-sidebar-width: 260px;
  --crm-topbar-height: 70px;
}
* {
  font-family: 'Kanit', sans-serif;
}
body {
  background-color: var(--crm-bg);
  margin: 0;
  padding: 0;
}
/* ========================================
   Layout
   ======================================== */
.main-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.main-content > div {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1;
  padding: 2rem;
  margin-left: var(--crm-sidebar-width);
  margin-top: var(--crm-topbar-height);
  background-color: var(--crm-bg);
}
/* ========================================
   Sidebar
   ======================================== */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--crm-sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: white;
  z-index: 1000;
  overflow-y: auto;
}
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 1rem;
}
.sidebar-header .logo {
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-purple));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  text-decoration: none;
}
.sidebar-header .logo-text {
  font-size: 1.25rem;
  font-weight: 600;
}
/* ========================================
   Topbar
   ======================================== */
.topbar {
  position: fixed;
  top: 0;
  left: var(--crm-sidebar-width);
  right: 0;
  height: var(--crm-topbar-height);
  z-index: 999;
  background: white;
  border-bottom: 1px solid var(--crm-border);
}
.topbar > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: inherit;
}
.topbar .avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
}
.topbar-left {
  flex: 1;
}
.topbar-left h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--crm-text);
}
.topbar-left p {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: var(--crm-text-muted);
}
.topbar-left p,
.topbar-right .user-name {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-right .user-profile {
  background-color: transparent;
  color: inherit;
  border: none;
  padding-left: 0;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}
.user-info {
  text-align: left;
}
.user-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--crm-text);
  display: block;
}
.user-role {
  font-size: 0.75rem;
  color: var(--crm-text-muted);
}
/* ========================================
   Dashboard Cards
   ======================================== */
.card-groups {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.card-groups > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}
.card-groups h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  color: var(--crm-text);
}
.card-groups > header p {
  margin: 0.5rem 0 0 0;
  color: var(--crm-text-muted);
}
.stat-card {
  background: var(--crm-card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--crm-border);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--crm-primary), var(--crm-purple));
}
.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}
.stat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.stat-header::before {
  font-size: 1.5rem;
  opacity: 0.8;
}
.stat-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--crm-text);
  margin-bottom: 0.5rem;
}
.stat-change {
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.stat-card.positive .stat-change {
  color: var(--crm-success);
}
.stat-card.negative .stat-change {
  color: var(--crm-danger);
}
/* ========================================
   Kanban Board
   ======================================== */
#kanban-board {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 2rem;
}
.kanban-column {
  background: var(--crm-card-bg);
  border-radius: 12px;
  border: 1px solid var(--crm-border);
  padding: 1rem;
  min-height: 500px;
  width: 300px;
}
.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--crm-border);
}
.column-title {
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--crm-text);
}
.column-count {
  background: var(--crm-bg);
  color: var(--crm-text-muted);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.column-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 100px;
}
.deal-card {
  background: white;
  border: 1px solid var(--crm-border);
  border-radius: 8px;
  padding: 1rem;
  cursor: move;
  transition: all 0.2s;
}
.deal-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}
.deal-card.sortable-ghost {
  opacity: 0.4;
  background: var(--crm-bg);
}
.deal-title {
  font-weight: 600;
  color: var(--crm-text);
  margin-bottom: 0.5rem;
}
.deal-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--crm-primary);
  margin-bottom: 0.75rem;
}
.deal-customer {
  font-size: 0.875rem;
  color: var(--crm-text-muted);
  margin-bottom: 0.5rem;
}
.deal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--crm-text-muted);
  padding-top: 0.75rem;
  border-top: 1px solid var(--crm-border);
}
.deal-probability {
  background: var(--crm-bg);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}
/* ========================================
   Charts
   ======================================== */
.content-body,
.ggrid section {
  background: var(--crm-card-bg);
  border-radius: 16px;
  padding: 1.5rem;
  border: 1px solid var(--crm-border);
}
.ggrid section h2 {
  margin: 0 0 1.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--crm-text);
}
/* ========================================
   Footer
   ======================================== */
.footer {
  background: white;
  border-top: 1px solid var(--crm-border);
  padding: 1.5rem 2rem;
  margin-left: var(--crm-sidebar-width);
  text-align: center;
}
.footer p {
  margin: 0;
  color: var(--crm-text-muted);
  font-size: 0.875rem;
}
.footer a {
  color: var(--crm-primary);
  text-decoration: none;
}
.footer a:hover {
  text-decoration: underline;
}
/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  .content {
    margin-left: 0;
    padding: 1rem;
  }
  .sidebar {
    transform: translateX(-100%);
  }
  .topbar {
    left: 0;
    padding: 0 1rem;
  }
  .footer {
    margin-left: 0;
  }
  .kanban-board {
    grid-template-columns: 1fr;
  }
  .content-body, .ggrid section {
    padding: 1rem;
  }
}
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.auth-form {
  background: white;
  padding: 2.5rem;
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}
.auth-form fieldset {
  margin-bottom: 0 !important;
}
.auth-form a {
  color: var(--crm-primary);
}
.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-purple));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: white;
  margin: 0 auto 1rem;
}
.login-card h1 {
  font-weight: 700;
  color: var(--crm-text);
  margin: 0;
}
/* Trophy Icon Styles */
.icon-win.gold {
  font-size: 1.75rem;
  color: #ffd700;
  filter: drop-shadow(0 2px 6px rgba(255, 215, 0, 0.8)) drop-shadow(0 0 10px rgba(255, 215, 0, 0.5)) brightness(1);
}
.icon-win.silver {
  font-size: 1.75rem;
  color: #c0c0c0;
  filter: drop-shadow(0 4px 12px rgba(192, 192, 192, 1)) drop-shadow(0 0 20px rgba(192, 192, 192, 0.8)) brightness(1.2);
}
.icon-win.bronze {
  font-size: 1.75rem;
  color: #cd7f32;
  filter: drop-shadow(0 4px 12px rgba(205, 127, 50, 1)) drop-shadow(0 0 20px rgba(205, 127, 50, 0.8)) brightness(1.15);
}
.dashboard td {
  white-space: nowrap;
}
form fieldset legend {
  font-weight: 600;
  margin-bottom: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--crm-border);
  font-size: var(--font-size-2xl);
}
/* ========================================
   Form Tabs - Custom Tabs Style for Forms
   ======================================== */
.form-tabs-nav {
  display: flex;
  justify-content: space-between;
  padding: 0;
  gap: 0;
  overflow-x: auto;
}
.form-tabs-nav button {
  display: flex;
  flex-direction: column;
  height: auto;
  align-items: center;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.5rem 5px
}
.form-tab:hover {
  background: rgba(59, 130, 246, 0.05);
}
.form-tab:hover .form-tab-icon {
  transform: scale(1.1);
  color: var(--crm-primary);
}
.form-tab-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--crm-text-muted);
  transition: all 0.3s ease;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.form-tab-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: white;
  border: 2px solid var(--crm-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--crm-text-muted);
  transition: all 0.3s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.form-tab[aria-selected="true"] {
  background: white;
  border-bottom-color: var(--crm-primary);
}
.form-tab[aria-selected="true"] .form-tab-icon {
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-purple));
  border-color: var(--crm-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}
.form-tab[aria-selected="true"] .form-tab-label {
  color: var(--crm-primary);
  font-weight: 600;
}
.form-tab-panel {
  display: none;
  animation: formTabFadeIn 0.4s ease;
  margin-top: 1.25rem;
}
.form-tab-panel:not([hidden]) {
  display: flex;
}
.form-tab-panel legend {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--crm-text);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--crm-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.form-tab-panel legend::before {
  content: '';
  width: 4px;
  height: 24px;
  background: linear-gradient(180deg, var(--crm-primary), var(--crm-purple));
  border-radius: 2px;
}
@keyframes formTabFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (max-width: 768px) {
  .form-tabs-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .form-tab-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
  .form-tab-label {
    font-size: 0.75rem;
  }
}
@media (max-width: 480px) {
  .form-tab {
    flex-direction: row;
    padding: 0.875rem 1rem;
    gap: 0.75rem;
    min-width: auto;
  }
  .form-tab-icon {
    width: 32px;
    height: 32px;
  }
}
/* ========================================
   Customer Detail View - Read-only Display
   ======================================== */
.customer-detail {
  background: var(--crm-card-bg);
  border-radius: 16px;
  overflow: hidden;
}
/* Customer Header */
.customer-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  background: linear-gradient(135deg, var(--crm-primary) 0%, var(--crm-purple) 100%);
  color: white;
}
.customer-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  border: 3px solid rgba(255, 255, 255, 0.3);
}
.customer-title h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}
.customer-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.customer-meta .badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}
.customer-meta .meta-item {
  font-size: 0.875rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.customer-meta .meta-item::before {
  font-size: 0.875rem;
}
.customer-actions {
  margin-left: auto;
}
.rating-stars {
  font-size: 1.25rem;
  letter-spacing: 2px;
}
/* Detail Grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  width: 100%;
}
.detail-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.detail-item.full-width {
  grid-column: span 2;
}
.detail-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--crm-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.detail-label::before {
  font-size: 0.875rem;
  opacity: 0.7;
}
.detail-value {
  font-size: 1rem;
  color: var(--crm-text);
  font-weight: 500;
}
.detail-value.highlight {
  color: var(--crm-primary);
  font-weight: 700;
  font-size: 1.125rem;
}
.detail-value.link {
  color: var(--crm-primary);
  text-decoration: none;
  cursor: pointer;
}
.detail-value.link:hover {
  text-decoration: underline;
  background: rgba(59, 130, 246, 0.05);
}
.detail-value.notes {
  white-space: pre-wrap;
  line-height: 1.6;
}
.detail-value .badge {
  display: inline-block;
}
/* Responsive Detail Grid */
@media (max-width: 768px) {
  .customer-header {
    flex-direction: column;
    text-align: center;
    padding: 1.5rem;
  }
  .customer-actions {
    margin-left: 0;
  }
  .customer-meta {
    justify-content: center;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .detail-item.full-width {
    grid-column: span 1;
  }
}
/* Detail Sections - Single Page Layout */
.detail-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.detail-section {
  border-radius: 16px;
  border: 1px solid var(--crm-border);
  padding: 1rem;
}
.detail-section:first-child {
  border-style: none solid solid solid;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--crm-text);
  margin: 0 0 1.25rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--crm-border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-title::before {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--crm-primary), var(--crm-purple));
  color: white;
  border-radius: 8px;
  font-size: 1rem;
}
td .userinfo {
  display: flex;
  align-items: center;
  gap: 5px;
}
.userinfo > span {
  display: flex;
  flex-direction: column;
}
.userinfo a {
  font-size: 0.875rem;
}
.usericon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 9999px;
  font-weight: bold;
  background-color: var(--crm-primary);
  color: white;
  background-size: cover;
  background-position: center;
  text-transform: uppercase;
}
.usericon[style*="url("]:not([style*="url(null)"]) {
  color: transparent;
}
.btn-table-action[data-action="active"][data-value="0"]:before,
.btn-table-action[data-action="active"][data-value="1"]:before {
  content: "✓";
  color: var(--color-silver);
  font-size: 1.5rem;
}
.btn-table-action[data-action="active"][data-value="1"]:before {
  color: var(--crm-success);
}
td a {
  color: var(--crm-primary);
}