/**
 * Kanban Boards CSS
 * Trello-style drag-and-drop board interface
 */

/* ===========================================
   MAIN LAYOUT
   =========================================== */

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 0;
  overflow: hidden;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ===========================================
   BOARD HEADER
   =========================================== */

.board-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
}

.board-header-left,
.board-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.board-selector {
  min-width: 240px;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-900);
  background: white;
  cursor: pointer;
}

.board-selector:focus {
  outline: none;
  border-color: var(--primary-light, #2E7A64);
  box-shadow: 0 0 0 3px rgba(46, 122, 100, 0.1);
}

.icon-btn {
  padding: 8px;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.icon-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
  color: var(--gray-900);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--primary, #1E4D3F);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-dark, #163D32);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary svg {
  width: 18px;
  height: 18px;
}

.btn-secondary {
  padding: 8px 16px;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  padding: 8px 16px;
  background: white;
  border: 1px solid #EF4444;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #EF4444;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-danger:hover {
  background: #FEF2F2;
  border-color: #DC2626;
  color: #DC2626;
}

.btn-text {
  padding: 4px 8px;
  background: none;
  border: none;
  color: var(--primary, #1E4D3F);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
}

.btn-text:hover {
  text-decoration: underline;
}

/* ===========================================
   DASHBOARD METRICS
   =========================================== */

.dashboard-metrics {
  padding: 16px 24px;
  background: white;
  border-bottom: 1px solid var(--gray-200);
  flex-shrink: 0;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.dashboard-metrics.hidden {
  max-height: 0;
  padding: 0 24px;
  overflow: hidden;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
}

.metric-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-period-select {
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--gray-600);
  background: white;
  cursor: pointer;
}

.metric-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.metric-subtext {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ===========================================
   BOARD CONTAINER
   =========================================== */

.board-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 24px;
}

.board-columns {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 280px;
  gap: 16px;
  min-height: 100%;
  padding-bottom: 24px;
}

/* ===========================================
   KANBAN COLUMN
   =========================================== */

.kanban-column {
  display: flex;
  flex-direction: column;
  background: var(--gray-100);
  border-radius: 12px;
  padding: 12px;
  max-height: calc(100vh - 220px);
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.column-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.column-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--gray-300);
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-700);
}

.column-menu-btn {
  padding: 4px;
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
}

.column-menu-btn:hover {
  background: var(--gray-200);
  color: var(--gray-600);
}

.column-menu-btn svg {
  width: 16px;
  height: 16px;
}

.column-cards {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px;
  min-height: 60px;
}

/* ===========================================
   KANBAN CARD
   =========================================== */

.kanban-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.kanban-card:hover {
  border-color: var(--gray-300);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.kanban-card.card-dragging {
  opacity: 0.5;
  cursor: grabbing;
}

.card-ghost {
  background: #EEF5F1;
  border: 2px dashed rgba(46, 122, 100, 0.4);
}

.card-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-900);
  margin-bottom: 8px;
  line-height: 1.4;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--gray-500);
}

.card-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-meta-item svg {
  width: 14px;
  height: 14px;
}

.card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.card-label {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.6875rem;
  font-weight: 500;
  background: var(--gray-200);
  color: var(--gray-700);
}

.card-label.high-priority {
  background: #FEE2E2;
  color: #991B1B;
}

.card-label.follow-up {
  background: #FEF3C7;
  color: #92400E;
}

/* ===========================================
   FAST ADD MODAL
   =========================================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 12px;
  width: 480px;
  max-width: 90vw;
  max-height: 90vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  padding: 4px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  border-radius: 4px;
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.modal-close svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}

/* ===========================================
   CARD DRAWER (Slide from right)
   =========================================== */

.card-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1100;
  pointer-events: none;
}

.card-drawer.active {
  pointer-events: all;
}

.card-drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.card-drawer.active .card-drawer-overlay {
  opacity: 1;
  pointer-events: all;
}

.card-drawer-content {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 90vw;
  background: white;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.card-drawer.active .card-drawer-content {
  transform: translateX(0);
}

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

.card-drawer-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
}

.card-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.card-drawer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}

.card-drawer-footer-right {
  display: flex;
  gap: 12px;
}

.card-drawer-section {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--gray-200);
}

.card-drawer-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 12px;
}

/* ===========================================
   FORM CONTROLS
   =========================================== */

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

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--gray-900);
  background: white;
  transition: border-color 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light, #2E7A64);
  box-shadow: 0 0 0 3px rgba(46, 122, 100, 0.1);
}

.form-control::placeholder {
  color: var(--gray-400);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
}

/* ===========================================
   CLIENT SEARCH
   =========================================== */

.client-link-display {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 8px;
}

#clientLinkText {
  font-size: 0.875rem;
  color: var(--gray-700);
}

.client-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  max-height: 200px;
  overflow-y: auto;
  z-index: 1001;
  margin-top: 4px;
}

.client-search-item {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
}

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

.client-search-item:hover {
  background: var(--gray-50);
}

.client-search-item strong {
  color: var(--gray-900);
}

/* ===========================================
   ACTIVITY LOG
   =========================================== */

.activity-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-log-loading {
  text-align: center;
  padding: 20px;
  color: var(--gray-400);
  font-size: 0.875rem;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
}

.activity-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #C8E0D8;
  color: var(--primary, #1E4D3F);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon svg {
  width: 16px;
  height: 16px;
}

.activity-content {
  flex: 1;
}

.activity-text {
  font-size: 0.875rem;
  color: var(--gray-700);
  line-height: 1.5;
}

.activity-timestamp {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ===========================================
   EMPTY STATE
   =========================================== */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-500);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--gray-300);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* ===========================================
   TOAST NOTIFICATIONS
   =========================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
  min-width: 280px;
}

.toast.success {
  background: #065F46;
  color: white;
}

.toast.error {
  background: #991B1B;
  color: white;
}

.toast.warning {
  background: #92400E;
  color: white;
}

.toast.info {
  background: #1E40AF;
  color: white;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ===========================================
   UTILITY CLASSES
   =========================================== */

.hidden {
  display: none !important;
}

.visible-flex {
  display: flex !important;
}

.visible-block {
  display: block !important;
}

.text-center {
  text-align: center;
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .main-content {
    margin-left: 0;
  }

  .board-header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .board-header-left,
  .board-header-right {
    width: 100%;
  }

  .board-selector {
    width: 100%;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .board-columns {
    grid-auto-columns: 260px;
  }

  .card-drawer-content {
    width: 100%;
    max-width: 100%;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    margin: 20px;
  }
}

/* ===========================================
   SIDEBAR INTEGRATION
   =========================================== */

.sidebar {
  width: 260px;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo {
  width: 32px;
  height: 32px;
}

.sidebar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-900);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.875rem;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.nav-item.active {
  background: #EEF5F1;
  color: var(--primary, #1E4D3F);
}

.nav-item svg {
  width: 20px;
  height: 20px;
}

/* ===========================================
   SCROLLBAR STYLING
   =========================================== */

.column-cards::-webkit-scrollbar,
.board-container::-webkit-scrollbar,
.card-drawer-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.column-cards::-webkit-scrollbar-track,
.board-container::-webkit-scrollbar-track,
.card-drawer-body::-webkit-scrollbar-track {
  background: transparent;
}

.column-cards::-webkit-scrollbar-thumb,
.board-container::-webkit-scrollbar-thumb,
.card-drawer-body::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}

.column-cards::-webkit-scrollbar-thumb:hover,
.board-container::-webkit-scrollbar-thumb:hover,
.card-drawer-body::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}
