/* CRM Dashboard Styles */
.conversation-summary-box {
  background: #fff;
  border-radius: 12px;
  margin-bottom: 24px;
  margin-top: 16px;
  overflow: hidden;
  border: 1px solid #e0e0e0;
}

.summary-header-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 16px 12px;
}

.summary-header-content {
  display: flex;
  align-items: center;
  flex: 1;
}

.summary-header-content > * {
  margin-right: 8px;
}

.summary-header-content > *:last-child {
  margin-right: 0;
}

.summary-header-content h4 {
  margin: 0;
  font-size: 15px;
  color: #9333ea;
  font-weight: 600;
  display: flex;
  align-items: center;
}

#refresh-summary-btn {
  background: transparent;
  color: #9333ea;
  border: none;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.summary-content-crm {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.summary-content-inner {
  padding: 0 12px 12px 12px;
}

.summary-content-box {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid #9333ea;
}

.summary-timestamp {
  font-size: 11px;
  color: #666;
  margin-bottom: 6px;
  font-weight: 500;
}

.summary-content-box p {
  margin: 0;
  font-size: 14px;
  color: #333;
  line-height: 1.8;
}

.summary-address-link {
  color: #9333ea;
  text-decoration: underline;
}

.summary-strong {
  color: #9333ea;
}

.checklist-container {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.checklist-container h5 {
  margin: 0 0 12px 0;
  font-size: 13px;
  color: #9333ea;
  font-weight: 600;
}

.checklist-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
}

.checklist-item {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.checklist-label span.checked {
  text-decoration: line-through;
  opacity: 0.6;
}

.suggested-buttons {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

#send-suggested-btn {
  background: #9333ea;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  flex: 1;
}

#schedule-suggested-btn {
  background: #3b82f6;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  flex: 1;
}

#generate-summary-btn {
  background: #9333ea;
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  width: 100%;
}

.conversation-summary-box.no-summary {
  padding: 16px 12px;
}

.conversation-summary-box.no-summary h4 {
  font-size: 15px;
  color: #9333ea;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-header {
  cursor: pointer;
  position: relative;
  padding: 16px 12px;
}

.quote-header-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-title-badges {
  display: flex;
  flex-direction: column;
  text-transform: uppercase;
  flex: 1;
}

.quote-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.quote-title-badges h4 {
  margin: 0;
}

.status-badges {
  display: flex;
  flex-wrap: wrap;
  padding-top: 14px;
}

.quote-toggle-icon {
  transition: transform 0.3s;
}

.quote-toggle-icon.rotated {
  transform: rotate(-90deg);
}

.quote-header h4 {
  margin: 0;
}

.edit-quote-btn {
  position: absolute;
  top: 8px;
  right: 4px;
  background: transparent;
  border: none;
  color: #9333ea;
  cursor: pointer;
  padding: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  border-radius: 6px;
}

.edit-quote-btn svg {
  width: 24px;
  height: 24px;
}

.edit-quote-btn:hover svg {
  stroke: white;
}

.quote-content {
  padding: 12px;
}

.quote-content.hidden {
  display: none;
}

.customer-page-link-container {
  margin-bottom: 12px;
}

.customer-page-link {
  display: block;
  background: #9333ea;
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  text-decoration: none;
  text-align: center;
}

.detail-value.phone-link {
  color: inherit;
  text-decoration: none;
}

.notes-section {
  margin-bottom: 24px;
  margin-top: 16px;
}

.notes-header-toggle {
  margin: 0;
  padding: 16px 6px 6px 12px;
  font-size: 15px;
  color: #9333ea;
  font-weight: 600;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.notes-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 12px 16px 12px;
}

.note-item {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 8px;
  border-left: 3px solid #9333ea;
}

.note-item.no-timestamp {
  border-left: 3px solid #666;
}

.note-timestamp {
  color: #666;
  font-size: 11px;
  margin-bottom: 6px;
  font-weight: 500;
}

.note-text {
  color: #333;
  font-size: 14px;
}

.quotes-section.event-details {
  margin-bottom: 24px;
}

.event-details-content {
  padding: 0 12px 12px 12px;
}

.status-badge {
  font-size: 12px;
  padding: 6px 10px 6px 10px;
  border-radius: 0;
  font-weight: 600;
  text-transform: uppercase;
  clip-path: polygon(0 0, calc(100% - 4px) 0, 100% 50%, calc(100% - 4px) 100%, 0 100%, 4px 50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.status-accepted {
  background: #3b82f6;
  color: white;
}

.status-pending {
  background: #f59e0b;
  color: white;
}

.status-declined {
  background: #ef4444;
  color: white;
}

.status-deposit {
  background: #10b981;
  color: white;
}

.status-paid {
  background: linear-gradient(135deg, #ffd700 0%, #ffed4e 50%, #ffd700 100%);
  color: #000;
  text-shadow: 0 0 2px rgba(255, 215, 0, 0.5);
}

.status-cocktails {
  background: #9333ea;
  color: white;
  padding: 6px 8px;
}

.status-cocktails svg {
  display: block;
}



#crm-panel {
  padding: 0 !important;
}

.crm-dashboard {
  padding: 8px 8px 0 8px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.quotes-section h3 {
  padding-left: 16px !important;
}

button svg,
.edit-quote-btn svg,
#refresh-summary-btn svg,
.action-btn svg,
.detail-icon svg,
.metric-icon svg {
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
}

button,
.edit-quote-btn,
#refresh-summary-btn,
.action-btn {
  -webkit-touch-callout: none !important;
  -webkit-user-select: none !important;
  user-select: none !important;
}

body.dark-mode .conversation-summary-box {
  background: #2c2c2e;
  border-color: #38383a;
}

body.dark-mode .summary-content-box,
body.dark-mode .note-item {
  background: #1c1c1e;
}

body.dark-mode .summary-timestamp,
body.dark-mode .note-timestamp {
  color: #999;
}

body.dark-mode .summary-content-box p,
body.dark-mode .note-text,
body.dark-mode .checklist-label {
  color: #e0e0e0;
}

/* Tab Styles */
.crm-tabs {
  display: flex;
  gap: 4px;
  margin-top: 16px;
  border-top: 2px solid #e0e0e0;
  position: sticky;
  bottom: 0;
  background: white;
  z-index: 10;
}

.crm-tab {
  background: transparent;
  border: none;
  padding: 12px 16px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #666;
  border-top: 3px solid transparent;
  transition: all 0.2s;
}

.crm-tab:hover {
  color: #9333ea;
  background: #f8f9fa;
}

.crm-tab.active {
  color: #9333ea;
  border-top-color: #9333ea;
}

.crm-tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
}

body.dark-mode .crm-tabs {
  border-top-color: #38383a;
  background: #1c1c1e;
}

body.dark-mode .crm-tab {
  color: #999;
}

body.dark-mode .crm-tab:hover {
  color: #9333ea;
  background: #2c2c2e;
}

body.dark-mode .crm-tab.active {
  color: #9333ea;
}

/* Mobile: Actions tab content from bottom to top */
@media (max-width: 768px) {
  .crm-tab-content[data-content="actions"][style*="display: block"] {
    display: flex !important;
    flex-direction: column-reverse;
  }
  
  .generic-h4 {
    margin-top: 0 !important;
  }
}

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

/* Customer Portal Button */
.portal-button-container {
  padding: 0 12px 16px 12px;
}

.portal-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #9333ea 0%, #7c3aed 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(147, 51, 234, 0.2);
}

.portal-button:hover {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  box-shadow: 0 4px 8px rgba(147, 51, 234, 0.3);
  transform: translateY(-1px);
}

.portal-button svg {
  flex-shrink: 0;
}

body.dark-mode .portal-button {
  box-shadow: 0 2px 4px rgba(147, 51, 234, 0.4);
}

body.dark-mode .portal-button:hover {
  box-shadow: 0 4px 8px rgba(147, 51, 234, 0.5);
}

/* Sidebar */
.crm-sidebar {
  width: 380px;
  background: #f9f9f9;
  border-left: 1px solid #ddd;
  overflow-y: auto;
  padding: 20px;
  transition: margin-right 0.3s ease;
}

.crm-sidebar.desktop-hidden {
  margin-right: -380px;
}

.crm-dashboard h3 {
  font-size: 16px;
  margin: 0 0 16px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.generic-h4 {
  text-align: center;
  padding: 12px 0;
}

.crm-dashboard h4 {
  font-size: 14px;
  margin: 0 0 12px 0;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.quotes-section {
  margin-bottom: 24px;
}

.quote-card {
  background: #fff;
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
}

.quote-date {
  font-size: 12px;
  color: #8e8e93;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 10;
  gap: 6px;
  margin-bottom: 8px;
  margin-top: 18px;
  align-items: center;
}

.metric-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  overflow: hidden;
  border: 1px solid #e8e8e8;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.metric-label {
  font-size: 12px;
  color: #8e8e93;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-weight: 400;
  line-height: 1.2;
}

.metric-icon {
  color: #9333ea;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.metric-icon svg {
  display: block;
}

.metric-value {
  font-size: 16px;
  font-weight: 600;
  color: #1d1d1f;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.details-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 6px 0;
}

.detail-icon {
  color: #8e8e93;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: 20px;
}

.detail-label {
  color: #8e8e93;
  min-width: 70px;
  font-size: 12px;
  flex-shrink: 0;
}

.detail-value {
  color: #1d1d1f;
  font-weight: 500;
  flex: 1;
  text-align: right;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.customer-section {
  margin-bottom: 24px;
}

.customer-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  border: 1px solid #e0e0e0;
}

.actions-section {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  border: 1px solid #e0e0e0;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  background: #9333ea;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s;
}

.action-btn:hover {
  background: #be123c;
}

.collapsible-section {
  margin-top: 12px;
  border-top: 1px solid #f0f0f0;
  padding-top: 12px;
}

.collapse-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 8px 0;
  background: none;
  border: none;
  color: #9333ea;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
}

.collapse-toggle svg {
  transition: transform 0.2s;
}

.collapsible-section.expanded .collapse-toggle svg {
  transform: rotate(180deg);
}

.collapse-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.collapsible-section.expanded .collapse-content {
  max-height: 500px;
  margin-top: 8px;
}

.crm-panel h3 {
  margin-bottom: 16px;
  font-size: 18px;
}

.crm-field {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
}

.crm-field label {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.crm-field span {
  font-size: 14px;
  color: #333;
}

.crm-empty, .crm-error {
  text-align: center;
  color: #999;
  padding: 20px;
}

.crm-quote {
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.crm-quote h4 {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: #9333ea;
}

.crm-close-btn {
  display: none;
  position: absolute;
  top: 20px;
  right: 20px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.crm-close-btn:active {
  background: rgba(0, 0, 0, 0.2);
}

body.dark-mode .crm-close-btn {
  background: rgba(255, 255, 255, 0.1);
}

body.dark-mode .crm-close-btn:active {
  background: rgba(255, 255, 255, 0.2);
}

#toggle-crm-btn {
  margin-left: 5px;
}

.crm-action-btn {
  width: 100%;
  padding: 12px;
  margin: 16px 0;
  background: #9333ea;
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.crm-action-btn:hover {
  background: #be123c;
}

body.dark-mode .crm-action-btn {
  background: #9333ea;
}

body.dark-mode .crm-action-btn:hover {
  background: #9333ea;
}

.crm-action-btn-small {
  padding: 8px 12px;
  margin: 4px 4px 4px 0;
  background: #9333ea;
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  font-size: 13px;
}

.crm-action-btn-small:hover {
  background: #be123c;
}

body.dark-mode .crm-action-btn-small {
  background: #9333ea;
}

body.dark-mode .crm-action-btn-small:hover {
  background: #9333ea;
}

.quote-contact-details {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid #e0e0e0;
}

.quote-contact-details .detail-row {
  display: grid;
  grid-template-columns: 24px 1fr 2fr;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
}

.quote-contact-details .detail-label {
  color: #666;
  font-weight: 500;
}

.quote-contact-details .detail-value {
  color: #333;
}

.notes-box {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px;
}

body.dark-mode .notes-box {
  background: #1c1c1e;
}

body.dark-mode .crm-sidebar {
  background: #1c1c1e;
  border-left-color: #38383a;
  color: #fff;
}

body.dark-mode .quote-card,
body.dark-mode .customer-card,
body.dark-mode .actions-section {
  background: #2c2c2e;
  border-color: #38383a;
}

body.dark-mode .quote-header {
  border-bottom-color: #38383a;
}

body.dark-mode .quote-header h4 {
  color: #9333ea;
}

body.dark-mode .metric-card {
  background: #1c1c1e;
  border-color: #38383a;
}

body.dark-mode .metric-icon {
  color: #9333ea;
}

body.dark-mode .metric-value,
body.dark-mode .detail-value {
  color: #fff;
}

body.dark-mode .action-btn {
  background: #9333ea;
}

body.dark-mode .action-btn:hover {
  background: #9333ea;
}

body.dark-mode .collapsible-section {
  border-top-color: #38383a;
}

body.dark-mode .collapse-toggle {
  color: #9333ea;
}

body.dark-mode .crm-field {
  border-bottom-color: #38383a;
}

body.dark-mode .crm-field label {
  color: #8e8e93;
}

body.dark-mode .crm-field span {
  color: #fff;
}

body.dark-mode .crm-quote {
  background: #2c2c2e;
  border-color: #38383a;
}

body.dark-mode .crm-empty,
body.dark-mode .crm-error {
  color: #8e8e93;
}

body.dark-mode .quote-contact-details {
  background: #1c1c1e;
  border-color: #3a3a3c;
}

body.dark-mode .quote-contact-details .detail-label {
  color: #9ca3af;
}

body.dark-mode .quote-contact-details .detail-value {
  color: #e0e0e0;
}

@media (max-width: 768px) {
  .crm-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    height: 100vh;
    z-index: 200;
    transform: translateX(100%);
    transition: transform 0.3s;
    box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
    margin-right: 0;
  }

  .crm-sidebar.active {
    transform: translateX(0);
  }

  .crm-close-btn {
    display: flex;
  }
}

@media (max-width: 768px) {
  .crm-sidebar {
    transition: transform 0.3s ease-out;
  }
}
