/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* Trix Editor Styles */
trix-editor {
  border: 1px solid #dee2e6;
  border-radius: 0 0 0.375rem 0.375rem;
  margin: 0;
  padding: 0.75rem;
  min-height: 150px;
  outline: none;
}

trix-editor:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

trix-toolbar {
  border: 1px solid #dee2e6;
  border-bottom: none;
  border-radius: 0.375rem 0.375rem 0 0;
  background-color: #f8f9fa;
  padding: 0.5rem;
}

trix-toolbar .trix-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

trix-toolbar .trix-button-group {
  display: flex;
  margin-bottom: 0;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  overflow: hidden;
}

trix-toolbar .trix-button-group:not(:first-child) {
  margin-left: 0.5rem;
}

trix-toolbar .trix-button {
  border: none;
  background: white;
  padding: 0.375rem 0.5rem;
  cursor: pointer;
}

trix-toolbar .trix-button:hover {
  background-color: #e9ecef;
}

trix-toolbar .trix-button.trix-active {
  background-color: #0d6efd;
  color: white;
}

trix-toolbar .trix-button--icon {
  width: 2.5rem;
  height: 2rem;
  text-indent: -9999px;
  position: relative;
}

trix-toolbar .trix-button--icon::before {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 1rem;
  content: "";
  opacity: 0.7;
}

trix-toolbar .trix-button--icon:hover::before,
trix-toolbar .trix-button--icon.trix-active::before {
  opacity: 1;
}

.trix-content {
  line-height: 1.6;
}

.trix-content h1 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.trix-content ul,
.trix-content ol {
  margin-left: 1.5rem;
  margin-bottom: 0.5rem;
}

.trix-content blockquote {
  border-left: 3px solid #dee2e6;
  padding-left: 1rem;
  margin-left: 0;
  color: #6c757d;
}

.trix-content pre {
  background-color: #f8f9fa;
  padding: 0.75rem;
  border-radius: 0.25rem;
  overflow-x: auto;
}

.trix-content a {
  color: #0d6efd;
}

/* Activity rich content display */
.activity-rich-content .trix-content {
  padding: 0;
}

/* Deal card dropdown fix */
.deal-card .dropdown-menu {
  position: absolute !important;
  z-index: 1050;
}

.deal-card {
  position: relative;
}

.deal-card .dropdown {
  position: static;
}

.pipeline-column {
  overflow: visible !important;
}

.stage-deals {
  overflow: visible !important;
}

/* ============================================
   SIDEBAR LAYOUT
   ============================================ */

:root {
  --sidebar-width: 240px;
  --sidebar-collapsed-width: 68px;
  --sidebar-bg: #1e1e2d;
  --sidebar-text: #9899ac;
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: rgba(13, 110, 253, 0.12);
  --sidebar-active-text: #0d6efd;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --mobile-topbar-height: 56px;
  --topbar-height: 56px;
}

/* Sidebar container */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: width var(--sidebar-transition);
  overflow: hidden;
}

/* Main content shift */
body.has-sidebar .sidebar-main-content {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--sidebar-transition);
  min-height: 100vh;
}

/* Collapsed state */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
}

body.sidebar-collapsed .sidebar-main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ---- Sidebar Header ---- */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 14px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 62px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  min-width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #0d6efd, #6610f2);
  border-radius: 10px;
  color: #fff;
  font-size: 1.1rem;
}

.sidebar-brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  margin-left: 10px;
  transition: opacity var(--sidebar-transition), width var(--sidebar-transition);
  opacity: 1;
}

body.sidebar-collapsed .sidebar-brand-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
  overflow: hidden;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--sidebar-text);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
  flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

body.sidebar-collapsed .sidebar-toggle-btn {
  margin: 0 auto;
}

/* ---- Sidebar Nav ---- */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

/* Section labels */
.sidebar-menu-label {
  padding: 18px 20px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.3);
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--sidebar-transition);
}

body.sidebar-collapsed .sidebar-menu-label span {
  opacity: 0;
}

body.sidebar-collapsed .sidebar-menu-label {
  padding: 14px 0 4px;
  text-align: center;
  min-height: 10px;
}

body.sidebar-collapsed .sidebar-menu-label::after {
  content: "";
  display: block;
  width: 24px;
  height: 1px;
  background: var(--sidebar-border);
  margin: 0 auto;
}

/* Menu items */
.sidebar-menu-item {
  padding: 2px 10px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  overflow: hidden;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.06);
  color: var(--sidebar-text-hover);
}

.sidebar-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.sidebar-link.active .sidebar-icon {
  color: var(--sidebar-active-text) !important;
}

.sidebar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  min-width: 22px;
  font-size: 1.1rem;
  transition: margin var(--sidebar-transition);
}

.sidebar-text {
  margin-left: 12px;
  transition: opacity var(--sidebar-transition), margin var(--sidebar-transition);
  opacity: 1;
}

body.sidebar-collapsed .sidebar-text {
  opacity: 0;
  width: 0;
  margin-left: 0;
  overflow: hidden;
  display: none;
}

body.sidebar-collapsed .sidebar-link {
  justify-content: center;
  padding: 10px 0;
}

body.sidebar-collapsed .sidebar-menu-item {
  padding: 2px 8px;
}

/* ---- Top Header Bar ---- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1020;
}

.topbar-left {
  display: flex;
  align-items: center;
}

.topbar-right {
  display: flex;
  align-items: center;
  margin-left: auto;
}

.topbar-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 5px 12px 5px 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.topbar-user-btn:hover,
.topbar-user-btn.show {
  background: #f8f9fa;
  border-color: #e9ecef;
}

.topbar-user-btn::after {
  /* dropdown caret */
  font-size: 0.65rem;
  color: #6c757d;
  margin-left: 4px;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: linear-gradient(135deg, #0d6efd, #6f42c1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.topbar-avatar-sm {
  width: 32px;
  height: 32px;
  min-width: 32px;
  background: linear-gradient(135deg, #0d6efd, #6f42c1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.topbar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #212529;
}

.topbar-user-role {
  font-size: 0.7rem;
  color: #6c757d;
}

.topbar .dropdown-menu {
  min-width: 220px;
  border-radius: 10px;
  padding: 8px 0;
}

.topbar .dropdown-item {
  font-size: 0.875rem;
  padding: 8px 16px;
  border-radius: 0;
}

.topbar .dropdown-item:hover {
  background: #f8f9fa;
}

.topbar .dropdown-item.text-danger:hover {
  background: #fff5f5;
}

.topbar .dropdown-header {
  padding: 8px 16px;
}

/* Remove caret styling for mobile dropdown */
.dropdown-toggle-no-caret::after {
  display: none !important;
}

/* ---- Mobile Topbar ---- */
.mobile-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-topbar-height);
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 1030;
}

.mobile-menu-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #333;
  padding: 4px;
  cursor: pointer;
}

.mobile-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: #0d6efd;
  text-decoration: none;
}

.mobile-brand:hover {
  color: #0b5ed7;
}

.mobile-user {
  font-size: 1.4rem;
  color: #6c757d;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1035;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
    z-index: 1045;
  }

  body.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-mobile-open .sidebar-overlay {
    display: block;
  }

  body.sidebar-collapsed .sidebar-text,
  body.sidebar-collapsed .sidebar-brand-text {
    opacity: 1;
    width: auto;
    margin-left: 10px;
    display: inline;
  }

  body.sidebar-collapsed .sidebar-link {
    justify-content: flex-start;
    padding: 9px 12px;
  }

  body.sidebar-collapsed .sidebar-menu-label span {
    opacity: 1;
  }

  body.sidebar-collapsed .sidebar-menu-label::after {
    display: none;
  }

  .sidebar-main-content {
    margin-left: 0 !important;
    padding-top: var(--mobile-topbar-height);
  }

  .sidebar-toggle-btn {
    display: none;
  }
}

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

  .sidebar-overlay {
    display: none !important;
  }
}
