// Main container styles
.leads-container {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  max-width: 90%;
  margin: 0 auto;
  padding: 2rem;
  color: #333;
  background-color: #f8f9fa;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);

  // Loader
  .loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;

    .loading-text {
      margin-top: 1rem;
      color: #5271FF;
      font-weight: 500;
    }
  }

  // Header section
  .leads-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #eaeaea;

    .leads-title {
      display: flex;
      align-items: center;
      font-size: 15px;
      margin: 0;
      color: #333;

      .leads-icon {
        margin-right: 0.75rem;
        color: #5271FF;
      }
    }

    .actions-container {
      .bulk-delete-btn {
        display: flex;
        align-items: center;
        background-color: #ff5252;
        color: white;
        border: none;
        border-radius: 4px;
        padding: 0.5rem 1rem;
        font-weight: 500;
        cursor: pointer;
        transition: background-color 0.2s;

        svg {
          margin-right: 0.5rem;
        }

        &:hover {
          background-color: darken(#ff5252, 10%);
        }
      }
    }
  }

  // Controls section
  .leads-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;

    .form-selector {
      display: flex;
      align-items: center;
      gap: 0.75rem;

      label {
        font-weight: 500;
        color: #555;
        width: 150px;
        margin-top: -15px;
      }

      .form-select {
        padding: 0.5rem 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        min-width: 220px;
        font-family: inherit;
        background-color: white;

        &:focus {
          outline: none;
          border-color: #5271FF;
          box-shadow: 0 0 0 2px rgba(82, 113, 255, 0.2);
        }
      }

      .form-count {
        font-size: 0.85rem;
        color: #777;
        background-color: #f0f2f5;
        padding: 0.25rem 0.75rem;
        border-radius: 12px;
        width: 45%;
        margin-top: -15px;
        display: flex;
        flex-direction: column;
        gap: 0.25rem;

        .auto-selected-indicator {
          font-size: 0.8rem;
          color: #667eea;
          font-weight: 600;
          background: linear-gradient(135deg, #e8f2ff 0%, #f0f7ff 100%);
          padding: 0.2rem 0.5rem;
          border-radius: 8px;
          border: 1px solid #b3d9ff;
          animation: fadeInPulse 0.5s ease-in-out;
        }
      }
    }

    .date-filter-section {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      flex-wrap: wrap;

      label {
        font-weight: 500;
        color: #555;
        white-space: nowrap;
      }

      .date-filter-select {
        padding: 0.5rem 1rem;
        border: 1px solid #ddd;
        border-radius: 4px;
        background-color: white;
        min-width: 150px;
        font-family: inherit;

        &:focus {
          outline: none;
          border-color: #5271FF;
          box-shadow: 0 0 0 2px rgba(82, 113, 255, 0.2);
        }
      }

      .custom-date-range {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-left: 10px;
        flex-wrap: wrap;

        .date-input {
          padding: 6px 10px;
          border: 1px solid #ddd;
          border-radius: 4px;
          font-size: 14px;
          font-family: inherit;

          &:focus {
            outline: none;
            border-color: #5271FF;
            box-shadow: 0 0 0 2px rgba(82, 113, 255, 0.2);
          }
        }

        .date-separator {
          color: #666;
          font-size: 14px;
          margin: 0 4px;
        }

        .apply-filter-btn {
          padding: 6px 12px;
          background: #5271FF;
          color: white;
          border: none;
          border-radius: 4px;
          cursor: pointer;
          font-size: 14px;
          font-weight: 500;
          transition: background-color 0.2s;

          &:hover:not(:disabled) {
            background: #4056d6;
          }

          &:disabled {
            background: #ccc;
            cursor: not-allowed;
          }
        }
      }
    }

    .export-options {
      display: flex;
      gap: 0.75rem;

      .export-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.5rem 1rem;
        border: none;
        border-radius: 4px;
        background-color: white;
        color: #555;
        cursor: pointer;
        font-weight: 500;
        transition: all 0.2s;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

        img {
          width: 18px;
          height: 18px;
          margin-right: 0.5rem;
        }

        span {
          font-size: 0.85rem;
        }

        &:hover {
          transform: translateY(-2px);
          box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }

        &.json:hover {
          background-color: #fffaf0;
          color: #f5a623;
        }

        &.csv:hover {
          background-color: #f0fff4;
          color: #3cb371;
        }

        &.pdf:hover {
          background-color: #fff0f0;
          color: #e53935;
        }

        &.print:hover {
          background-color: #f0f8ff;
          color: #2196f3;
        }
      }
    }
  }

  // Data grid styles
  .data-grid-wrapper {
    margin-bottom: 2rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

    .leads-datagrid {
      background-color: white;

      .MuiDataGrid-columnHeaders {
        background-color: #f5f7fa;
      }

      .MuiDataGrid-cell {
        padding: 1rem;
        white-space: normal;
        line-height: 1.5;
      }

      .image-cell {
        display: flex;
        justify-content: center;
        align-items: center;

        .lead-image {
          max-width: 80px;
          max-height: 60px;
          border-radius: 4px;
          object-fit: contain;

          &.error-image {
            opacity: 0.5;
          }
        }
      }

      .no-image {
        color: #999;
        font-style: italic;
      }

      .action-buttons {
        display: flex;
        gap: 0.5rem;

        button {
          display: flex;
          align-items: center;
          justify-content: center;
          width: 32px;
          height: 32px;
          border: none;
          border-radius: 4px;
          cursor: pointer;
          transition: all 0.2s;
          background-color: transparent;

          svg {
            font-size: 18px;
          }

          &.view-button {
            color: #5271FF;

            &:hover {
              background-color: rgba(82, 113, 255, 0.1);
            }
          }

          &.delete-button {
            color: #ff5252;

            &:hover {
              background-color: rgba(255, 82, 82, 0.1);
            }
          }
        }
      }
    }
  }

  // Empty state
  .empty-leads {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

    .empty-image {
      width: 180px;
      height: auto;
      margin-bottom: 1.5rem;
      opacity: 0.8;
    }

    h3 {
      font-size: 1.5rem;
      margin: 0 0 0.75rem;
      color: #333;
    }

    p {
      color: #777;
      max-width: 400px;
      margin: 0;
    }
  }
}

// Modal styles
/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  backdrop-filter: blur(3px);
  animation: fadeIn 0.2s ease-out;
}

/* Lead Modal */
.lead-modal {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
  position: relative;
}

/* Modal Header */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: #f8f9fa;
  border-bottom: 1px solid #eaecef;
}

.modal-header h2 {
  margin: 0;
  font-size: 20px;
  color: #333;
  font-weight: 600;
}

.close-button {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.close-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: #333;
}

/* Modal Content */
.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  max-height: calc(90vh - 140px);
  scrollbar-width: thin;
}

.modal-content::-webkit-scrollbar {
  width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
  background-color: #d1d5db;
  border-radius: 3px;
}

.modal-content::-webkit-scrollbar-track {
  background-color: #f3f4f6;
}

/* Modal Sections */
.modal-section {
  padding: 20px 24px;
  border-bottom: 1px solid #eaecef;
}

.modal-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: #5271FF;
  margin: 0 0 16px 0;
  padding-bottom: 8px;
  border-bottom: 1px solid #eaecef;
}

/* Table Styling */
.lead-data-table {
  overflow-x: auto;
}

.lead-data-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
}

.lead-data-table th {
  background-color: #f8f9fa;
  text-align: left;
  padding: 12px;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #eaecef;
}

.lead-data-table td {
  padding: 12px;
  border-bottom: 1px solid #eaecef;
  word-break: break-word;
  vertical-align: top;
}

.lead-data-table tr:last-child td {
  border-bottom: none;
}

.lead-data-table tr:hover {
  background-color: #f8f9fa;
}

.field-name {
  width: 30%;
  color: #555;
  font-weight: 500;
}

.field-value {
  width: 70%;
}

/* Image Styling */
.image-container {
  max-width: 100%;
  overflow: hidden;
}

.lead-detail-image {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  border: 1px solid #eaecef;
  cursor: pointer;
  transition: transform 0.2s;
}

.lead-detail-image:hover {
  transform: scale(1.02);
}

/* Modal Footer */
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background-color: #f8f9fa;
  border-top: 1px solid #eaecef;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.secondary-btn,
.export-btn,
.delete-btn {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.secondary-btn {
  background-color: #f0f2f5;
  color: #555;
  border: 1px solid #d1d5db;
}

.secondary-btn:hover {
  background-color: #e4e7eb;
}

.export-btn {
  background-color: #4caf50;
  color: white;
  border: none;
}

.export-btn:hover {
  background-color: #43a047;
}

.delete-btn {
  background-color: #f44336;
  color: white;
  border: none;
}

.delete-btn:hover {
  background-color: #e53935;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideIn {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .lead-modal {
    width: 95%;
    max-height: 95vh;
  }

  .modal-content {
    max-height: calc(95vh - 140px);
  }

  .modal-section {
    padding: 16px;
  }

  .field-name,
  .field-value {
    width: 100%;
    display: block;
  }

  .lead-data-table td {
    padding: 10px;
  }

  .lead-data-table table {
    table-layout: auto;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 12px;
  }

  .action-buttons {
    width: 100%;
    justify-content: space-between;
  }

  .secondary-btn {
    width: 100%;
    justify-content: center;
  }
}

// Delete confirmation modal
.delete-modal {
  width: 400px;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  animation: scaleIn 0.3s ease;
  overflow: hidden;

  .delete-modal-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;
    text-align: center;

    .delete-image {
      width: 120px;
      height: 120px;
      margin-bottom: 1.5rem;
    }

    h2 {
      margin: 0 0 0.75rem;
      color: #ff5252;
    }

    p {
      margin: 0 0 1.5rem;
      color: #666;
      line-height: 1.5;
    }

    .delete-modal-actions {
      display: flex;
      gap: 1rem;
      width: 100%;
      justify-content: center;

      button {
        padding: 0.75rem 1.5rem;
        border-radius: 4px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s;
        min-width: 100px;

        &.cancel-btn {
          background-color: #f0f2f5;
          border: 1px solid #ddd;
          color: #555;

          &:hover {
            background-color: darken(#f0f2f5, 5%);
          }
        }

        &.confirm-btn {
          background-color: #ff5252;
          color: white;
          border: none;

          &:hover {
            background-color: darken(#ff5252, 10%);
          }
        }
      }
    }
  }
}

// Animations
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

// Responsive adjustments
@media (max-width: 768px) {
  .leads-container {
    padding: 1rem;

    .leads-controls {
      flex-direction: column;
      align-items: flex-start;

      .form-selector {
        width: 100%;

        .form-select {
          flex: 1;
        }
      }

      .export-options {
        width: 100%;
        justify-content: space-between;
      }
    }
  }

  .lead-modal {
    width: 95%;

    .modal-content {
      padding: 1rem;
    }
  }
}

// Animation for auto-selected indicator
@keyframes fadeInPulse {
  0% {
    opacity: 0;
    transform: scale(0.9);
  }

  50% {
    opacity: 1;
    transform: scale(1.05);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

// Leads limit banner
.leads-limit-banner {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 16px 24px;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid #f59e0b;
  border-radius: 12px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);

  .banner-icon {
    color: #f59e0b;
    font-size: 24px;
  }

  .banner-content {
    flex: 1;

    strong {
      display: block;
      color: #92400e;
      font-size: 16px;
      margin-bottom: 4px;
    }

    p {
      color: #78350f;
      font-size: 14px;
      margin: 0;
    }
  }

  .banner-upgrade-btn {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    }
  }
}

// Export buttons locked state
.export-options {
  .export-btn.locked {
    position: relative;
    opacity: 0.6;
    cursor: not-allowed;

    &:hover {
      transform: none;
    }

    .export-lock-icon {
      position: absolute;
      top: 10%;
      right: 8px;
      transform: translateY(-50%);
      font-size: 14px;
      color: #667eea;
    }
  }
}

// Date filter locked option
.date-filter-select {
  option:disabled {
    color: #999;
    font-style: italic;
  }
}

// For
m selector locked notice .form-count {
  display: flex;
  gap: 15px;
  align-items: center;
  margin-top: 8px;

  .locked-forms-notice {
    color: #f59e0b;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(245, 158, 11, 0.1);
    border-radius: 6px;
    border: 1px solid rgba(245, 158, 11, 0.3);
  }
}

// Locked select options
.form-select {
  option:disabled {
    color: #999;
    font-style: italic;
  }
}