/* PipeLine IQ Custom Styles */

/* Color Palette - Blues and Greys */
:root {
  --primary-blue: #2563eb;
  --primary-blue-dark: #1e40af;
  --primary-blue-light: #3b82f6;
  --accent-blue: #0ea5e9;
  --grey-dark: #374151;
  --grey-medium: #6b7280;
  --grey-light: #e5e7eb;
  --grey-lighter: #f3f4f6;
  --grey-lightest: #f9fafb;
  --white: #ffffff;
  --sidebar-width: 280px;
  --header-height: 73px;
}

/* Override Bootstrap primary color */
.text-primary {
  color: var(--primary-blue) !important;
}

.btn-primary {
  background-color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.btn-primary:hover {
  background-color: var(--primary-blue-dark);
  border-color: var(--primary-blue-dark);
}

.btn-outline-primary {
  color: var(--primary-blue);
  border-color: var(--primary-blue);
}

.btn-outline-primary:hover {
  background-color: var(--primary-blue);
  border-color: var(--primary-blue);
}

/* Header Styles */
.header-main {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  z-index: 1040;
  position: relative;
}

/* Sticky navbar on larger screens (lg and up) */
@media (min-width: 992px) {
  .header-main {
    position: sticky;
    top: 0;
  }
}

.navbar-brand {
  font-size: 1.5rem;
  transition: all 0.3s ease;
}

.navbar-brand:hover {
  transform: scale(1.05);
}

.navbar-nav .nav-link {
  color: var(--grey-dark);
  font-weight: 500;
  padding: 0.5rem 1rem;
  transition: all 0.3s ease;
  border-radius: 0.375rem;
  margin: 0 0.25rem;
}

.navbar-nav .nav-link:hover {
  color: var(--primary-blue);
  background-color: var(--grey-lightest);
}

.navbar-nav .nav-link.active {
  color: var(--primary-blue);
  background-color: var(--grey-lighter);
}

/* Desktop Sidebar (Fixed, always visible on large screens) */
.desktop-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background-color: var(--grey-lightest);
  border-right: 1px solid var(--grey-light);
  overflow-y: auto;
  z-index: 1020;
}

/* Off-canvas Sidebar Styles (Mobile only) */
.offcanvas-sidebar {
  width: var(--sidebar-width);
  border-right: 1px solid var(--grey-light);
  background-color: var(--white);
}

.offcanvas-sidebar .offcanvas-header {
  background: linear-gradient(135deg, var(--grey-lightest) 0%, var(--white) 100%);
  padding: 1.25rem 1.5rem;
}

.offcanvas-sidebar .offcanvas-body {
  background-color: var(--grey-lightest);
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 1.5rem 0 1rem 0;
}

.sidebar-nav .nav-link {
  color: var(--grey-dark);
  padding: 0.875rem 1.5rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border-left: 3px solid transparent;
  display: flex;
  align-items: center;
}

.sidebar-nav .nav-link:hover {
  background-color: var(--grey-lighter);
  color: var(--primary-blue);
  border-left-color: var(--primary-blue);
  padding-left: 1.75rem;
}

.sidebar-nav .nav-link.active {
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary-blue);
  border-left-color: var(--primary-blue);
  font-weight: 600;
}

.sidebar-nav .nav-link i {
  width: 20px;
  font-size: 1rem;
}

.sidebar-nav .nav-link.text-danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-left-color: #ef4444;
  color: #dc2626;
}

/* Main Content Area */
.main-content {
  margin-left: 0;
  margin-top: 0;
  transition: margin-left 0.3s ease;
  min-height: calc(100vh - var(--header-height));
  background-color: var(--grey-lightest);
  padding: 2rem;
}

/* Desktop - Show sidebar and push content */
@media (min-width: 992px) {
  .main-content {
    margin-left: var(--sidebar-width);
  }
}

/* Mobile and Tablet - No margin */
@media (max-width: 991.98px) {
  .main-content {
    margin-left: 0;
  }
}

/* Dropdown Menu Styling */
.dropdown-menu {
  border: 1px solid var(--grey-light);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border-radius: 0.5rem;
  margin-top: 0.5rem;
}

.dropdown-item {
  padding: 0.625rem 1.25rem;
  color: var(--grey-dark);
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: var(--grey-lightest);
  color: var(--primary-blue);
}

.dropdown-item i {
  color: var(--grey-medium);
  width: 20px;
}

/* Utility Classes */
.bg-primary-gradient {
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
}

.text-grey {
  color: var(--grey-medium);
}

.text-grey-dark {
  color: var(--grey-dark);
}

/* Card Enhancements */
.card {
  border: 1px solid var(--grey-light);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  transition: all 0.3s ease;
}

.card:hover {
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transform: translateY(-2px);
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Focus Styles */
:focus-visible {
  outline: 2px solid var(--primary-blue);
  outline-offset: 2px;
}

/* Loading States */
.btn.loading {
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid transparent;
  border-radius: 50%;
  border-top-color: currentColor;
  animation: spin 0.6s linear infinite;
  color: var(--white);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Responsive Typography */
@media (max-width: 767.98px) {
  .navbar-brand {
    font-size: 1.25rem;
  }
  
  .main-content {
    padding: 1rem;
  }
}

/* ========================================
   EMAIL INBOX PAGE STYLES
   ======================================== */

/* Email Summary Card */
.email-summary-card {
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--white) 0%, var(--grey-lightest) 100%);
  border: 1px solid var(--grey-light);
}

/* Email Icon Circle */
.email-icon-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* Mailbox List Card */
.mailbox-list-card {
  border-radius: 0.75rem;
  height: fit-content;
  position: sticky;
  top: 1rem;
}

.mailbox-item {
  padding: 0.875rem 1.25rem;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
}

.mailbox-item:hover {
  background-color: var(--grey-lightest);
  border-left-color: var(--primary-blue);
}

.mailbox-item.active {
  background-color: rgba(37, 99, 235, 0.1);
  border-left-color: var(--primary-blue);
  color: var(--primary-blue);
  font-weight: 600;
}

.mailbox-item i {
  color: var(--grey-medium);
  width: 20px;
}

.mailbox-item.active i {
  color: var(--primary-blue);
}

/* Email Messages Card */
.email-messages-card {
  border-radius: 0.75rem;
}

.email-messages-list {
  max-height: 800px;
  overflow-y: auto;
}

/* Email Message Item */
.email-message-item {
  padding: 1.25rem;
  border-bottom: 1px solid var(--grey-light);
  transition: all 0.2s ease;
  cursor: pointer;
}

.email-message-item:last-child {
  border-bottom: none;
}

.email-message-item:hover {
  background-color: var(--grey-lightest);
}

.email-message-item.unread {
  background-color: rgba(37, 99, 235, 0.03);
}

.email-message-item.unread:hover {
  background-color: rgba(37, 99, 235, 0.08);
}

/* Email Avatar */
.email-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--grey-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-dark);
  font-weight: 600;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.email-avatar.unread-avatar {
  background: linear-gradient(135deg, var(--primary-blue-light) 0%, var(--accent-blue) 100%);
  color: var(--white);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

/* Email Message Content */
.email-message-content {
  min-width: 0;
}

.email-from {
  font-weight: 600;
  color: var(--grey-dark);
  margin-bottom: 0.25rem;
}

.email-message-item.unread .email-from {
  color: var(--primary-blue);
  font-weight: 700;
}

.email-subject {
  font-weight: 500;
  color: var(--grey-dark);
  margin-bottom: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-message-item.unread .email-subject {
  font-weight: 600;
}

.email-preview {
  font-size: 0.875rem;
  color: var(--grey-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

/* Email Actions */
.email-actions .btn-link {
  color: var(--grey-medium);
  text-decoration: none;
  transition: all 0.2s ease;
}

.email-actions .btn-link:hover {
  color: var(--primary-blue);
  transform: scale(1.1);
}

/* Stat Cards */
.stat-card {
  border-radius: 0.75rem;
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px -5px rgba(37, 99, 235, 0.15);
}

.stat-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-blue) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.5rem;
  margin: 0 auto;
}

.stat-card h3 {
  color: var(--primary-blue);
  font-weight: 700;
}

/* Badge Enhancements */
.badge {
  padding: 0.35rem 0.75rem;
  font-weight: 600;
  font-size: 0.75rem;
  border-radius: 0.375rem;
}

.bg-success-subtle {
  background-color: rgba(34, 197, 94, 0.1) !important;
}

.text-success {
  color: #16a34a !important;
}

.bg-warning-subtle {
  background-color: rgba(234, 179, 8, 0.1) !important;
}

.text-warning {
  color: #ca8a04 !important;
}

/* Pagination */
.pagination-sm .page-link {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
}

/* Responsive Email Layout */
@media (max-width: 991.98px) {
  .mailbox-list-card {
    position: static;
    margin-bottom: 1.5rem;
  }
  
  .email-messages-list {
    max-height: 600px;
  }
}

@media (max-width: 767.98px) {
  .email-icon-circle {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
  
  .email-avatar {
    width: 36px;
    height: 36px;
    font-size: 0.75rem;
  }
  
  .email-message-item {
    padding: 1rem;
  }
  
  .email-from {
    font-size: 0.9rem;
  }
  
  .email-subject {
    font-size: 0.85rem;
  }
  
  .email-preview {
    font-size: 0.8rem;
    -webkit-line-clamp: 1;
  }
  
  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }
  
  .stat-card h3 {
    font-size: 1.5rem;
  }
}

/* Custom Scrollbar for Email List */
.email-messages-list::-webkit-scrollbar {
  width: 6px;
}

.email-messages-list::-webkit-scrollbar-track {
  background: var(--grey-lightest);
  border-radius: 10px;
}

.email-messages-list::-webkit-scrollbar-thumb {
  background: var(--grey-light);
  border-radius: 10px;
}

.email-messages-list::-webkit-scrollbar-thumb:hover {
  background: var(--grey-medium);
}

/* ========================================
   CUSTOMER/LEAD DETAIL PAGE - SCROLLABLE CARDS
   ======================================== */

/* Scrollable card body for data sections */
.card-body-scrollable {
  max-height: 400px;
  overflow-y: auto;
}

/* Custom scrollbar for scrollable card bodies */
.card-body-scrollable::-webkit-scrollbar {
  width: 6px;
}

.card-body-scrollable::-webkit-scrollbar-track {
  background: var(--grey-lightest);
  border-radius: 10px;
}

.card-body-scrollable::-webkit-scrollbar-thumb {
  background: var(--grey-light);
  border-radius: 10px;
}

.card-body-scrollable::-webkit-scrollbar-thumb:hover {
  background: var(--grey-medium);
}

/* Firefox scrollbar support */
.card-body-scrollable {
  scrollbar-width: thin;
  scrollbar-color: var(--grey-light) var(--grey-lightest);
}

/* Responsive adjustments for smaller screens */
@media (max-width: 767.98px) {
  .card-body-scrollable {
    max-height: 300px;
  }
}
