@import "../../../customer-service-styles.scss";

.consultation-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

// 页面头部
.page-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);

  .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: #f8fafc;
    border-radius: 10px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;

    &:hover {
      background: #e2e8f0;
      color: #475569;
      transform: translateX(-2px);
    }

    &:active {
      transform: translateX(-1px);
    }
  }

  .header-title {
    h1 {
      font-size: 24px;
      font-weight: 700;
      color: #1e293b;
      margin: 0;
      line-height: 1.2;
    }

    .subtitle {
      font-size: 14px;
      color: #64748b;
      margin: 4px 0 0;
      line-height: 1.4;
    }
  }

  .header-actions {
    .refresh-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      border: 1px solid #e2e8f0;
      background: #ffffff;
      border-radius: 8px;
      color: #475569;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;

      &:hover:not(:disabled) {
        background: #f8fafc;
        border-color: #cbd5e1;
      }

      &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
      }

      svg.spinning {
        animation: spin 1s linear infinite;
      }
    }
  }
}

// 搜索和筛选区域
.search-filter-section {
  padding: 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;

  .search-container {
    margin-bottom: 20px;

    .search-input-wrapper {
      position: relative;
      max-width: 500px;

      .search-icon {
        position: absolute;
        left: 16px;
        top: 50%;
        transform: translateY(-50%);
        color: #94a3b8;
        z-index: 2;
      }

      .search-input {
        width: 100%;
        padding: 14px 16px 14px 48px;
        border: 2px solid #e2e8f0;
        border-radius: 12px;
        font-size: 16px;
        background: #f8fafc;
        transition: all 0.2s ease;
        outline: none;

        &::placeholder {
          color: #94a3b8;
        }

        &:focus {
          border-color: #3b82f6;
          background: #ffffff;
          box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
        }
      }

      .clear-search {
        position: absolute;
        right: 12px;
        top: 50%;
        transform: translateY(-50%);
        width: 24px;
        height: 24px;
        border: none;
        background: #e2e8f0;
        border-radius: 50%;
        color: #64748b;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;

        &:hover {
          background: #cbd5e1;
          color: #475569;
        }
      }
    }
  }

  .filter-chips {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;

    .filter-chip {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      border: 2px solid #e2e8f0;
      background: #ffffff;
      border-radius: 20px;
      color: #64748b;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;
      position: relative;

      &:hover {
        border-color: #cbd5e1;
        background: #f8fafc;
      }

      &.active {
        border-color: #3b82f6;
        background: #3b82f6;
        color: #ffffff;

        .chip-count {
          background: rgba(255, 255, 255, 0.2);
          color: #ffffff;
        }
      }

      .chip-count {
        background: #e2e8f0;
        color: #64748b;
        padding: 2px 8px;
        border-radius: 10px;
        font-size: 12px;
        font-weight: 600;
        min-width: 20px;
        text-align: center;
      }
    }
  }
}

// 咨询内容区域
.consultation-content {
  padding: 24px;
  min-height: 400px;

  .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #64748b;

    .loading-spinner {
      width: 40px;
      height: 40px;
      border: 3px solid #e2e8f0;
      border-top: 3px solid #3b82f6;
      border-radius: 50%;
      animation: spin 1s linear infinite;
      margin-bottom: 16px;
    }

    p {
      font-size: 16px;
      margin: 0;
    }
  }

  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: #64748b;

    svg {
      margin-bottom: 20px;
      opacity: 0.5;
    }

    h3 {
      font-size: 20px;
      font-weight: 600;
      color: #475569;
      margin: 0 0 8px;
    }

    p {
      font-size: 16px;
      margin: 0;
      line-height: 1.5;
    }
  }

  .consultation-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
}

// 咨询条目
.consultation-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;

  &:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
  }

  &.urgent {
    border-left: 4px solid #ef4444;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
  }

  &.sensitive {
    border-left: 4px solid #f59e0b;
    background: linear-gradient(135deg, #fffbeb 0%, #ffffff 100%);
  }

  &.overdue {
    border-left: 4px solid #dc2626;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%);
  }

  .item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;

    .customer-section {
      display: flex;
      align-items: center;
      gap: 12px;
      flex: 1;

      .customer-avatar {
        width: 48px;
        height: 48px;
        border-radius: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #ffffff;
        font-size: 18px;
        font-weight: 600;
        flex-shrink: 0;
      }

      .customer-details {
        flex: 1;

        .customer-name {
          font-size: 18px;
          font-weight: 600;
          color: #1e293b;
          margin: 0 0 4px;
          line-height: 1.3;
        }

        .customer-meta {
          display: flex;
          align-items: center;
          gap: 8px;
          font-size: 14px;
          color: #64748b;

          .separator {
            color: #cbd5e1;
          }

          .reply-status {
            &.overdue {
              color: #dc2626;
              font-weight: 500;
            }
          }
        }
      }
    }

    .priority-badges {
      display: flex;
      gap: 8px;
      flex-shrink: 0;

      .priority-badge {
        display: flex;
        align-items: center;
        gap: 4px;
        padding: 6px 10px;
        border-radius: 12px;
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;

        &.urgent {
          background: #fef2f2;
          color: #dc2626;
          border: 1px solid #fecaca;
        }

        &.sensitive {
          background: #fffbeb;
          color: #d97706;
          border: 1px solid #fed7aa;
        }
      }
    }
  }

  .consultation-content-text {
    margin-bottom: 20px;

    p {
      font-size: 16px;
      line-height: 1.6;
      color: #374151;
      margin: 0;

      :global(mark) {
        background: #fef3c7;
        color: #92400e;
        padding: 2px 4px;
        border-radius: 4px;
        font-weight: 500;
      }
    }
  }

  .item-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;

    .action-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      border-radius: 8px;
      font-size: 14px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.2s ease;
      border: none;
      outline: none;

      &:disabled {
        opacity: 0.6;
        cursor: not-allowed;
      }

      &.primary {
        background: #3b82f6;
        color: #ffffff;

        &:hover:not(:disabled) {
          background: #2563eb;
          transform: translateY(-1px);
          box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
        }
      }

      &.secondary {
        background: #f8fafc;
        color: #475569;
        border: 1px solid #e2e8f0;

        &:hover {
          background: #f1f5f9;
          border-color: #cbd5e1;
        }
      }

      &.tertiary {
        background: #f0fdf4;
        color: #16a34a;
        border: 1px solid #bbf7d0;

        &:hover {
          background: #dcfce7;
          border-color: #86efac;
        }
      }
    }
  }
}

// 动画
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

// 响应式设计
@media (max-width: 768px) {
  .page-header {
    padding: 16px 20px;

    .header-title h1 {
      font-size: 20px;
    }

    .header-actions .refresh-btn {
      padding: 8px 12px;
      font-size: 13px;
    }
  }

  .search-filter-section {
    padding: 20px;

    .search-container .search-input-wrapper .search-input {
      font-size: 16px; // 防止iOS缩放
    }

    .filter-chips {
      gap: 8px;

      .filter-chip {
        padding: 8px 12px;
        font-size: 13px;
      }
    }
  }

  .consultation-content {
    padding: 20px;

    .consultation-item {
      padding: 16px;

      .item-header {
        .customer-section {
          .customer-avatar {
            width: 40px;
            height: 40px;
            font-size: 16px;
          }

          .customer-details .customer-name {
            font-size: 16px;
          }
        }
      }

      .consultation-content-text p {
        font-size: 15px;
      }

      .item-actions {
        gap: 8px;

        .action-btn {
          padding: 8px 12px;
          font-size: 13px;
        }
      }
    }
  }
}

@media (max-width: 480px) {
  .page-header {
    .header-left {
      gap: 12px;
    }

    .header-title h1 {
      font-size: 18px;
    }
  }

  .consultation-item {
    .item-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 12px;

      .priority-badges {
        align-self: flex-end;
      }
    }

    .item-actions {
      .action-btn {
        flex: 1;
        justify-content: center;
        min-width: 0;
      }
    }
  }
}